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

Add the bioimageio resource description to deserialized stardist model #187

Merged
merged 3 commits into from
Mar 22, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 9 additions & 0 deletions stardist/bioimageio_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -453,4 +453,13 @@ def import_bioimageio(source, outpath):

model_class = (StarDist2D if config['n_dim'] == 2 else StarDist3D)
model = model_class(None, outpath.name, basedir=str(outpath.parent))

# 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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this helpful?

Copy link
Contributor Author

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.

Copy link
Member

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?

# add the resource description as an attribute to the model,
# so that additional information stored in there does not get lost
model.bioimageio_resource_description = biomodel
constantinpape marked this conversation as resolved.
Show resolved Hide resolved

return model