rbgirshick/rcnn

Problems training on my own dataset

siliconvalleypilot opened this issue · 21 comments

Hi everyone,

I installed RCNN and ran all demos on PASCAL VOC 07 without any error, so I proceed to train and test on my own dataset. I have images, classes and complete bounding box coordinates. Instead of defining my own imdb_from_voc, roidb_from_voc and imdb_eval_voc functions, I reformatted my dataset to be compatible with PASCAL VOC. I generated my own annotation xml files, train/val/test txt files and extracted features using rcnn_exp_cache_features(train/val/test) without any problem. However, when I run rcnn_exp_train_and_test(), it shows:

XXX class has 0 positive instances
cache hold 0 pos example and 2443 neg examples

Where did I go wrong? I hope somebody can share an working example on a new dataset or help me figure out this problem so I can share the code to reformat general bounding box annotations into PASCAL VOC format, and make it easier for those who want to use RCNN on their own dataset/research work.

I noticed similar issues as follows:
#34
#23
#17
#14

Thank you!

are you a chinese?can you add my QQ number 821628393?

can you tell me how can you get the complete bounding box coordinates?can you share the code to reformat general bounding box annotations into PASCAL VOC format???

tgels commented

Do we need to segment the images ? The segmented images are in the Segmentation folder. I am not sure how they were done for the VOC 07 dataset. Here is an example:

rcnn-segment-2
rcnn-segment-1

You don't need segmentation. RCNN is for detection not segmentation.

can you share the code to reformat general bounding box annotations into PASCAL VOC format??

tgels commented

you can write a simple perl script to generate the annotation tags.

tgels commented

@qiaosongwang : did you generate a new selective_search model data ?. I get the below error when I remove the old VOC 2007 model data under data/selective_search_data ( script does not seem to create it )::

Error using load
Unable to read file './data/selective_search_data/voc_2007_train':
no such file or directory.

BTW, should this be used as it is ? My image files are smaller than the VOC 2007 image files and I get the below error ( and the reason is selective_search seems to generate boxes greater than what is specified in my annotations file and bigger than my image size )

Error using imresize>parsePreMethodArgs (line 333)
Expected input number 1, A, to be nonempty.

Error in imresize>parseInputs (line 248)
[params.A, params.map, params.scale, params.output_size] = ...

tgels commented

@qiaosongwang: I have the same error as you now, 0 positive instances and then I get this exceptions:

Error using *
Inner matrix dimensions must agree.

Error in rcnn_pool5_to_fcX (line 21)
feat = max(0, bsxfun(@plus,
feat*rcnn_model.cnn.layers(i).weights{1}, ...

Error in rcnn_train (line 102)
X_pos{i} = rcnn_pool5_to_fcX(X_pos{i}, opts.layer, rcnn_model);

Error in rcnn_exp_train_and_test (line 19)
[rcnn_model, rcnn_k_fold_model] = ...

But I don't have this message:
cache hold 0 pos example and 2443 neg examples

The imbd/cache/ seems to be populated with model files.

tgels commented

@qiaosongwang : did you check the tags in the annotation xml files ? I found a problem with one of the tags and it was not reading the annotation files (throwing an exception). Have restarted the training ? Will update if it finds the boxes and positive instances ...

I generated Pascal-style XML files for my own training data. I found out that the Pascal XML parser likes tabs and not spaces. (Initially, the parser found no bboxes... then when I converted spaces to tabs, it all worked properly.)

I generated my own selective search data and I used xml2struct and struct2xml (from matlab central) to generate my own xml files. I think for some reason, the original xml reader from PASCAL VOC toolkit has problems parsing xml files.

tgels commented

@qiaosongwang : How did you generate your own selective search data ? I did not find any instructions on training with a custom data set.

But I was able to train rcnn and selective search using VOC 2007 templates with my own / custom images (just 2 classes to keep it simple), but when I run a test using rcnn_demo, it seems to select / box the entire image instead of finding the ROI of the interested class of object. I am not sure if it is related to my training examples or due to selective search boxes having been trained on VOC 2007 data set. Did you or anyone see similar results ?

@tgels Yes I generated my own selective search data, it's pretty straightforward, just save selective search coordinates to the varable boxes:

for i=1:num_images
im_name=sprintf('./datasets/VOCdevkit2007/VOC2007/JPEGImages/%06d.jpg',i)
im=imread(im_name);
box_coord = selective_search_boxes(im, fast_mode, im_width);
end

boxes=cell(1,num_images);
for i=1:num_images
boxes{1,i}=box_coord;
end

It does not make any sense to run your own dataset with VOC 2007 selective search boxes. The images are different, how can you reuse the bounding boxes?

tgels commented

Thank you @qiaosongwang. Will take a look at the selective search boxes. I was able to use the VOC 2007 boxes though and get about 68% accuracy. Not bad. But with selective_search tuned for a particular dataset, I may be able to get better accuracy.

@qiaosongwang
I use selective_search_boxes to produce region proposals of /fast-rcnn/data/demo/000004.jpg, but the result seems very different with Ross Girshick provided in /fast-rcnn/data/demo/000004_boxes.mat. I wonder if the 000004_boxes.mat is produced by selective_search or there is something I miss.
Thanks for your help.

@wuxinhong can you solve your problem, I have same problem.

@forresti can you help me to generate PASCAL-style xml from my annotation file? thanks

@tgels hello i wonder if you could solve the problem about the error using imresize i have the same problem . i wonder if you can tell me how could you solve the problem thank you.

Error using imresize>parsePreMethodArgs (line 333)
Expected input number 1, A, to be nonempty.

Error in imresize>parseInputs (line 248)
[params.A, params.map, params.scale, params.output_size] = ...

@forresti @niloo-sh
What tool have you used to make Pascal Voc xml annotations?

We wrote our own. I can't remember if we used pyXML or if we just printf'd the XML.

@forresti
Actually I solved the issue by using a different software named LabelImg