Skip to content
This repository has been archived by the owner on Oct 31, 2023. It is now read-only.

default branch name breaking torch.hub #19

Closed
kmatzen opened this issue Oct 13, 2021 · 1 comment
Closed

default branch name breaking torch.hub #19

kmatzen opened this issue Oct 13, 2021 · 1 comment

Comments

@kmatzen
Copy link

kmatzen commented Oct 13, 2021

Was the default branch recently renamed from master to main? This seems to break torch.hub loading unless you have a very recent build of pytorch installed. e.g., If you're on 1.9.1 Stable or 1.8.2 LTS and attempt to load a model such as MiDaS, it reports the following:

    self.netNetwork = torch.hub.load('intel-isl/MiDaS', 'MiDaS')
  File "/<removed>/lib/python3.8/site-packages/torch/hub.py", line 382, in load
    model = _load_local(repo_or_dir, model, *args, **kwargs)
  File "/<removed>/lib/python3.8/site-packages/torch/hub.py", line 411, in _load_local
    model = entry(*args, **kwargs)
  File "/<removed>/.cache/torch/hub/intel-isl_MiDaS_master/hubconf.py", line 61, in MiDaS
    model = MidasNet()
  File "/<removed>/.cache/torch/hub/intel-isl_MiDaS_master/midas/midas_net.py", line 30, in __init__
    self.pretrained, self.scratch = _make_encoder(backbone="resnext101_wsl", features=features, use_pretrained=use_pretrained)                       
  File "/<removed>/.cache/torch/hub/intel-isl_MiDaS_master/midas/blocks.py", line 37, in _make_encoder
    pretrained = _make_pretrained_resnext101_wsl(use_pretrained)
  File "/<removed>/.cache/torch/hub/intel-isl_MiDaS_master/midas/blocks.py", line 115, in _make_pretrained_resnext101_wsl                             
     resnet = torch.hub.load("facebookresearch/WSL-Images", "resnext101_32x8d_wsl")
  File "/<removed>/lib/python3.8/site-packages/torch/hub.py", line 380, in load
    repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, verbose, skip_validation)
  File "/<removed>/lib/python3.8/site-packages/torch/hub.py", line 173, in _get_cache_or_reload
    _validate_not_a_forked_repo(repo_owner, repo_name, branch)
  File "/<removed>/lib/python3.8/site-packages/torch/hub.py", line 143, in _validate_not_a_forked_repo
    raise ValueError(f'Cannot find {branch} in https://github.com/{repo_owner}/{repo_name}. '
ValueError: Cannot find master in https://github.com/facebookresearch/WSL-Images. If it's a commit from a forked repo, please call hub.load() with f
orked repo directly.

Would it make sense to postpone renaming until after at least Stable has rolled out the required changes?

Here's some background on the issue.
pytorch/pytorch#63753

@abhiskk
Copy link

abhiskk commented Oct 14, 2021

Hi @kmatzen, this is indeed an issue if you are using the 1.9.1 stable or older versions. The specification of master branch is coming from pytorch repo. We did delete the master branch recently. There are two fixes possible for resolving this:

  1. Make changes in the intel-isl/MiDaS repo to download the model using the main branch:
    resnet = torch.hub.load("facebookresearch/WSL-Images:main", "resnext101_32x8d_wsl")
    
    refer to File "/<removed>/.cache/torch/hub/intel-isl_MiDaS_master/midas/midas_net.py", line 30, in __init__ in your error log.
  2. Download the MiDaS model locally, using the custom step from 1 and in your code have the torch.hub.load function use the local copy.
  3. Install the bleeding edge version of pytorch. You can track the release schedule of pytorch here [v.1.10.0] Release Tracker pytorch/pytorch#65438 . I believe the PR for 1.10 version has been merged in and I am guessing a new version will be out soon. Disclaimer: I am not part of the pytorch team, I am inferring this from discussions.

@abhiskk abhiskk closed this as completed Oct 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants