Maskrcnn-benchmark: Error after fresh install: Cannot import '_download_url_to_file' from 'torch.utils.model_zoo'

Created on 15 Apr 2019  路  6Comments  路  Source: facebookresearch/maskrcnn-benchmark

馃悰 Bug

To Reproduce

Steps to reproduce the behavior:

  1. Install as per instructions (Ubuntu DSVM)
  2. Attempt to start training

Error

The error is:
ImportError: cannot import name '_download_url_to_file' from 'torch.utils.model_zoo'

Additional context

If I am seeing things clearly, torch.utils.model_zoo no longer contains _download_url_to_file.

Most helpful comment

@my-hello-world as a temp fix, you make these changes to maskrcnn_benchmark/utils/model_zoo.py

All 6 comments

how fix it? please

@my-hello-world as a temp fix, you make these changes to maskrcnn_benchmark/utils/model_zoo.py

thx! i got it 馃槂@JinKsi

Hello,
I am still getting the error in docker image. I update file as proposed temporary fix above but same error shows up. It seems somewhat cached code is run. How can i force it to use normal code instead of cached (well, if that is the case)
thanks in advance

Error lines in docker container:
root@a213ed43e084:/home/retinamask/maskrcnn-benchmark/demo# python3 
Python 3.6.7 |Anaconda, Inc.| (default, Oct 23 2018, 19:16:44) 
[GCC 7.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from predictor import COCODemo
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/retinamask/maskrcnn-benchmark/demo/predictor.py", line 7, in <module>
    from maskrcnn_benchmark.utils.checkpoint import DetectronCheckpointer
  File "/maskrcnn-benchmark/maskrcnn_benchmark/utils/checkpoint.py", line 10, in <module>
    from maskrcnn_benchmark.utils.model_zoo import cache_url
  File "/maskrcnn-benchmark/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'

And the head content of model_zoo.py is as follows ( I commented out torch.utils related lines):

 root@a213ed43e084:/home/retinamask/maskrcnn-benchmark/demo# head -n 20 ../maskrcnn_benchmark/utils/model_zoo.py 
# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
import os
import sys

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


   # from torch.utils.model_zoo import _download_url_to_file
  #  from torch.utils.model_zoo import urlparse
  #  from torch.utils.model_zoo import HASH_REGEX
except:
    from torch.hub import _download_url_to_file
    from torch.hub import urlparse
    from torch.hub import HASH_REGEX

from maskrcnn_benchmark.utils.comm import is_main_process
from maskrcnn_benchmark.utils.comm import synchronize

Was this page helpful?
0 / 5 - 0 ratings