question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

The ONNX network's output 'output' dimensions should be non-negative

See original GitHub issue

Ask a Question

Question

I trained a CycleGAN and imported it to onnx format. When I import the onnx model to the runtime(Snap Lens Studio), I got the error like this and cannot import it. Resource import for /Users/youjin/Downloads/latest_net_G (1).onnx failed: The ONNX network's output '625' dimensions should be non-negative image From this post, I assumed that I got the error cuz the output node does not know its shape. (when I print the output.shape or use torchsummary, it shows the output shape clearly) I used dynamic_axes of torch.onnx.export like the snippet below. When I open it with Netron, it seems to show the right shape, but it still gives the same error on Snap Lens Studio. image

I am thinking of using resize at the end of the model now. I’d like to hear any opinion on solving this situation. Even I am not sure I am on the right track.

Further information

  • Relevant Area (e.g. model usage, backend, best practices, converters, shape_inference, version_converter, training, test, operators): runtime error

  • Is this issue related to a specific model?
    Model name (e.g. mnist): CycleGAN Model opset (e.g. 7): 11

Notes

Any additional information, code snippets.

  net.eval()
  net.cuda()  
  RESOLUTION = 512

  batch_size = 1  
  input_shape = (3, RESOLUTION, RESOLUTION)  # in my case its 512
  export_onnx_file = load_filename[:-4]+".onnx"  
  save_path = os.path.join(self.save_dir, export_onnx_file)

  input_names = ["input"]
  output_names = ["output"]
  random_input = torch.randn(1, 3, RESOLUTION, RESOLUTION, dtype=torch.float32)
  torch.onnx.export(net, random_input, save_path,
                    input_names = input_names, output_names = output_names,
                    opset_version = 11,)
                     dynamic_axes={
                     'output' : {
                       0:'1',
                       1:'3',
                       2:'512',
                       3:'512'
                     }})
  onnx.save(onnx.shape_inference.infer_shapes(onnx.load(save_path)), save_path)

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
youjinChungcommented, Aug 18, 2022

I came back with an update. It turns out that Snap Lens Studio has some limitations with onnx models, so it would be safe to use their provided models only. I found the CycleGAN model from Snap Research, and I could import their model without any error.

0reactions
youjinChungcommented, Aug 17, 2022

@jcwchen Thanks for checking the model! Now I am assured it is now the model problem, so I can switch my direction. Let me come back if I have any updates or some other onnx-related questions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

The ONNX network's output 'pred' dimensions should be non ...
Hello, I am trained a CycleGAN and converted it to onnx model using ... The ONNX network's output 'pred' dimensions should be non-negative....
Read more >
CycleGAN onnx file import error - Snap AR
I trained a face conversion CycleGAN and exported it as an onnx file. ... The ONNX network's output '625' dimensions should be non-negative...
Read more >
Resource Import Failed: Negative Dimensions
Failed to add resource: The ONNX network's output 'model_outputs0' dimensions should be non-negative. Is this because the 'object' I'm using ...
Read more >
ConvolutionBackpropData - OpenVINO™ Documentation
Output shape when specified as an input output_shape , specifies only spatial dimensions. No batch or channel dimension should be passed along with...
Read more >
Open Neural Network Exchange Intermediate Representation ...
Up to IR version 6, the ONNX specification and model format addressed only ... Once all output parameters have been written to by...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found