openvinotoolkit / openvinotoolkit/open_model_zoo

Unable to convert ResNet-50-Pytorch model

Open
#4,009 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.4k
Forks
1.4k
Avg merge
4d 13h
Merged PRs (30d)
4

Description

Unable to convert the downloaded model. Error:

(openvino_env) (base) testuser@clftower:~/workspace$ omz_downloader --name resnet-50-pytorch
################|| Downloading resnet-50-pytorch ||################

========== Downloading /home/testuser/workspace/public/resnet-50-pytorch/resnet50-19c8e357.pth
... 100%, 100100 KB, 32465 KB/s, 3 seconds passed

(openvino_env) (base) testuser@clftower:~/workspace$ omz_converter --name resnet-50-pytorch
========== Converting resnet-50-pytorch to ONNX
Conversion to ONNX command: /home/testuser/openvino_env/bin/python -- /home/testuser/openvino_env/lib/python3.12/site-packages/omz_tools/internal_scripts/pytorch_to_onnx.py --model-name=resnet50 --weights=/home/testuser/workspace/public/resnet-50-pytorch/resnet50-19c8e357.pth --import-module=torchvision.models --input-shape=1,3,224,224 --output-file=/home/testuser/workspace/public/resnet-50-pytorch/resnet-v1-50.onnx --input-names=data --output-names=prob

ERROR: Weights from /home/testuser/workspace/public/resnet-50-pytorch/resnet50-19c8e357.pth cannot be loaded for model resnet50! Check matching between model and weights
Cannot use ``weights_only=True`` with files saved in the legacy .tar format. In PyTorch 2.6, we changed the default value of the `weights_only` argument in `torch.load` from `False` to `True`. Re-running `torch.load` with `weights_only` set to `False` will likely succeed, but it can result in arbitrary code execution. Do it only if you got the file from a trusted source.

FAILED:
resnet-50-pytorch
(openvino_env) (base) testuser@clftower:~/workspace$ 

Steps used on Ubuntu 24.04:

sudo apt install python3.12-venv
python3 -m venv openvino_env
source openvino_env/bin/activate
python -m pip install --upgrade pip
python -m pip install openvino
python -c "from openvino import Core; print(Core().available_devices)"      #  ---- Please verify that both CPU and GPU are listed -----
pip install openvino-dev
pip install onnx
pip install torch torchvision

mkdir workspace
cd workspace

omz_downloader --name resnet-50-pytorch
omz_converter --name resnet-50-pytorch

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with omz_downloader and omz_converter for resnet-50-pytorch, then inspect the generated command and pytorch_to_onnx.py. Compare the reported torch.load compatibility error with the model conversion path. Done means the downloaded ResNet-50-PyTorch model converts successfully without the shown error.

Written by the indexing model from the issue text.

Assessment

Tech stack
python, pytorch
Domain
machine-learning, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.