lin zhihua
lin zhihua

Reputation: 61

AttributeError: module 'torch' has no attribute 'hub'

import torch
model = torch.hub.list('pytorch/vision')

My pytorch version is 1.0.0, but I can't load the hub, why is this?

Upvotes: 6

Views: 5890

Answers (2)

dazzafact
dazzafact

Reputation: 2860

deinstall torch

reinstall torch==1.9.0, torchvision==0.10.0 and then install the necessary requirments.txt again

Upvotes: 0

Anubhav Singh
Anubhav Singh

Reputation: 8699

You will need torch >= 1.1.0 to use torch.hub attribute.

Alternatively, try by downloading this hub.py file and then try below code:

import hub
model = hub.list('pytorch/vision', force_reload=False)

Arguments:

github: Required, a string with format repo_owner/repo_name[:tag_name] with an optional tag/branch. The default branch is master if not specified. Example: pytorch/vision[:hub]

force_reload: Optional, whether to discard the existing cache and force a fresh download. Default is False.

Upvotes: 3

Related Questions