CharlesShang / TFFRCNN

FastER RCNN built on tensorflow
MIT License
874 stars 418 forks source link

problems when training for my own data #51

Open chakpongchung opened 7 years ago

chakpongchung commented 7 years ago

Hi Charles,

Thank you for sharing your good work.

I am trying to use your repository for training. Here is the test input. Could you also share some test input data as shown below? I am not sure whether we are using the same format for label. The one I am using in label_2 for each image is like the following:

microway:TFFRCNN$ more data/KITTI/training/label_2/0000000000.txt
car -1 -1 3.14 96.00 203.00 125.00 214.00 -1 -1 -1 -1000 -1000 -1000 -10 -0.512473

To reproduce the error, you can run the following code inside your folder:

TFFRCNN=`pwd`
python ./experiments/scripts/kitti2pascalvoc.py \
--kitti $TFFRCNN/data/KITTI --out $TFFRCNN/data/KITTIVOC

python ./faster_rcnn/train_net.py \
--gpu 0 \
--weights ./data/pretrain_model/VGG_imagenet.npy \
--imdb kittivoc_train \
--iters 160000 \
--cfg ./experiments/cfgs/faster_rcnn_kitti.yml \
--network VGGnet_train

then I run into this:

Traceback (most recent call last): 
 File "./faster_rcnn/train_net.py", line 91, in <module> 
   roidb = get_training_roidb(imdb) 
 File "./faster_rcnn/../lib/fast_rcnn/train.py", line 300, in get_training_roidb 
   imdb.append_flipped_images() 
 File "./faster_rcnn/../lib/datasets/imdb.py", line 117, in append_flipped_images 
   boxes = self.roidb[i]['boxes'].copy() 
IndexError: list index out of range

FYI, this is the input and output data before and after running "kitti2pascalvoc.py" Actually I also tried using converter from https://github.com/umautobots/vod-converter.

microway:TFFRCNN$ tree data/KITTI data/KITTI ├── testing │ ├── image_2 │ │ ├── 0000000000.png │ │ ├── 0000000001.png │ │ ├── 0000000002.png │ │ ├── 0000000003.png │ │ ├── 0000000004.png │ │ ├── 0000000005.png │ │ ├── 0000000006.png │ │ ├── 0000000007.png │ │ ├── 0000000008.png │ │ └── 0000000009.png │ └── label_2 │ ├── 0000000000.txt │ ├── 0000000001.txt │ ├── 0000000002.txt │ ├── 0000000003.txt │ ├── 0000000004.txt │ ├── 0000000005.txt │ ├── 0000000006.txt │ ├── 0000000007.txt │ ├── 0000000008.txt │ └── 0000000009.txt ├── training │ ├── image_2 │ │ ├── 0000000000.png │ │ ├── 0000000001.png │ │ ├── 0000000002.png │ │ ├── 0000000003.png │ │ ├── 0000000004.png │ │ ├── 0000000005.png │ │ ├── 0000000006.png │ │ ├── 0000000007.png │ │ ├── 0000000008.png │ │ └── 0000000009.png │ └── label_2 │ ├── 0000000000.txt │ ├── 0000000001.txt │ ├── 0000000002.txt │ ├── 0000000003.txt │ ├── 0000000004.txt │ ├── 0000000005.txt │ ├── 0000000006.txt │ ├── 0000000007.txt │ ├── 0000000008.txt │ └── 0000000009.txt

microway:TFFRCNN$ tree data/KITTIVOC/ data/KITTIVOC/ ├── Annotations │ ├── 0000000000.xml │ ├── 0000000001.xml │ ├── 0000000002.xml │ ├── 0000000003.xml │ ├── 0000000004.xml │ ├── 0000000005.xml │ ├── 0000000006.xml │ ├── 0000000007.xml │ ├── 0000000008.xml │ └── 0000000009.xml ├── ImageSets │ ├── Layout │ ├── Main │ │ ├── car_train.txt │ │ ├── car_trainval.txt │ │ ├── car_val.txt │ │ ├── cyclist_train.txt │ │ ├── cyclist_trainval.txt │ │ ├── cyclist_val.txt │ │ ├── dontcare_train.txt │ │ ├── dontcare_trainval.txt │ │ ├── dontcare_val.txt │ │ ├── pedestrian_train.txt │ │ ├── pedestrian_trainval.txt │ │ ├── pedestrian_val.txt │ │ ├── train.txt │ │ ├── trainval.txt │ │ └── val.txt │ └── Segmentation ├── JPEGImages │ ├── 0000000000.jpg │ ├── 0000000001.jpg │ ├── 0000000002.jpg │ ├── 0000000003.jpg │ ├── 0000000004.jpg │ ├── 0000000005.jpg │ ├── 0000000006.jpg │ ├── 0000000007.jpg │ ├── 0000000008.jpg │ └── 0000000009.jpg ├── SegmentationClass └── SegmentationObject

What could be the problem?

Best, Chak-Pong

xymeow commented 7 years ago

Hi @chakpongchung, I'm using it for training my own data and just faced the same problem before.

I've printed self.roidb and found it was an empty list, the image index was remove by _remove_empty_samples method in class kittivoc(lib/datasets/kittivoc.py). Then I just set all the difficult variable in my annotation xml files to 0 and solve the problem.

Hope this could help you.

chakpongchung commented 7 years ago

@xymeow Thank you! The problem is resolved now.

what I did is to make sure there is 20% margin btw the bounding boxes and the image boundary. I also make sure each annotation file has bounding box in it.

Now I come to another problem:

I want to load the pretrained model except the last layer(s) so that I can reuse the features for my own dataset. Any tutorial found to do this?