Skip to content

Unable to convert ResNet-50-Pytorch model #4009

Open
@js333031

Description

@js333031

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions