msracver / Relation-Networks-for-Object-Detection

Relation Networks for Object Detection
MIT License
1.09k stars 190 forks source link

fix: import error for pycocotools._mask #3

Closed jqcai closed 6 years ago

jqcai commented 6 years ago

fix import error when inport _mask in Desktop/Relation-Networks-for-Object-Detection/lib/dataset/pycocotools/mask.py

chengdazhi commented 6 years ago

Hi, what error did you encounter before you modified this import clause?

jqcai commented 6 years ago

Hi, I got this error

Traceback (most recent call last):
  File "experiments/relation_rcnn/rcnn_test.py", line 17, in <module>
    import test
  File "experiments/relation_rcnn/../../relation_rcnn/test.py", line 63, in <module>
    from function.test_rcnn import test_rcnn
  File "experiments/relation_rcnn/../../relation_rcnn/function/test_rcnn.py", line 23, in <module>
    from dataset import *
  File "experiments/relation_rcnn/../../relation_rcnn/../lib/dataset/__init__.py", line 2, in <module>
    from coco import coco
  File "experiments/relation_rcnn/../../relation_rcnn/../lib/dataset/coco.py", line 24, in <module>
    from .pycocotools.coco import COCO
  File "experiments/relation_rcnn/../../relation_rcnn/../lib/dataset/pycocotools/coco.py", line 58, in <module>
    import mask
  File "experiments/relation_rcnn/../../relation_rcnn/../lib/dataset/pycocotools/mask.py", line 3, in <module>
    import _mask as _mask
ImportError: No module named _mask
chengdazhi commented 6 years ago

Which python version are you using?

cclauss commented 6 years ago

This sounds like an absolute vs. relative imports thing in which case Python 3 will be more touchy than Python 2. However, it might also be about wether _mask_ has already been imported by some previous file (i.e. mask in globals() is True__). In any case, the zen of Python says that explicit is better that implicit so I approve of this change.

chengdazhi commented 6 years ago

@cclauss Thanks for your comment, it is very helpful. @jqcai Because I cannot reproduce your error, this PR can't be merged right now. Glad to see you figure out a solution. If I see other questions raised regarding this very error, I will put it under FAQ section or merge this PR. Thanks for your effort.