Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

An error occurs when running the onnx model #2925

Closed
yang162132 opened this issue Jan 9, 2024 · 2 comments
Closed

An error occurs when running the onnx model #2925

yang162132 opened this issue Jan 9, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@yang162132
Copy link

An error occurs when running the onnx model

2024-01-09 11:06:18.1575181 [E:onnxruntime:, sequential_executor.cc:346 onnxruntime::SequentialExecutor::Execute] Non-zero status code returned while running ReduceMax node. Name:'ReduceMax_1745' Status Message: D:\a\_work\1\s\onnxruntime\core\providers\cpu\reduction\reduction_ops.cc:747 onnxruntime::ValidateKeepDims keepdims was false. Can't reduce on dim with value of 0 if 'keepdims' is false. Invalid output shape would be produced. input_shape:{0,4}

this onnx file is converted from the pytorch pth file

    device = torch.device("cpu")
    model = create_model(num_classes=2)
    train_weights = "./save_weights/model.pth"
    model.load_state_dict(torch.load(train_weights, map_location=device)["model"])
    model.to(device)
    model.eval()
    original_img = Image.open("G:/yangben/newdata/png/56.png")
    data_transform = transforms.Compose([transforms.ToTensor()])
    img = data_transform(original_img)
    data_transform = transforms.Compose([transforms.ToTensor()])
    img = data_transform(original_img)
    img = torch.unsqueeze(img, dim=0)
    torch.onnx.export(model, img,
                      "faster_rcnn.onnx", 
                      opset_version=11, 
    )
@yang162132 yang162132 added the bug Something isn't working label Jan 9, 2024
@zachgk
Copy link
Contributor

zachgk commented Jan 11, 2024

Where are you getting this error? If I am reading it right, there is a call to max() in your model that is not supported by ONNX (but is presumably supported by Pytorch). You may have to modify the model to not make that call. It may also have something to do with a dimension (which may be the batch size) that has a value of 0 and that is not supported

@yang162132
Copy link
Author

Where are you getting this error? If I am reading it right, there is a call to max() in your model that is not supported by ONNX (but is presumably supported by Pytorch). You may have to modify the model to not make that call. It may also have something to do with a dimension (which may be the batch size) that has a value of 0 and that is not supported

Do you know where I need to adjust in my model? What function is this problem generally related to?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants