mseg-dataset / mseg-semantic

An Official Repo of CVPR '20 "MSeg: A Composite Dataset for Multi-Domain Segmentation"
MIT License
460 stars 78 forks source link

error running demo #17

Closed kkycj closed 3 years ago

kkycj commented 3 years ago

Hi! Thank you for your amazing work! There was some problem when I tried to run the demo program on my own PC as I followed the instruction in README. Here is the error message.

[2020-10-31 19:49:01,033 INFO universal_demo.py line 63 10457] => creating model ... [2020-10-31 19:49:03,787 INFO inference_task.py line 308 10457] => loading checkpoint 'mseg_semantic/model/mseg-1m.pth' [2020-10-31 19:49:04,255 INFO inference_task.py line 314 10457] => loaded checkpoint 'mseg_semantic/model/mseg-1m.pth' [2020-10-31 19:49:04,259 INFO inference_task.py line 327 10457] >>>>>>>>>>>>>> Start inference task >>>>>>>>>>>>> [2020-10-31 19:49:04,262 INFO inference_task.py line 365 10457] Write image prediction to 000000_overlaid_classes.jpg /home/kkycj/.local/lib/python3.6/site-packages/torch/nn/functional.py:3121: UserWarning: Default upsampling behavior when mode=bilinear is changed to align_corners=False since 0.4.0. Please specify align_corners=True if the old behavior is desired. See the documentation of nn.Upsample for details. "See the documentation of nn.Upsample for details.".format(mode)) /home/kkycj/.local/lib/python3.6/site-packages/torch/nn/functional.py:2941: UserWarning: nn.functional.upsample is deprecated. Use nn.functional.interpolate instead. warnings.warn("nn.functional.upsample is deprecated. Use nn.functional.interpolate instead.") Traceback (most recent call last): File "mseg_semantic/tool/universal_demo.py", line 109, in run_universal_demo(args, use_gpu) File "mseg_semantic/tool/universal_demo.py", line 76, in run_universal_demo itask.execute() File "/home/kkycj/workspace/mseg-semantic/mseg_semantic/tool/inference_task.py", line 343, in execute self.render_single_img_pred() File "/home/kkycj/workspace/mseg-semantic/mseg_semantic/tool/inference_task.py", line 379, in render_single_img_pred id_to_class_name_map=self.id_to_class_name_map File "/home/kkycj/workspace/mseg-api/mseg/utils/mask_utils_detectron2.py", line 468, in overlayinstances polygons, = mask_obj.mask_to_polygons(segment) File "/home/kkycj/workspace/mseg-api/mseg/utils/mask_utils_detectron2.py", line 121, in mask_to_polygons res, hierarchy = cv2.findContours(mask.astype("uint8"), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE) ValueError: too many values to unpack (expected 2)

Could you please help me finding out where is the problem? Thank you so much.

johnwlambert commented 3 years ago

Hi @kkycj, it looks like this might be an OpenCV versioning issue. What is your version? In our requirements.txt, we use opencv-python>=4.1.0.25

Are you able to run the Colab demo successfully?

kkycj commented 3 years ago

@johnwlambert, I ran the Colab demo successfully and I noticed I was using opencv-python 3.4.1 for the sake of other projects. Actually, I have solved my problem by changing line 121. in mask_utils_detectron2.py. It seems the cv2.findContours() function in opencv-python 4 has 2 output while in opencv-python 3 it has 3 output. So I added one more variable to save the extra output like this binary, res, hierarchy = cv2.findContours(mask.astype("uint8"), cv2.RETR_CCOMP, cv2.CHAIN_APPROX_NONE)

and it seems to work correctly when I use a single image as the input. Appreciate your help! :)

BTW, if I suppose to use the semantic mask for the removal of moving object, how can I get the purely colourful images just like the ground truth images instead of the overlaid ones?

johnwlambert commented 3 years ago

Hi @kkycj , no problem. Are you referring to the ground truth label maps from our paper, e.g. Figure 1

If so, please use the function we use in this line: https://github.com/mseg-dataset/mseg-api/blob/master/tests/verify_all_dataset_paths_exist.py#L84

kkycj commented 3 years ago

@johnwlambert , Thank you very much!