Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Train and Test R-CNN on Another Dataset #21

Open
wants to merge 26 commits into
base: master
Choose a base branch
from

Conversation

zeyuanxy
Copy link

Hi Ross, Fast-RCNN is really fantastic! I am impressed by its great performance and speed, thus I add some other code and two READMEs to help train and test Fast-RCNN on INRIA Person, and it is easy to modify it to train on other datasets, not limiting to PASCAL VOC. It is really a honor for me to help with this, Thanks!

@rbgirshick
Copy link
Owner

Hi @zeyuanxy, I'm curious to know what mAP you get on INRIA?

I won't be able to merge this PR in its current form because it includes the selective search code, which is under a license that does not permit redistribution.

@zeyuanxy
Copy link
Author

Hi @rbgirshick It is about 87.8, a very high number.

@cuatristapr
Copy link

@zeyuanxy Do you have a trained model that I can already use in my project?

@futurely
Copy link

You don't have to stick with the MATLAB implementation of selective search. There's a pure python version.

Usage is a super easy one-liner rects = dlibss.selective_search(img, 50, 200, 3, 20, 50).

@cuatristapr
Copy link

How do I use it futurely? Where do I add that line to point to the python wrapper of Selective Search?

@sunshineatnoon
Copy link

@zeyuanxy Hi~, How did you generate images for the background class? How many images are needed for this class?

@sunshineatnoon
Copy link

@pradeepj247 You don't need to mention which class the image belongs to in the train.txt file, its only the names of the images, if you see classes included in images' names, that's pure coincidence. The annotation files should indicate which class a image belongs to.
For instance, a pascal voc annotation file looks like this:

<object>
        <name>dog</name>
        <pose>Left</pose>
        <truncated>1</truncated>
        <difficult>0</difficult>
        <bndbox>
            <xmin>48</xmin>
            <ymin>240</ymin>
            <xmax>195</xmax>
            <ymax>371</ymax>
        </bndbox>
    </object>

Then the name tag tells you which class this object belongs to.

Yes, you need to mention the full path to the images in factory.py.
All these three files we modified tell fast rcnn how to find data and how to parse the annotation files.

@pradeepj247
Copy link

@sunshineatnoon, just 2 more questions:

I) in your Factory.py, there are 3 for..loops outside the functions, and they contain, the imagenet_devkit_path = '/home/xuetingli/imagenet' and towncenter_devkit_path = '/home/szy/TownCenter' and also inria_devkit_path = '/home/xuetingli/test/INRIA'. This is a bit confusing for me. if you are dealing with only one dataset (i.e imagenet), then only the imagenet should suffice?

  1. after setting up everything as mentioned by you and when I run train, i see this error:
    EnvironmentError: MATLAB command 'matlab' not found. Please add 'matlab' to your PATH.
    do we still need MATLAB? I thought this was a pure Python implementation, especially, if we bring in our own selective search proposals and train.mat

@sunshineatnoon
Copy link

  1. yes, only imagenet loop is needed, you can deleted others. As I mentioned, I referred here for how to modify the code, so I didn't delete what the author wrote initially.
  2. this error is caused by code in lib/datasets/init.py, so just comment it out:
if _which(MATLAB) is None:
    msg = ("MATLAB command '{}' not found. "
           "Please add '{}' to your PATH.").format(MATLAB, MATLAB)
    raise EnvironmentError(msg)'''

@pradeepj247
Copy link

Thanks @sunshineatnoon,

I crossed all those stages - it loaded the dataset, annotations and the caffeNet model required for training.

But just before starting the training, it failed with the following error:
Check failed: error == cudaSuccess (8 vs. 0) invalid device

This seems to be quite a popular error and I read quite a few posts on the forums, but couldn't resolve it.

I am running this on AWS g2.2x and my caffe device_query call works fine.

Any suggestions on how to get past this one?

@KrasusC
Copy link

KrasusC commented Dec 24, 2015

@DaChaoXc I met the problem you mentioned. Have you figured it out?

@leejiajun
Copy link

@DaChaoXc
@KrasusC
@nicci1771
I met the problem you mentioned. Have you figured it out?
"./tools/train_net.py", line 80, in
roidb = get_training_roidb(imdb)
File "/home/xc/fast-rcnn-master/tools/../lib/fast_rcnn/train.py", line 107, in get_training_roidb
imdb.append_flipped_images()
File "/home/xc/fast-rcnn-master/tools/../lib/datasets/imdb.py", line 99, in append_flipped_images
boxes = self.roidb[i]['boxes'].copy()
File "/home/xc/fast-rcnn-master/tools/../lib/datasets/imdb.py", line 63, in roidb
self._roidb = self.roidb_handler()
File "/home/xc/fast-rcnn-master/tools/../lib/datasets/inria.py", line 116, in selective_search_roidb
ss_roidb = self._load_selective_search_roidb(gt_roidb)
File "/home/xc/fast-rcnn-master/tools/../lib/datasets/inria.py", line 138, in _load_selective_search_roidb
return self.create_roidb_from_box_list(box_list, gt_roidb)
File "/home/xc/fast-rcnn-master/tools/../lib/datasets/imdb.py", line 167, in create_roidb_from_box_list
argmaxes = gt_overlaps.argmax(axis=1)
ValueError: attempt to get argmax of an empty sequence

@nwestlake
Copy link

@leejiajun
Try applying the changes proposed here: #102

e.g.
git fetch [email protected]:nw362/fast-rcnn.git negativeImages:negativeImages
git merge negativeImages

(I am interesting in the pull request too, so I might later try merging it with mine.)

@leejiajun
Copy link

@nw362
nice work! I will fetch you code, thank you.

@aragon111
Copy link

Hello,
when I try to train, I get this error

File "/home/attilio/fast-rcnn/tools/../lib/datasets/amph.py", line 190, in get_data_from_tag
return node.getElementsByTagName(tag)[0].childNodes[0].data
IndexError: list index out of range

Would you help to understand how to fix it?
I don't know if it depends on the Annotation file I have or some editing error of python files (I use just one class)

@nwestlake
Copy link

This looks to be code you have written (amph.py)? Hard to say without seeing both the code and the annotation file.

@aragon111
Copy link

I fixed it adding to the .xml files (which I got from Matlab) the fields name and folder.

@MinaRe
Copy link

MinaRe commented Apr 19, 2016

Dear All, (@zeyuanxy )
can you please kindly tell me how can I change batch_size?

@IdiosyncraticDragon
Copy link

Editing the config file FAST-RCNN-ROOT/lib/fast_rcnn/config.py

发自我的 iPhone

在 2016年4月19日,下午5:35,MinaRe [email protected] 写道:

Dear All,
can you please kindly tell me how can I change batch_size?


You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub

@MinaRe
Copy link

MinaRe commented Apr 19, 2016

thanks @IdiosyncraticDragon
Actually my training stop during "Computing bounding-box regression targets..." ,do you have any Idea? is this problem because of memory size? I have 50k images, How much CPU memory do I need for training?

@IdiosyncraticDragon
Copy link

Well, that's because of too much training data. I don't know whether it will be helpful if you have more memory size.

发自我的 iPhone

在 2016年4月19日,下午8:11,MinaRe [email protected] 写道:

thanks @IdiosyncraticDragon
Actually my training stop during "Computing bounding-box regression targets..." ,do you have any Idea? is this problem because of memory size?


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@aragon111
Copy link

Can you tell me why running detection, the frame detect just one item at a time?

@nwestlake
Copy link

One ROI at a time?

@aragon111
Copy link

@nw362 exactly :)

@nwestlake
Copy link

The convolutional layers of the CNN are calculated on the whole image (resized before hand). The final polling layer pools over only the ROI and so the CNN must run the forward steps over these layers for every ROI.

@aragon111
Copy link

In order to detect more ROIs in the same frame there is anything I could do?

@nwestlake
Copy link

It should happen already "lib/fast_rcnn/test.py": _get_blobs will take in one image but multiple ROIs. In im_detect(net, im, boxes), the CNN will be called forward only once for an image and a set of ROIs. Is only one ROI being sent to this method?

@aragon111
Copy link

aragon111 commented Apr 25, 2016

@nw362 I checked and it seems to me that it does not send only one ROI.

@aragon111
Copy link

aragon111 commented May 9, 2016

I have a little doubt. During the labeling of the training set, is it possible to label more items (ROIs) in the same image?

@nwestlake
Copy link

Yes, e.g. the xml format used for annotations.

@aragon111
Copy link

@nw362 Do you mean that is not a problem if there are more bounding boxes for the same .xml file?

@nwestlake
Copy link

No problem at all. This is the case for many data sets.

@aragon111
Copy link

@nw362 I'm not sure about what you mean with many data sets. I have only two classes (background and amphora) and in some image from the data set there are many amphoras.

@mksarker
Copy link

hi all,
I have followed the below web instruction for training my own dataset as INRIA,
https://github.com/zeyuanxy/fast-rcnn/blob/master/help/train/README.md
and found the below problem,
:$ cd fast-rcnn
:
/fast-rcnn$ ./tools/train_net.py --gpu 0 --solver models/pascal_voc/VGG_CNN_M_1024/fast-rcnn/solver.prototxt --weights data/faster_rcnn_models/VGG16_faster_rcnn_final.caffemodel --imdb inria_train
/home/sarker/anaconda2/lib/python2.7/site-packages/matplotlib/font_manager.py:273: UserWarning: Matplotlib is building the font cache using fc-list. This may take a moment.
warnings.warn('Matplotlib is building the font cache using fc-list. This may take a moment.')
Python 2.7.11 |Anaconda custom (64-bit)| (default, Jun 15 2016, 15:21:30)
Type "copyright", "credits" or "license" for more information.

IPython 4.2.0 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object', use 'object??' for extra details.

In [1]:

when I run the training code on terminal the IPython console is open? I don’t know what is the problem? I am a beginner in this area. Please help me.
Thanks in advanced....

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.