question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

pytorch 1.0 version - error on custom COCO dataset

See original GitHub issue

running a custom dataset, seeing the following

Appending horizontally-flipped training examples...
coco_try_20190419_train gt roidb loaded from /media/latest_mount/Dev/git/EMCP/faster-rcnn.pytorch/data/cache/coco_try_20190419_train_gt_roidb.pkl
done
Preparing training data...
Backend TkAgg is interactive backend. Turning interactive mode on.
done
loading annotations into memory.../media/latest_mount/Dev/git/EMCP/faster-rcnn.pytorch/data/coco_try_20190419/annotations/instances_train_20190419.json at 1556370591.791137
Done (t=0.00s)
creating index...
index created!
before filtering, there are 254 images...
after filtering, there are 254 images...
254 roidb entries
Loading pretrained weights from data/pretrained_model/resnet101_caffe.pth
Traceback (most recent call last):
  File "/home/emcp/Tools/pycharm-community-2018.2.4/helpers/pydev/pydevd.py", line 1741, in <module>
    main()
  File "/home/emcp/Tools/pycharm-community-2018.2.4/helpers/pydev/pydevd.py", line 1735, in main
    globals = debugger.run(setup['file'], None, None, is_module)
  File "/home/emcp/Tools/pycharm-community-2018.2.4/helpers/pydev/pydevd.py", line 1135, in run
    pydev_imports.execfile(file, globals, locals)  # execute the script
  File "/home/emcp/Tools/pycharm-community-2018.2.4/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile
    exec(compile(contents+"\n", file, 'exec'), glob, loc)
  File "/media/latest_mount/Dev/git/EMCP/faster-rcnn.pytorch/trainval_net.py", line 322, in <module>
    data = next(data_iter)
  File "/home/emcp/anaconda3/envs/pytorch1_py36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 615, in __next__
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/home/emcp/anaconda3/envs/pytorch1_py36/lib/python3.6/site-packages/torch/utils/data/dataloader.py", line 615, in <listcomp>
    batch = self.collate_fn([self.dataset[i] for i in indices])
  File "/media/latest_mount/Dev/git/EMCP/faster-rcnn.pytorch/lib/roi_data_layer/roibatchLoader.py", line 67, in __getitem__
    blobs = get_minibatch(minibatch_db, self._num_classes)
  File "/media/latest_mount/Dev/git/EMCP/faster-rcnn.pytorch/lib/roi_data_layer/minibatch.py", line 30, in get_minibatch
    im_blob, im_scales = _get_image_blob(roidb, random_scale_inds)
  File "/media/latest_mount/Dev/git/EMCP/faster-rcnn.pytorch/lib/roi_data_layer/minibatch.py", line 79, in _get_image_blob
    cfg.TRAIN.MAX_SIZE)
  File "/media/latest_mount/Dev/git/EMCP/faster-rcnn.pytorch/lib/model/utils/blob.py", line 39, in prep_im_for_blob
    im -= pixel_means
ValueError: operands could not be broadcast together with shapes (1880,2880,4) (1,1,3) (1880,2880,4) 

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:13 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
EMCPcommented, May 25, 2019

you have to change it in two places… once in the training python file, and one in the demo…

if you detect 4 channels, and you’re sure that the alpha channel is unused, go ahead and transform the image using python… to only 3 channels

https://github.com/jwyang/faster-rcnn.pytorch/blob/master/demo.py#L115-L118

  im_orig = im.astype(np.float32, copy=True)
  if im_orig.shape[2] == 4:
      # in the event you have an image with alpha channels, drop it for now
      im_orig = im_orig[:, :, :3]
  im_orig -= cfg.PIXEL_MEANS	  im_orig -= cfg.PIXEL_MEANS


0reactions
miaozhang0525commented, Aug 5, 2020

Using custom coco dataset, errors happend

after filtering, there are 0 images...
0 roidb entries
Loading pretrained weights from data/pretrained_model/resnet101_caffe.pth
Traceback (most recent call last):
  File "trainval_net.py", line 373, in <module>
    save_name = os.path.join(output_dir, 'faster_rcnn_{}_{}_{}.pth'.format(args.session, epoch, step))
NameError: name 'step' is not defined

could you drop your custom data here code because you have to modify

Have you guys solved it??

Read more comments on GitHub >

github_iconTop Results From Across the Web

COCO evaluation can fail for custom datasets which ... - GitHub
The COCO evaluation pipeline in references/detection (also used in the object detection finetuning tutorial here) can fail if the custom dataset ...
Read more >
Train an Object Detector with your own 'COCO' dataset in ...
Hi Guys, I am pretty new using PyTorch, I have successfully trained ... to train on my custom dataset (coco format) i got...
Read more >
Pytorch Faster R-CNN size mismatch errors in testing
When running test_net.py in pytorch1.0 Faster R-CNN and demo.py on coco dataset with faster_rcnn_1_10_9771.pth(the pretrained resnet101 ...
Read more >
How to work with object detection datasets in COCO format
Due to the popularity of the dataset, the format that COCO uses to store annotations is often the go-to format when creating a...
Read more >
Tutorial 2: Customize Datasets - MMDetection's documentation!
In MMDetection, we recommend to convert the data into COCO formats and do the conversion offline, thus you only need to modify the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found