编译maskscoring_rcnn、Maskrcnn-benchmark出现ImportError: cannot import name '_download_url_to_file'问题解决方法

问题描述

编译报错如下:

 File "tools/test_net.py", line 14, in <module>
    from maskrcnn_benchmark.utils.checkpoint import DetectronCheckpointer
  File "d:\anaconda_env_workspace\maskscoring_rcnn\maskrcnn_benchmark\utils\checkpoint.py", line 10, in <module>
    from maskrcnn_benchmark.utils.model_zoo import cache_url
  File "d:\anaconda_env_workspace\maskscoring_rcnn\maskrcnn_benchmark\utils\model_zoo.py", line 5, in <module>
    from torch.utils.model_zoo import _download_url_to_file
ImportError: cannot import name '_download_url_to_file'

解决办法

修改 maskscoring_rcnn/maskrcnn_benchmark/utils/model_zool.py文件里的导入包为

from torch.hub import _download_url_to_file
from torch.hub import urlparse
from torch.hub import HASH_REGEX

即可解决

填坑不易,且行且珍惜

发布了44 篇原创文章 · 获赞 97 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/weixin_44573410/article/details/104313436