furkanom / tf-faster-rcnn Goto Github PK
View Code? Open in Web Editor NEWTensorflow 2 Faster-RCNN implementation from scratch supporting to the batch processing with MobileNetV2 and VGG16 backbones
License: Apache License 2.0
Tensorflow 2 Faster-RCNN implementation from scratch supporting to the batch processing with MobileNetV2 and VGG16 backbones
License: Apache License 2.0
how i can use my own dataset like voc2007 which include train.txt test.txt?
hello,i want to running this code,but have a error,this is
tensorflow_datasets.core.download.extractor.ExtractError: Error while extracting C:\Users\yzk/tensorflow_datasets\downloads\pjreddi.com_media_files_VOCtest_6-Nov-2007-uyfHB4aCy4ZRNbxEOl0zsGlfk4orDpuRRs8mcmQyGk.tar to C:\Users\yzk/tensorflow_datasets\downloads\extracted\TAR.pjreddi.com_media_files_VOCtest_6-Nov-2007-uyfHB4aCy4ZRNbxEOl0zsGlfk4orDpuRRs8mcmQyGk.tar (file: VOCdevkit\VOC2007\Annotations\000001.xml) : Failed to create a directory: C:\Users\yzk/tensorflow_datasets\downloads\extracted\TAR.pjreddi.com_media_files_VOCtest_6-Nov-2007-uyfHB4aCy4ZRNbxEOl0zsGlfk4orDpuRRs8mcmQyGk.tar.incomplete_60a23fd8d1924f2dbe3005c1dcb96f47\VOCdevkit\VOC2007\Annotations; No such file or directory
i don`t know deal with this error.
think you!!!!
Any idea how to fix this?
Hi,
The code you did for Faster RCNN was really amazing, but in preprocessing function after you resized the image, I did not find where have you handled the bbox for the following resized image, Please know whether its there on the code or not??
Thank you in advance
K Rohan Varma
When training the RPN Model for example, wouldn't be more suitable to reuse the weights for 'imagenet' instead of retrain all model from scratch?
Did you noticed better results when training all model instead of only last layers?
Thank you
1- AssertionError: Could not compute output Tensor("rpn_reg_loss/truediv:0", shape=(), dtype=float32) in faster rcnn
2-Incompatible shapes: [8,9216] vs. [8]
[[node gradient_tape/reg_loss/mul/BroadcastGradientArgs (defined at e:/faster_rcnn/rpn_trainer.py:60) ]] [Op:__inference_train_function_12539] in rpn alone
can any one solve this issue please on training faster_rcnn_trainer.py
Anyone know what is variances in train_utils.py?
I tried search of it and can't find any answer.
WARNING:tensorflow:input_shape
is undefined or non-square, or rows
is not in [96, 128, 160, 192, 224]. Weights for input shape (224, 224) will be loaded as the default.
WARNING:tensorflow:input_shape
is undefined or non-square, or rows
is not in [96, 128, 160, 192, 224]. Weights for input shape (224, 224) will be loaded as the default.
Epoch 1/2
Traceback (most recent call last):
File "C:/Users/SV60002880/Desktop/FRCNN/rpn_trainer.py", line 66, in
rpn_model.fit(rpn_train_feed,
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\keras\engine\training.py", line 66, in _method_wrapper
return method(self, *args, **kwargs)
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\keras\engine\training.py", line 848, in fit
tmp_logs = train_function(iterator)
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\eager\def_function.py", line 580, in call
result = self._call(*args, **kwds)
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\eager\def_function.py", line 644, in _call
return self._stateless_fn(*args, **kwds)
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\eager\function.py", line 2420, in call
return graph_function._filtered_call(args, kwargs) # pylint: disable=protected-access
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\eager\function.py", line 1661, in _filtered_call
return self._call_flat(
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\eager\function.py", line 1745, in _call_flat
return self._build_call_outputs(self._inference_function.call(
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\eager\function.py", line 593, in call
outputs = execute.execute(
File "D:\anaconda\envs\CPU\lib\site-packages\tensorflow\python\eager\execute.py", line 59, in quick_execute
tensors = pywrap_tfe.TFE_Py_Execute(ctx._handle, device_name, op_name,
tensorflow.python.framework.errors_impl.InvalidArgumentError: Incompatible shapes: [4,9216] vs. [4]
[[node reg_loss/mul (defined at C:\Users\SV60002880\Desktop\FRCNN\utils\train_utils.py:223) ]] [Op:__inference_train_function_14590]
Errors may have originated from an input operation.
Input Source operations connected to node reg_loss/mul:
reg_loss/Cast (defined at C:\Users\SV60002880\Desktop\FRCNN\utils\train_utils.py:221)
reg_loss/Sum (defined at C:\Users\SV60002880\Desktop\FRCNN\utils\train_utils.py:218)
Function call stack:
train_function
how to solve it
Tensorflow 2.3.1, can anybody share the solution for the problem above
Hi, I trained the RPN only with rpn_trainer.py with mobilenet_v2 backbone on voc2007, batch size 1 and 50 epochs.
But when running rpn_predictor.py as it is, no changes, I got tons of bounding boxes like in attached image.
Which code should be run to get similar predictions (i.e. just a few bounding boxes) like you obtained in your example with the lion picture?
Thanks!
Hi, I'm now facing a problem when training on your code.
I have trained about 37 epochs on PASCAL VOC 2007 trainval dataset directly, and it turns out no bounding box appeared on test image.
I wonder what is your training procedure, for example, changing learning rate value or training RPN and Regression layers alternatively.
Thanks a lot!!!
dataset, info = tfds.load("voc/2007", split="train+validation",data_dir="D:/faster_voc2007",with_info=True),
一直提示创建不了目录
Failed to create a directory: D:/faster_voc2007\voc2007\1.0.0.incompleteSHSNAR; No such file or directory
I have a voc2007 datasets, how to use it without tfds.load() ?
and it seems your code is wrong with it:
data_utils.get_dataset("voc/2007", "train+validation")
voc2007 is in the tfds' list, voc/2007 not.
Hi FurkanOM,
Would you be able to upload your pipeline.config?
I cant make out what feature_extractor you're using and weather it is locked or training.
Instructions for updating:
Use tf.where in 2.0, which has the same broadcast rule as np.where
Traceback (most recent call last):
File "C:/Users/famer/PycharmProjects/tf-faster-rcnn/faster_rcnn_trainer.py", line 53, in
frcnn_model = faster_rcnn.get_model(feature_extractor, rpn_model, anchors, hyper_params)
File "C:\Users\famer\PycharmProjects\tf-faster-rcnn\models\faster_rcnn.py", line 254, in get_model
[roi_bboxes, input_gt_boxes, input_gt_labels])
File "C:\Users\famer\anaconda3\lib\site-packages\tensorflow_core\python\keras\engine\base_layer.py", line 854, in call
outputs = call_fn(cast_inputs, *args, **kwargs)
File "C:\Users\famer\anaconda3\lib\site-packages\tensorflow_core\python\autograph\impl\api.py", line 237, in wrapper
raise e.ag_error_metadata.to_exception(e)
ValueError: in converted code:
relative to C:\Users\famer:
PycharmProjects\tf-faster-rcnn\models\faster_rcnn.py:162 call *
expanded_gt_boxes = tf.where(tf.expand_dims(pos_mask, axis=-1), gt_boxes_map, tf.zeros_like(gt_boxes_map))
anaconda3\lib\site-packages\tensorflow_core\python\util\deprecation.py:324 new_func
return func(*args, **kwargs)
anaconda3\lib\site-packages\tensorflow_core\python\util\dispatch.py:180 wrapper
return target(*args, **kwargs)
anaconda3\lib\site-packages\tensorflow_core\python\ops\array_ops.py:3759 where
return gen_math_ops.select(condition=condition, x=x, y=y, name=name)
anaconda3\lib\site-packages\tensorflow_core\python\ops\gen_math_ops.py:9439 select
"Select", condition=condition, t=x, e=y, name=name)
anaconda3\lib\site-packages\tensorflow_core\python\framework\op_def_library.py:794 _apply_op_helper
op_def=op_def)
anaconda3\lib\site-packages\tensorflow_core\python\util\deprecation.py:507 new_func
return func(*args, **kwargs)
anaconda3\lib\site-packages\tensorflow_core\python\framework\ops.py:3357 create_op
attrs, op_def, compute_device)
anaconda3\lib\site-packages\tensorflow_core\python\framework\ops.py:3426 _create_op_internal
op_def=op_def)
anaconda3\lib\site-packages\tensorflow_core\python\framework\ops.py:1770 __init__
control_input_ops)
anaconda3\lib\site-packages\tensorflow_core\python\framework\ops.py:1610 _create_c_op
raise ValueError(str(e))
ValueError: Dimension 2 in both shapes must be equal, but are 4 and 1. Shapes are [?,1500,4] and [?,1500,1]. for 'roi_deltas/Select' (op: 'Select') with input shapes: [?,1500,1], [?,1500,4], [?,1500,4].
tensorflow version : 2.0
python version : 3.7.6
I think this error occur at tf.where because update tensorflow
Hi,
Thanks for making this repo available. I've spent quite a bit of time implementing my own version of FasterRCNN in both PyTorch and TF2/Keras and have noticed that the latter is very difficult to get working with the same degree of performance and reliability as PyTorch.
I notice that you train for a large number of epochs (50) with a small learning rate (1e-5). Was this determined empirically? The original paper uses about 16 epochs (12 at lr=1e-3 and 4 at lr=1e-4), but this was with Caffe. My PyTorch model is capable of converging to the same mean average precision as the paper using 10 + 4 epochs.
However, with TF2/Keras, I've had to use aggressive gradient norm clipping to train at these learning rates and must increase the number of epochs drastically (I am still trying to determine the optimal number but it is at least 30).
Just wanted to confirm that you saw the same sort of instability during training that I saw when following the paper's recipe (lr=1e-3)?
Thank you,
Bart
My code when I run model to predict causing an error
step_size = train_utils.get_step_size(test_total_item, batch_size)
pred_bboxes, pred_labels, pred_scores = frcnn_test_model.predict(test_data, steps=step_size, verbose=1)
here is the stacktrace:
TypeError Traceback (most recent call last)
[<ipython-input-26-de9c8627623e>](https://localhost:8080/#) in <module>()
1 step_size = train_utils.get_step_size(test_total_item, batch_size)
----> 2 pred_bboxes, pred_labels, pred_scores = frcnn_test_model.predict(test_data, steps=step_size, verbose=1)
[/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/autograph/impl/api.py](https://localhost:8080/#) in wrapper(*args, **kwargs)
235 except Exception as e: # pylint:disable=broad-except
236 if hasattr(e, 'ag_error_metadata'):
--> 237 raise e.ag_error_metadata.to_exception(e)
238 else:
239 raise
TypeError: in converted code:
/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/keras/engine/training_v2.py:677 map_fn
batch_size=None)
/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/keras/engine/training.py:2474 _standardize_tensors
sample_weight, feed_output_names)
/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/keras/engine/training_utils.py:639 standardize_sample_weights
'sample_weight')
/usr/local/lib/python3.7/dist-packages/tensorflow_core/python/keras/engine/training_utils.py:629 standardize_sample_or_class_weights
str(x_weight))
TypeError: The model has multiple outputs, so `sample_weight` should be either a list or a dict. Provided `sample_weight` type not understood: Tensor("args_2:0", shape=(None, None), dtype=int32)
Thanks for the redeployment in TF2.I'm wondering if there is a checkpoint to download so that I could predict directly.
thx!
Hi FurkanOM, Thanks for the great work!!
This repository works only for square images. What if i want to keep the aspect ratio of my images and train, like 1280x720. Then the anchor generation and anchor target generations have to be modified. Any thoughts on implementing this soon?
I want to train Faster RCNN on four GPUs. Does this version support multi-GPU training?
Hello, Thanks Furqan for sharing your code. I am facing an issue while training the model with mobilenet_v2
other than that if I trace back, I find that image file's name are not being retrieved. as you can see from the first screen shot. snapshop. Even I cannot find where has tfds.load() downloaded the dataset. I cannot see that. can you please help.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.