Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

error when running with --show-mask-heatmaps #266

Closed
ywlng opened this issue Dec 12, 2018 · 4 comments · Fixed by #274
Closed

error when running with --show-mask-heatmaps #266

ywlng opened this issue Dec 12, 2018 · 4 comments · Fixed by #274
Labels

Comments

@ywlng
Copy link
Contributor

ywlng commented Dec 12, 2018

I have no problem when running demo without --show-mask-heatmaps. But error occurs when adding the parameter --show-mask-heatmaps. The output log is as follow:

Traceback (most recent call last):
  File "webcam.py", line 80, in <module>
    main()
  File "webcam.py", line 71, in main
    composite = coco_demo.run_on_opencv_image(img)
  File "/home/ywl/dl/maskrcnn-benchmark/demo/predictor.py", line 175, in run_on_opencv_image
    return self.create_mask_montage(result, top_predictions)
  File "/home/ywl/dl/maskrcnn-benchmark/demo/predictor.py", line 311, in create_mask_montage
    masks.float(), scale_factor=1 / masks_per_dim
  File "/home/ywl/.virtualenvs/pymask/lib/python3.5/site-packages/torch/nn/functional.py", line 2437, in interpolate
    return torch._C._nn.upsample_nearest2d(input, _output_size(2))
RuntimeError: invalid argument 2: 4D input tensor expected but got: [0 x 1 x 480 x 640] at /pytorch/aten/src/THNN/generic/SpatialUpSamplingNearest.c:19

My enviroment is pytorch preview, python 3.5 and CUDA 9.0. Looking forward to your apply.

@ywlng ywlng changed the title error when running error when running with --show-mask-heatmaps Dec 12, 2018
@fmassa
Copy link
Contributor

fmassa commented Dec 12, 2018

Thanks for opening the issue!

The problem happens in this line because there were no predictions in your case.

In order to fix this, can you replace

masks = torch.nn.functional.interpolate(

with

from maskrcnn_benchmark import layers as L
masks = L.interpolate(

and report back?

If this works for you, would you mind sending a PR?

Thanks!

@fmassa fmassa added enhancement New feature or request contributions welcome labels Dec 12, 2018
@ywlng
Copy link
Contributor Author

ywlng commented Dec 12, 2018

Thanks very much. That works for me.

@fmassa
Copy link
Contributor

fmassa commented Dec 12, 2018

Great, can you send a PR with this fix? it would be greatly appreciated!

@ywlng
Copy link
Contributor Author

ywlng commented Dec 14, 2018

I have sent a PR. Thanks

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

Successfully merging a pull request may close this issue.

2 participants