It seems an error when loading the image with demo/webcam.py. And I don't konw how to fix it.
I use the provided dockerfile and run it on docker. Any suggestions?
Here is the error:
root@effbcd2e465c:/maskrcnn-benchmark/demo# python webcam.py --min-image-size 800
Downloading: "https://s3-us-west-2.amazonaws.com/detectron/35858933/12_2017_baselines/e2e_mask_rcnn_R-50-FPN_1x.yaml.01_48_14.DzEQe4wC/output/train/coco_2014_train%3Acoco_2014_valminusminival/generalized_rcnn/model_final.pkl" to /root/.torch/models/_detectron_35858933_12_2017_baselines_e2e_mask_rcnn_R-50-FPN_1x.yaml.01_48_14.DzEQe4wC_output_train_coco_2014_train%3Acoco_2014_valminusminival_generalized_rcnn_model_final.pkl
100%|#######################################################################################| 362433370/362433370 [05:51<00:00, 1031823.39it/s]
VIDEOIO ERROR: V4L: can't open camera by index 0
Traceback (most recent call last):
File "webcam.py", line 80, in
main()
File "webcam.py", line 71, in main
composite = coco_demo.run_on_opencv_image(img)
File "/maskrcnn-benchmark/demo/predictor.py", line 169, in run_on_opencv_image
predictions = self.compute_prediction(image)
File "/maskrcnn-benchmark/demo/predictor.py", line 193, in compute_prediction
image = self.transforms(original_image)
File "/miniconda/envs/py36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py", line 58, in __call__
File "/miniconda/envs/py36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/transforms.py", line 119, in __call__
File "/miniconda/envs/py36/lib/python3.6/site-packages/torchvision-0.2.1-py3.6.egg/torchvision/transforms/functional.py", line 109, in to_pil_image
TypeError: pic should be Tensor or ndarray. Got
cc @miguelvr
@keineahnung2345 any idea of what this could be? It probably is opencv related
@ocean1211 I think it's saying that you don't have a camera.
One thing I thought was a possibility was that docker was not being able to see their webcam (I don't know if it requires special handling), but if nothing else is needed for a webcam to be seen by docker, then it might be the case that @ocean1211 doesn't have a webcam?
I will try to run the demo on my side, to see if I encounter the same issue
docker indeed needs some special tricks to recognize your webcam... still didn't manage to do it yet, but @ocean1211 can try to investigate how to get docker to recognize your webcam as well in the meantime.
I attached this line to the docker run command and I managed to read from the webcam, but I had to fix the opencv dockerfile installation.
However, I couldn't still get the image to show on my screen from the docker container.
--device=/dev/video0:/dev/video0
EDIT: PR #205 should fix the opencv installation
I managed to get it working.
Refer to here to get the webcam output on your machine.
The process I followed:
xhost +
docker run --rm -it \
-e DISPLAY=${DISPLAY} \
--privileged \
-v /tmp/.X11-unix:/tmp/.X11-unix \
--device=/dev/video0:/dev/video0 \
--ipc=host maskrcnn-benchmark \
python demo/webcam.py \
--min-image-size 300 \
--config-file configs/caffe2/e2e_mask_rcnn_R_101_FPN_1x_caffe2.yaml \
MODEL.DEVICE cpu
@fmassa feel free to close this issue
Thanks a lot for the help @miguelvr !
Maybe you could send a PR improving the README for the Docker installation part with your findings?
Most helpful comment
I managed to get it working.
Refer to here to get the webcam output on your machine.
The process I followed:
@fmassa feel free to close this issue