models icon indicating copy to clipboard operation
models copied to clipboard

onnx Error parsing message with type 'onnx.ModelProto'

Open wangzy0327 opened this issue 3 years ago • 4 comments

Bug Report

Which model does this pertain to?

resnet50-v2-7.onnx bvlcalexnet-3.onnx googlenet-9.onnx vgg16-7.onnx

Describe the bug

when I run the python script load onnx model , it get error as

google.protobuf.message.DecodeError: Error parsing message with type 'onnx.ModelProto'

image

how to solve the problem ?

Reproduction instructions

System Information

OS Platform and Distribution (e.g. Linux Ubuntu 16.04):
Ubuntu18.04 ONNX version (e.g. 1.6):
onnx 1.12.0 Backend/Runtime version (e.g. ONNX Runtime 1.1, PyTorch 1.2):

Provide a code snippet to reproduce your errors.

import onnx
import numpy as np

MODEL_NAME = "ResNet-50"    # "AlexNet" or "ResNet-50" or "GoogleNet" or "Vgg-16"

if MODEL_NAME == "AlexNet":
    MODEL_PATH = 'onnx-model/vision/classification/alexnet/model/bvlcalexnet-3.onnx'
    INPUT_NAME = "data_0"
elif MODEL_NAME == "ResNet-50":
    MODEL_PATH = 'onnx-model/vision/classification/resnet/model/resnet50-v2-7.onnx'
    INPUT_NAME = "data"
elif MODEL_NAME == "GoogleNet":
    MODEL_PATH = 'onnx-model/vision/classification/inception_and_googlenet/googlenet/model/googlenet-9.onnx'
    INPUT_NAME = "data_0"
elif MODEL_NAME == "Vgg-16":
    MODEL_PATH = 'onnx-model/vision/classification/vgg/model/vgg16-7.onnx'
    INPUT_NAME = "data"
elif MODEL_NAME == "Vgg-19":
    MODEL_PATH = 'onnx-model/vision/classification/vgg/model/vgg19-7.onnx'
    INPUT_NAME = "data"

dtype="float32"

batch, channel, height, weight = 1, 3, 224, 224
I_np = np.random.uniform(size=(batch, channel, height, weight)).astype(dtype)

onnx_model = onnx.load(MODEL_PATH)
shape_dict = {INPUT_NAME: I_np.shape}

Notes

Any additional information

wangzy0327 avatar Oct 24 '22 03:10 wangzy0327

Hi @wangzy0327, Have you git-lfs theses models before using them? See https://github.com/onnx/models#usage---git-lfs-. They were initially stored as a git-lfs so you will need to further git-lfs them after git clone.

jcwchen avatar Oct 25 '22 15:10 jcwchen

OK,Thanks for your solution.

wangzy0327 avatar Oct 27 '22 03:10 wangzy0327

How did you solve this problem in the end?

1216560202 avatar Mar 05 '24 03:03 1216560202