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
Add the bioimageio resource description to deserialized stardist model #187
Conversation
Can you explain why this is useful? I would really help if I understood what this is supposed to be used for. |
stardist/bioimageio_utils.py
Outdated
# update the location of the stardist specific files, since they are the ones being used by the model | ||
biomodel.config['stardist']['config'] = outpath / 'config.json' | ||
biomodel.config['stardist']['thresholds'] = outpath / 'thresholds.json' | ||
biomodel.config['stardist']['weights'] = outpath / weights |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this helpful?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
E.g. to have the correct weight path that the stardist model is using, for example in the case where weights are updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, I don't get it. If you want the preserve the config, thresholds, and weights at the time when the bioimage.io model was imported, then why should biomodel.config['stardist']['config']
and biomodel.config['stardist']['thresholds']
be overwritten?
To access information stored in the rdf.yaml in a programatic way. |
Sorry, I really don't get it. Can you (or @esgomezm) please write the steps of a potential use case? E.g.
|
Ok, I understand now why the changes proposed here don't make sense. This would be easy to change and I could propose these changes.
Just very briefly, a use case would be:
|
Hi @uschmidt83 and @constantinpape Thank you for opening the discussion! The use case proposed by @constantinpape is actually very nice. The use-case with ZeroCostDL4Mic notebooks is as follows:
In step 3 we could suggest uploading the pre-trained model directly and keep training it, but then we would need to create an extra library or code to check that the architecture specified by the user, match the one of the pre-trained model. Yet, some of the information contained in the model YAML is not contained in configuration or thresholds. I think (but maybe I'm wrong) giving the chance to access this info is not damaging and it can be helpful for the integration of StarDist in different workflows. Note also that the YAML file may contain a technical description about how to use the training data or some training parameters. Parsing this type of information and directly providing it makes the interaction smoother to building up self-contained workflows, in my opinion. In any case, if this is a big issue, I can program the notebooks in a different manner. |
Thanks for expanding on the use-cases, @esgomezm. To make my proposal from above more concrete, I would adapt the implementation of
@uschmidt83 let me know if this makes sense to you. If not we can work around it in zero-cost and other potential use-cases. (But I think the proposed solution would be more elegant, also because it allows calling |
Sorry, I don't like the idea that
This I can get behind, i.e. also saving the
How do I check whether the folder has the "correct files"? The files can change over time, e.g. when fine-tuning. New weights will then be added to the folder, which may be loaded instead of the weights from the BMZ. This makes it hard to reason in advance what will happen. I propose the following: >>> from stardist import import_bioimageio
>>> from pathlib import Path
>>> model = import_bioimageio("10.5281/zenodo.6348084", "./bio-model")
>>> print(Path(model.logdir / "rdf.yaml").exists())
True Isn't it easy enough for you to then just load the
Wouldn't it be better to have the user select a pre-trained model and then just allow to change parameters that don't affect the architecture of the CNN? |
I updated the PR to implement your suggestion @uschmidt83: This solution would be totally fine for our use cases as well, since it's indeed very easy to now load the bioimageio resource description via Let me know if there are any more questions / issues with this or if we can merge it. |
- save all files to separate sub-folder - rename weights to "weights_bioimageio.h5"
I've changed the code again. Ok like that? |
The result of your changes is good, i.e. having a subfolder |
Which comment?
I think it's cleaner that way.
Which comment? |
I forgot to hit the review button, you should see it on line 436 now. |
Hi @constantinpape and @uschmidt83, with this, should be enough! thank you
That's another way of interacting with the models, which is also quite nice and can be motivated by the BMZ (without relying on other software). However, the logic behind the ZeroCostDL4Mic notebooks goes the other way around. |
@uschmidt83 this is good to go from my end :). |
Thanks @uschmidt83. I also tested it locally for our use-case data now and this works as expected. |
I've just made a new release (0.8.1). |
to keep the information stored in the bioimageio rdf.yaml available after loading the model.