Skip to content

Make unet implementation scriptable#548

Open
FynnBe wants to merge 2 commits into
constantinpape:mainfrom
FynnBe:improve_unet_scripting
Open

Make unet implementation scriptable#548
FynnBe wants to merge 2 commits into
constantinpape:mainfrom
FynnBe:improve_unet_scripting

Conversation

@FynnBe

@FynnBe FynnBe commented Sep 9, 2025

Copy link
Copy Markdown
Contributor

I started looking into improving affable-shark and its onnx weights in particular, which led me down the rabbit hole, so this PR makes the unet implementation mostly scriptable (with the small exception of the 'check_shape' validation).

In order to make it scriptable I

  • added type annotations (in particular a few Final annotations to inform torch.jit about constants).
    Not all annotations are required, many I added for myself for a better overview and to help avoid unintended code changes.
  • removed some of thereturn_outputs flags, changing the Encoder and Decoder interfaces slightly for static signatures needed for scripting.

I am not done testing the code with the affable-shark model example.

@FynnBe

FynnBe commented Sep 9, 2025

Copy link
Copy Markdown
Contributor Author

I will try to allow scale_factor to be List[float] again, this seems to be used outside of unet.py...

@FynnBe FynnBe marked this pull request as ready for review September 10, 2025 12:47
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

Successfully merging this pull request may close these issues.

1 participant