rbgirshick / py-faster-rcnn

Faster R-CNN (Python implementation) -- see https://github.com/ShaoqingRen/faster_rcnn for the official MATLAB version
Other
8.11k stars 4.11k forks source link

How to train Faster R-CNN on my own dataset ? #243

Open JohnnyY8 opened 8 years ago

JohnnyY8 commented 8 years ago

Hi everyone: I want to train Faster R-CNN on my own dataset. Because Faster R-CNN does not use selective search method, I comment the code about selective. However, there are still some errors about roidb, and so on. Can anybody help me ? I am not quite sure what should I do for training Faster R-CNN. It is a little complicated for me. Thanks so much!

medhani commented 7 years ago

Do you have any solutions for this error? Traceback (most recent call last): File "/usr/lib/python2.7/multiprocessing/process.py", line 258, in _bootstrap self.run() File "/usr/lib/python2.7/multiprocessing/process.py", line 114, in run self._target(*self._args, **self._kwargs) File "tools/train_faster_rcnn_alt_opt.py", line 129, in train_rpn max_iters=max_iters) File "/home/medhani/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 160, in train_net model_paths = sw.train_model(max_iters) File "/home/medhani/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 101, in train_model self.solver.step(1) File "/home/medhani/py-faster-rcnn/tools/../lib/roi_data_layer/layer.py", line 144, in forward blobs = self._get_next_minibatch() File "/home/medhani/py-faster-rcnn/tools/../lib/roi_data_layer/layer.py", line 63, in _get_next_minibatch return get_minibatch(minibatch_db, self._num_classes) File "/home/medhani/py-faster-rcnn/tools/../lib/roi_data_layer/minibatch.py", line 27, in get_minibatch assert(cfg.TRAIN.BATCH_SIZE % num_images == 0), \ ZeroDivisionError: integer division or modulo by zero

Thanks

Seanmatthews commented 7 years ago

@medhani It's not finding any images, which means either the path to your images is wrong, or there are no images listed in your image set text file.

medhani commented 7 years ago

Thank Sean,I feel like there is a problem with my annotation file. screenshot from 2017-06-16 15 47 12

I'm training my network for spider detection. Annotations files are in .xml format. Is it the correct structure of the .xml file?

medhani commented 7 years ago

@Roskgp96 Have you able find a solution for the below error? line 27, in get_minibatch assert(cfg.TRAIN.BATCH_SIZE % num_images == 0), ZeroDivisionError: integer division or modulo by zero

ivalab commented 7 years ago

I used another modification of fasterrcnn in TF and it saves permutation into snapshots. In my case, I actually traced the code and found out that I was using an OLD permutation loaded with my snapshot. That means, if you modified the number of testing or training data, it is possible you would access outside the permutation array and return zero index, and then load nothing from roidb. A simply solution is to delete all snapshots or modify the permutation in your train_val.py after loaded. Hope it helps.

jzyztzn commented 7 years ago

@ivalab Thanks, when I delete all the .pyc files in the path "$FRCN/lib/",it can train well without the ZeroDivisionError. @medhani Have you solve the problem? You could also try this method。

madhu-kt commented 7 years ago

@deboc Apologies for digging up an old discussion topic, but you mentioned that we have the option to reuse a pre-trained model that already classifies our objects OR train our own model from scratch. Would that put any restrictions on how we train our faster R-CNN? Would the joint approximation (end-2-end) approach be better than the alternate training method?

fireden commented 6 years ago

Hi, I'm trying to train the net on my own dataset I have created, using video with microphone. It seems that I did everything as ednrab29 wrote (started from the model I've got from training VOC2007), but results a really surprising:

  1. Testing a picture from my dataset gives me porper region and class=microphone (the only class (+backround) I left during training) with 1.0 probability
  2. Testing a picture not from my dataset gives me nothing. That's can be explained I think by that my dataset is good enough and too small (hundreds of pics of one mic).
  3. What's really surprized me that any picture from voc dataset gives me bounding boxes of objects in voc dataset with microphone label and lesser probability. What have I done wrong?
mantou22 commented 6 years ago

Excuse me.When I trained my own model, I used the model I trained to run demo.py to detect the graph. When the pixel was large (5000,3000), the results were all white include image.If the image pixel is not too large, there is no problem.What's the reason?(当我训练好自己的模型时,用自己训练的模型运行demo.py,去检测图形,当检测图片像素很大时(5000,3000),检测出来的结果是全白包括图片。如果图片像素不是太大,就不会出问题。请问这是什么原因?)

JohnnyY8 commented 6 years ago

@mantou22 sorry, I do not understand "the results were all white"?

tjzjp commented 6 years ago

I"m using INRIA Person data set. After running below command

./tools/train_faster_rcnn_alt_opt.py --gpu 0 --net_name INRIA_Person --weights data/imagenet_models/VGG_CNN_M_1024.v2.caffemodel --imdb inria_train --cfg config.yml

I got a error File "./tools/train_faster_rcnn_alt_opt.py", line 62 print 'Loaded dataset {:s} for training'.format(imdb.name) ^ SyntaxError: invalid syntax

Can you please let me know reason behind this error

have you fixed it? I met the same problem

frk1993 commented 5 years ago

I"m using INRIA Person data set. After running below command ./tools/train_faster_rcnn_alt_opt.py --gpu 0 --net_name INRIA_Person --weights data/imagenet_models/VGG_CNN_M_1024.v2.caffemodel --imdb inria_train --cfg config.yml I got a error File "./tools/train_faster_rcnn_alt_opt.py", line 62 print 'Loaded dataset {:s} for training'.format(imdb.name) ^ SyntaxError: invalid syntax Can you please let me know reason behind this error

have you fixed it? I met the same problem

Hey, I have the same problem. Have you fixed it?