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

Failed to convert Pytorch MASKRCNN_RESNET50_FPN model to TensorFlow from ONNX #1056

Open
mmoghadam1 opened this issue Feb 8, 2023 · 0 comments

Comments

@mmoghadam1
Copy link

mmoghadam1 commented Feb 8, 2023

Describe the bug

When trying to run inference on a pretrained PyTorch model that has been converted to TensorFlow from ONNX, I get the following error:

ValueError: as_list() is not defined on an unknown TensorShape.

Inference using the onnx model with onnxruntime works fine, it's only when I convert it to TensorFlow that it fails. I've used this same code with other PyTorch models and it works fine, so I'm guessing it's related to the pretrained model.

To Reproduce

Here's a minimal example:

import torch
import torchvision
import onnx
from onnx_tf.backend import prepare

pt_model = torchvision.models.detection.maskrcnn_resnet50_fpn(weights="DEFAULT")
x = torch.randn(1, 3,800,800)
torch.onnx.export(pt_model, x, "torch.onnx")
model = onnx.load('torch.onnx')
tf_rep = prepare(model)
tf_output = tf_rep.run(x)

ONNX model file

https://drive.google.com/file/d/1sw1GhywhFrpeO6zQSaz9hlop1SEnDYG_/view?usp=sharing

Python, ONNX, ONNX-TF, Tensorflow version

  • Python version: 3.9.5
  • ONNX version: 1.13.0
  • ONNX-TF version: 1.10.0
  • Tensorflow version: 2.5.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant