Skip to content

ImportError: cannot import name 'c2d_r50' from 'pytorchvideo.models.hub' #264

@Shengguang-Zhou

Description

@Shengguang-Zhou

If you do not know the root cause of the problem / bug, and wish someone to help you, please
post according to this template:

🐛 Bugs / Unexpected behaviors

NOTE: Please look at the existing list of Issues tagged with the label 'bug`. Only open a new issue if this bug has not already been reported. If an issue already exists, please comment there instead..

Instructions To Reproduce the Issue:

Please include the following (depending on what the issue is):

  1. Any changes you made (git diff) or code you wrote
# Device on which to run the model
# Set to cuda to load on GPU
device = "cuda" if torch.cuda.is_available() else "cpu"

# Pick a pretrained model and load the pretrained weights
model_name = "slowfast_r50"
model = torch.hub.load("facebookresearch/pytorchvideo", model=model_name, pretrained=True)
# Set to eval mode and move to desired device
model = model.to(device)
model = model.eval()```
2. The exact command(s) you ran:
3. What you observed (including the full logs):

ImportError Traceback (most recent call last)
Cell In[2], line 7
5 # Pick a pretrained model and load the pretrained weights
6 model_name = "slowfast_r50"
----> 7 model = torch.hub.load("facebookresearch/pytorchvideo", model=model_name, pretrained=True)
8 # Set to eval mode and move to desired device
9 model = model.to(device)

File ~/PycharmProjects/EurekAI-LM/venv/lib/python3.12/site-packages/torch/hub.py:568, in load(repo_or_dir, model, source, trust_repo, force_reload, verbose, skip_validation, *args, **kwargs)
564 if source == 'github':
565 repo_or_dir = _get_cache_or_reload(repo_or_dir, force_reload, trust_repo, "load",
566 verbose=verbose, skip_validation=skip_validation)
--> 568 model = _load_local(repo_or_dir, model, *args, **kwargs)
569 return model

File ~/PycharmProjects/EurekAI-LM/venv/lib/python3.12/site-packages/torch/hub.py:594, in _load_local(hubconf_dir, model, *args, **kwargs)
592 with _add_to_sys_path(hubconf_dir):
593 hubconf_path = os.path.join(hubconf_dir, MODULE_HUBCONF)
--> 594 hub_module = _import_module(MODULE_HUBCONF, hubconf_path)
596 entry = _load_entry_from_hubconf(hub_module, model)
597 model = entry(*args, **kwargs)

File ~/PycharmProjects/EurekAI-LM/venv/lib/python3.12/site-packages/torch/hub.py:106, in _import_module(name, path)
104 module = importlib.util.module_from_spec(spec)
105 assert isinstance(spec.loader, Loader)
--> 106 spec.loader.exec_module(module)
107 return module

File :995, in exec_module(self, module)

File :488, in _call_with_frames_removed(f, *args, **kwds)

File ~/.cache/torch/hub/facebookresearch_pytorchvideo_main/hubconf.py:4
1 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3 dependencies = ["torch"]
----> 4 from pytorchvideo.models.hub import ( # noqa: F401, E402
5 c2d_r50,
6 csn_r101,
7 efficient_x3d_s,
8 efficient_x3d_xs,
9 i3d_r50,
10 mvit_base_16,
11 mvit_base_16x4,
12 mvit_base_32x3,
13 r2plus1d_r50,
14 slow_r50,
15 slow_r50_detection,
16 slowfast_16x8_r101_50_50,
17 slowfast_r101,
18 slowfast_r50,
19 slowfast_r50_detection,
20 x3d_l,
21 x3d_m,
22 x3d_s,
23 x3d_xs,
24 )

ImportError: cannot import name 'c2d_r50' from 'pytorchvideo.models.hub' (/home/shengguang/PycharmProjects/EurekAI-LM/venv/lib/python3.12/site-packages/pytorchvideo/models/hub/init.py)```

Please also simplify the steps as much as possible so they do not require additional resources to
run, such as a private dataset, models, etc.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions