py-faster-rcnn icon indicating copy to clipboard operation
py-faster-rcnn copied to clipboard

AssetionError: training py-faster-rcnn with one class

Open yawadugyamfi opened this issue 8 years ago • 17 comments

I am using py-faster-rcnn to train the 2007 VOC dataset. When I run on the original 21 classes, it works fine, but when I change the original number of classes, I get an error.. I am doing this for 1 class ('person'). I made the following changes to the original codes:

  1. file: fcn_root/models/VGG16/faster_rcnn_alt_opt.pt layer { name: "cls_score" type: "InnerProduct" bottom: "fc7" top: "cls_score" inner_product_param { num_output: 2 } }

    layer { name: "bbox_pred" type: "InnerProduct" bottom: "fc7" top: "bbox_pred" inner_product_param { num_output: 8 } }

  2. file2: fcn_root/lib/datasets/pascal_voc.py

    line 28:self._classes = ('background', # always index 0 'person')

    removed -1's from the lines below

         x1 = float(get_data_from_tag(obj, 'xmin'))
          y1 = float(get_data_from_tag(obj, 'ymin'))
          x2 = float(get_data_from_tag(obj, 'xmax')) 
          y2 = float(get_data_from_tag(obj, 'ymax'))
    
  3. file3: ../VOCdevkit/VOCcode/VOCinit.m

VOCopts.classes={... 'person'};

I get the following error after I run this command,

./experiments/scripts/faster_rcnn_alt_opt.sh 3 VGG16 \ --set EXP_DIR foobarx

I have also attached a full trace of my program running. Error: Process Process-1: 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 123, in train_rpn roidb, imdb = get_roidb(imdb_name) File "./tools/train_faster_rcnn_alt_opt.py", line 68, in get_roidb roidb = get_training_roidb(imdb) File "/home/microway/test/pytest/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 121, in get_training_roidb imdb.append_flipped_images() File "/home/microway/test/pytest/py-faster-rcnn/tools/../lib/datasets/imdb.py", line 108, in append_flipped_images assert (boxes[:, 2] >= boxes[:, 0]).all() AssertionError

error_attachment.txt

yawadugyamfi avatar Dec 04 '15 15:12 yawadugyamfi

Hi, I have also encountered this error. Seems like something is wrong in at least one of the annotations, an artificial solution is the following: in imdb.py

for b in range(len(boxes)):     
                if boxes[b][2] < boxes[b][0]:
                   boxes[b][0] = 0

assert (boxes[:, 2] >= boxes[:, 0]).all()

Hope this helps!

marphil avatar Dec 07 '15 21:12 marphil

@marphil I get the following error: Process Process-1: 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 122, in train_rpn roidb, imdb = get_roidb(imdb_name) File "./tools/train_faster_rcnn_alt_opt.py", line 67, in get_roidb roidb = get_training_roidb(imdb) File "/media/dl/c0d34b51-8a78-4364-bc19-35003bf01885/RCNN/py-faster-rcnn/tools/../lib/fast_rcnn/train.py", line 118, in get_training_roidb imdb.append_flipped_images() File "/media/dl/c0d34b51-8a78-4364-bc19-35003bf01885/RCNN/py-faster-rcnn/tools/../lib/datasets/imdb.py", line 106, in append_flipped_images boxes = self.roidb[i]['boxes'].copy() File "/media/dl/c0d34b51-8a78-4364-bc19-35003bf01885/RCNN/py-faster-rcnn/tools/../lib/datasets/imdb.py", line 67, in roidb self._roidb = self.roidb_handler() File "/media/dl/c0d34b51-8a78-4364-bc19-35003bf01885/RCNN/py-faster-rcnn/tools/../lib/datasets/pascal_voc.py", line 103, in gt_roidb for index in self.image_index] File "/media/dl/c0d34b51-8a78-4364-bc19-35003bf01885/RCNN/py-faster-rcnn/tools/../lib/datasets/pascal_voc.py", line 204, in _load_pascal_annotation x1 = float(bbox.find('xmin').text) ValueError: invalid literal for float(): 737,

moyans avatar Mar 23 '16 08:03 moyans

Hello yawadugyamfi, did you find a solution to your error? Would you share it with us please?

Never mind, I found the answer. There should be no <ymin>0</ymin> nor <xmin>0</xmin> in an object.

I changed that in the Annotations folder with the two commands (./ means the current folder is Annotations): grep -rl '<ymin>0</ymin>' ./ | xargs sed -i 's#<ymin>0</ymin>#<ymin>1</ymin>#g' and grep -rl '<xmin>0</xmin>' ./ | xargs sed -i 's#<xmin>0</xmin>#<xmin>1</xmin>#g'

Now training is running smoothly. .

DiegoPortoJaccottet avatar May 07 '16 05:05 DiegoPortoJaccottet

@marphil in which function you wrote those lines?

aragon111 avatar May 19 '16 07:05 aragon111

@DiegoPortoJaccottet I got sed: no input files

aragon111 avatar May 19 '16 07:05 aragon111

@marphil that worked for me!.

alviur avatar May 30 '16 01:05 alviur

@DiegoPortoJaccottet your fix worked for me, thanks! The @marphil fix produces the same assertion error in my case.

CWOA avatar Jun 01 '16 10:06 CWOA

@DiegoPortoJaccottet Even i got sed : no input files. I have my annotation files in that folder ( *.xml)

harora avatar Aug 24 '16 13:08 harora

@harora You got 'sed: no input files' from the commands I described or from Faster-RCNN?

DiegoPortoJaccottet avatar Aug 24 '16 14:08 DiegoPortoJaccottet

@moyans I get the same error with you.

y2= float(bbox.find('ymax').text) ValueError: invalid literal for float(): 196006001002176.jpg

Have you found any solution to it? Thank you

XiangyuChu avatar May 05 '17 01:05 XiangyuChu

you need check this img and label.

来自 魅族 MX5

-------- 原始邮件 -------- 发件人:Xiang [email protected] 时间:周五 5月5日 09:52 收件人:rbgirshick/py-faster-rcnn [email protected] 抄送:moyans [email protected],Mention [email protected] 主题:Re: [rbgirshick/py-faster-rcnn] AssetionError: training py-faster-rcnn with one class (#34)

@moyans I get the same error with you.

y2= float(bbox.find('ymax').text) ValueError: invalid literal for float(): 196006001002176.jpg

Do you find any solution to it? Thank you

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/rbgirshick/py-faster-rcnn","title":"rbgirshick/py-faster-rcnn","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/rbgirshick/py-faster-rcnn"}},"updates":{"snippets":[{"icon":"PERSON","message":"@XiangyuChu in #34: @moyans I get the same error with you. \r\n\r\ny2= float(bbox.find('ymax').text)\r\nValueError: invalid literal for float(): 196006001002176.jpg\r\n\r\nDo you find any solution to it? Thank you "}],"action":{"name":"View Issue","url":"https://github.com/rbgirshick/py-faster-rcnn/issues/34#issuecomment-299353335"}}}

moyans avatar May 05 '17 02:05 moyans

@moyans 196006001002176.jpg is very odd. My images are usually "000000.jpg", same as VOC2007. And I have removed "-1" from the lines below x1 = float(bbox.find( 'xmin').text) y1 = float(bbox.find('ymin').text) x2 = float(bbox.find('xmax').text) y2 = float(bbox.find('ymax').text)

XiangyuChu avatar May 05 '17 02:05 XiangyuChu

check the label out of range?

来自 魅族 MX5

-------- 原始邮件 -------- 发件人:Xiang [email protected] 时间:周五 5月5日 10:32 收件人:rbgirshick/py-faster-rcnn [email protected] 抄送:moyans [email protected],Mention [email protected] 主题:Re: [rbgirshick/py-faster-rcnn] AssetionError: training py-faster-rcnn with one class (#34)

@moyans 196006001002176.jpg is very odd. My images are usually "000000.jpg", same as VOC2007. And I have removed "-1" from the lines below x1 = float(get_data_from_tag(obj, 'xmin')) y1 = float(get_data_from_tag(obj, 'ymin')) x2 = float(get_data_from_tag(obj, 'xmax')) y2 = float(get_data_from_tag(obj, 'ymax'))

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/rbgirshick/py-faster-rcnn","title":"rbgirshick/py-faster-rcnn","subtitle":"GitHub repository","main_image_url":"https://cloud.githubusercontent.com/assets/143418/17495839/a5054eac-5d88-11e6-95fc-7290892c7bb5.png","avatar_image_url":"https://cloud.githubusercontent.com/assets/143418/15842166/7c72db34-2c0b-11e6-9aed-b52498112777.png","action":{"name":"Open in GitHub","url":"https://github.com/rbgirshick/py-faster-rcnn"}},"updates":{"snippets":[{"icon":"PERSON","message":"@XiangyuChu in #34: @moyans 196006001002176.jpg is very odd. My images are usually "000000.jpg", same as VOC2007. \r\nAnd I have removed "-1" from the lines below\r\n x1 = float(get_data_from_tag(obj, 'xmin'))\r\n y1 = float(get_data_from_tag(obj, 'ymin'))\r\n x2 = float(get_data_from_tag(obj, 'xmax')) \r\n y2 = float(get_data_from_tag(obj, 'ymax'))"}],"action":{"name":"View Issue","url":"https://github.com/rbgirshick/py-faster-rcnn/issues/34#issuecomment-299357112"}}}

moyans avatar May 05 '17 03:05 moyans

in the Annotation folder I run grep -rl '<ymin>0</ymin>' ./ | xargs sed -i 's#<ymin>0</ymin>#<ymin>1</ymin>#g' I got: sed : no input files just like @harora . I want to know why. @DiegoPortoJaccottet

firestonelib avatar May 05 '17 06:05 firestonelib

@moyans Thanks for your help. I have solved the error. I found an error in "output.txt", i.e. 002175.jpg c 669 155 769 **196006001002176.jpg p 207 188 229 257. What puzzles me is that I cannot find error in .xml. Anyway, it is solved. Thank you again!

XiangyuChu avatar May 05 '17 08:05 XiangyuChu

I replaced xmin 0 and ymin 0 with xmin 1 and ymin 1, all things resolved!

see more https://github.com/rbgirshick/py-faster-rcnn/issues/34

iamlxb3 avatar Aug 08 '18 04:08 iamlxb3

in the Annotation folder I run grep -rl '<ymin>0</ymin>' ./ | xargs sed -i 's#<ymin>0</ymin>#<ymin>1</ymin>#g' I got: sed : no input files just like @harora . I want to know why. @DiegoPortoJaccottet

replace 0 with 0.0

ankitcsr avatar Sep 23 '19 11:09 ankitcsr