Faster-RCNN_TF
Faster-RCNN_TF copied to clipboard
How to train my own model
I have changed the Annotation, Imagesets and JPEG dir into my dataset in VOC2007 and changed the classes and num_classes to 15. But it still don't work. Where else should I change?
Thanks.
hi,can you tell me how to make files of the annotation dir? any tools can be used?
Hi @yang1997yi
You have to make following changes also: lib/pascal_voc.py --> change the classes tools/demo.py --> change the classes
Thanks
Hi @zjz5250
You can use LabelImage tool for generating xml files for Annotation directory.
Thanks
how to change Main and Segementation floder under ImageSets @yang1997yi
how to change Main and Segementation floder under ImageSets @Akansha06
Hi @gentlebreeze1
Suppose u have 2 classes- male and female. You should have following named files in your Main folder i.e trainval.txt -->contains name of all the images train.txt and val.txt --> split the names into 70-30 ratio and add 70% to train.txt and 30% to val.txt test.txt --> pick some random image names and put it in test.txt
For each class: male.txt --> contain names of all the male images maletrain.txt, maleval.txt --> same as mentioned above(but ds data will contain only male class images name) Then same for female class.
Note: Please don't include extension inside these txt. Only names should be added. Else you ll get an error.
Happy Learning :)
Can you send me the modified code in lib/pascal_voc.py and tools/demo.py? should i modify other floders ?my email is [email protected] OR [email protected] ,thanks! @Akansha06
but how to get 1 or -1 in male_train.txt?do you have code to make dataset? @Akansha06 thanks
AssertionError: Path does not exist: /home/c303/student/yongzhang/Faster-RCNN_TF/data/VOCdevkit2007/VOC2007/JPEGImages/.jpg what's wrong? @Akansha06
Hi @gentlebreeze1 ,
In any of your text files there is a blank line. For this reason only there is assertion error
Hi @gentlebreeze1,
I am not clear with 1 and -1 . Can you explain it?? Because I have given only names in txt's and it was working fine
The data of standard VOC2007/ImageSets/main**_train.txt is as follows: 0000005 -1 0000007 1 0000009 -1 they say that the mean of 1 is positive sample and -1 is negative sample @Akansha62
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [8] rhs shape= [84] [[Node: save/Assign = Assign[T=DT_FLOAT, _class=["loc:@bbox_pred/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/gpu:0"](bbox_pred/biases, save/RestoreV2/_1)]] i get the problem , is it a tensorflow problem? @Akansha62
Hi @gentlebreeze1,
How many classes you are using?? You have to change it in VGGtest.py and VGGtrain.py present inside tools.
Hi @gentlebreeze1 ,
You don't have to give it 1 and -1 it will simply work
Thanks very much for your answer @Akansha62
i have 2 classes,i change classes into 3 in VGGtest.py and VGGtrain.py inside lib/networks.
is the problem related to the follows?
WARNING:tensorflow:*******************************************************
WARNING:tensorflow:TensorFlow's V1 checkpoint format has been deprecated.
WARNING:tensorflow:Consider switching to the more efficient V2 format:
WARNING:tensorflow: tf.train.Saver(write_version=tf.train.SaverDef.V2)
WARNING:tensorflow:now on by default.
WARNING:tensorflow:*******************************************************
Traceback (most recent call last):
File "./tools/test_net.py", line 99, in
Caused by op u'save/Assign_2', defined at:
File "./tools/test_net.py", line 97, in
InvalidArgumentError (see above for traceback): Assign requires shapes of both tensors to match. lhs shape= [3] rhs shape= [21] [[Node: save/Assign_2 = Assign[T=DT_FLOAT, _class=["loc:@cls_score/biases"], use_locking=true, validate_shape=true, _device="/job:localhost/replica:0/task:0/gpu:0"](cls_score/biases, save/RestoreV2_2/_5)]]
it seems classes problem .i change pascal_voc.py,VGGnet_train.py and VGGnet_test.py.what else should i change? @Akansha62
Hi @gentlebreeze1 ,
Please grep any of the 21 classes . And wherever u find them change accordingly
Hi @Akansha62 , i try again,i get different problem.as follow: File "./tools/train_net.py", line 96, in max_iters=args.max_iters) File "/home/c303/student/yongzhang/Faster-RCNN_TF/tools/../lib/fast_rcnn/train.py", line 264, in train_net sw.train_model(sess, max_iters) File "/home/c303/student/yongzhang/Faster-RCNN_TF/tools/../lib/fast_rcnn/train.py", line 198, in train_model self.snapshot(sess, iter) File "/home/c303/student/yongzhang/Faster-RCNN_TF/tools/../lib/fast_rcnn/train.py", line 61, in snapshot sess.run(net.bbox_weights_assign, feed_dict={net.bbox_weights: orig_0 * np.tile(self.bbox_stds, (weights_shape[0], 1))})
ValueError: operands could not be broadcast together with shapes (4096,16) (4096,12)
Hi @gentlebreeze1 ,
I guess still somewhere your number of classes are given wrong, Please check again.
grep -irn <n_classes> *
grep -irn
use dse commands and get the data, and then see somewhere you r missing something
@Akansha62 , maybe i use the trained model that cause the problem .but new problem occurs:
VOC07 metric? Yes
Reading annotation for 1/170
Traceback (most recent call last):
File "./tools/test_net.py", line 97, in
Thank you for your guidance during this time @Akansha62 @Akansha06 .I have been running successfully on my dataset.
Hi @gentlebreeze1,
Congratulations....
Happy Learning :)
What is the meaning of this document in VOC2007\ ImageSets\Layout? should i make the txt files like train.txt,val.txt and trainval.txt? @Akansha62
Hi @gentlebreeze1 ,
Layout is not necessary. It just the replica of your Main folder.
i only need to change Main floder.Train.txt in Main floder includes all classes's ***_trian.txt. @Akansha62
yes @gentlebreeze1
if i want to test my pictures use demo.py.where should i change @Akansha62
Hi @gentlebreeze1 ,
l have the error as follows:
Traceback (most recent call last):
File "/usr/lib/python2.7/pdb.py", line 1314, in main
pdb._runscript(mainpyfile)
File "/usr/lib/python2.7/pdb.py", line 1233, in _runscript
self.run(statement)
File "/usr/lib/python2.7/bdb.py", line 400, in run
exec cmd in globals, locals
File "
/home/tf/Downloads/Faster-RCNN_TF/lib/fast_rcnn/train.py(63)snapshot() -> sess.run(net.bbox_weights_assign, feed_dict={net.bbox_weights: orig_0 * np.tile(self.bbox_stds, (weights_shape[0], 1))})
when i use the command:
grep -irn <n_classes> *
grep -irn *
new problem occurred: "bash: n_classes: No such file or directory"
l have solved the problem, by changing the VGGnet_train.py file as follows: n_classes = 2