bioimage-io / core-bioimage-io-python

Python libraries for loading, running and packaging bioimage.io models
https://bioimage-io.github.io/core-bioimage-io-python/bioimageio/core.html
MIT License
28 stars 21 forks source link

Plans for weight converter? Common interface. #383

Open constantinpape opened 7 months ago

constantinpape commented 7 months ago

There have been some recent changes to the weight converters and it seems not everything there is up-to-date.

In weight_converter/torch/_torchscript the function converts the weights and returns the corresponding weight description: https://github.com/bioimage-io/core-bioimage-io-python/blob/main/bioimageio/core/weight_converter/torch/_torchscript.py#L98

In weight_converter/torch/_onnx the function name implies that the weights would directly be added to the model, but that does not seem to happen in the function. Note that this initially followed the same design as in the torchscript converter when I implemented this. See https://github.com/bioimage-io/core-bioimage-io-python/blob/main/bioimageio/core/weight_converter/torch/_onnx.py

In weight_converter/keras/_tensorflow the function is similar to the torchscript one above, but it does not return the weight description. See https://github.com/bioimage-io/core-bioimage-io-python/blob/main/bioimageio/core/weight_converter/keras/_tensorflow.py#L101

It would be good to agree to a common syntax for this functionality and outline a plan to update this and make it usable again. I would prefer to follow the syntax in the torchscript file; adding the weight directly to the model could be added as a different function that makes use of the conversion functions internally.

FynnBe commented 7 months ago

Totally! These converter submodules should only need minor updates (with the option to add additional converters). Providing both functionalities as you suggest makes sense to me 👍 Anyone interested in contributing is welcome to tackle this. I would do my best to provide answers to any questions that may arise.

FynnBe commented 7 months ago

@bioimage-io/spec-dev anyone interested in taking a look?