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

Shifted segmentation mask output when converting from keras to onnx models #2366

Open
kgossage opened this issue Nov 14, 2024 · 2 comments
Open
Labels
bug An unexpected problem or unintended behavior

Comments

@kgossage
Copy link

Describe the bug
I trained a U-net style segmentation model using the exact model generation code found here: (https://keras.io/examples/vision/oxford_pets_image_segmentation/).

The segmentation mask lines up properly with the input RGB image (640x640x3 input size with 2 output classes) when run using the Keras model, but is shifted 15x15 pixels when running the model converted to onnx (onnx coords are shifted smaller than keras coords by 15 pixels in each dimension). I've tried tf2onnx.convert and console and tf2onnx.convert.from_keras python commands to convert the model and both have the same output. I've tried opsets 12-18, but no difference. This Unet style model takes the image from 640x640 to 40x40 before scaling back up to 640x640. This is a factor of 16x16 and I feel the problem is one of the upscaling layers is erroneously shifting (or failing to shift more likely) at each step.

Urgency
ASAP

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 18.04*): Ubuntu 22.04.4 LTS
  • TensorFlow Version: 2.15.1
  • Python version: 3.9.19
  • ONNX version (if applicable, e.g. 1.11*): 1.17.0
  • ONNXRuntime version (if applicable, e.g. 1.11*): tf2onnx=1.16.1/15c810

To Reproduce

Screenshots

Additional context

@kgossage kgossage added the bug An unexpected problem or unintended behavior label Nov 14, 2024
@fatcat-z
Copy link
Collaborator

Could you please share an end-to-end example of how you discovering this problem so we can repro it more efficiently?

@kgossage
Copy link
Author

kgossage commented Nov 15, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants