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

Bioimageio Model Creation #227

Closed
wants to merge 24 commits into from
Closed
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
f2fa218
WIP Add bioimage.io model creation
anwai98 Oct 10, 2023
2073119
Update model building script
anwai98 Oct 11, 2023
fbfde8e
Update model predictor adaptor for bioimage models
anwai98 Oct 11, 2023
c62fe93
Refactor modelzoo functionality into submodule
constantinpape Oct 11, 2023
615ffc6
Add first working scripts for bioengine export
constantinpape Oct 11, 2023
09f5f76
Add input prompt transofrms to adaptor
anwai98 Oct 11, 2023
b869a33
Update numpy input saving
anwai98 Oct 11, 2023
96dc3f6
Update bioengine export script
constantinpape Oct 11, 2023
61b076e
Merge branch 'aa-modelzoo' of https://github.com/computational-cell-a…
constantinpape Oct 11, 2023
7d6bfca
Refactor modelzoo export
constantinpape Oct 12, 2023
b470257
Add tempfile for model conversion inputs
anwai98 Oct 12, 2023
de6b245
Add doc-strings to bioengine export functionality
constantinpape Oct 12, 2023
ebba719
Update modelzoo export script
constantinpape Oct 12, 2023
ee831ef
Update url in imjoy test
constantinpape Oct 13, 2023
b28c885
Merge branch 'dev' into aa-modelzoo
constantinpape Mar 14, 2024
390ce23
Update to bioimageio.spec v0.5 WIP
constantinpape Mar 14, 2024
6cccc06
Update example script
constantinpape Mar 15, 2024
b9df849
Update bioimageio export
constantinpape Mar 18, 2024
d911392
Minor fixes
constantinpape Mar 19, 2024
ec56035
Work on export
constantinpape Mar 19, 2024
2d9c88a
More modelzoo updtes
constantinpape Mar 20, 2024
a170511
Add all possible model inputs
constantinpape Mar 21, 2024
d2e4909
Merge branch 'dev' into aa-modelzoo
constantinpape Apr 9, 2024
c181e29
Bioimageio updates WIP
constantinpape Apr 9, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Minor fixes
constantinpape committed Mar 19, 2024
commit d911392294f1658535146d8dea99ec5a7b9b7475
23 changes: 10 additions & 13 deletions micro_sam/bioimageio/model_export.py
Original file line number Diff line number Diff line change
@@ -241,11 +241,9 @@ def export_sam_model(
id=spec.TensorId("masks"),
axes=[
spec.BatchAxis(),
# NOTE: we use the data dependent size here to avoid dependency on optional inputs
spec.IndexOutputAxis(
id=spec.AxisId("object"),
size=spec.SizeReference(
tensor_id=spec.TensorId("box_prompts"), axis_id=spec.AxisId("object")
)
id=spec.AxisId("object"), size=spec.DataDependentSize(),
),
# NOTE: this could be a 3 once we use multi-masking
spec.ChannelAxis(channel_names=[spec.Identifier("mask")]),
@@ -271,11 +269,9 @@ def export_sam_model(
id=spec.TensorId("scores"),
axes=[
spec.BatchAxis(),
# NOTE: we use the data dependent size here to avoid dependency on optional inputs
spec.IndexOutputAxis(
id=spec.AxisId("object"),
size=spec.SizeReference(
tensor_id=spec.TensorId("box_prompts"), axis_id=spec.AxisId("object")
)
id=spec.AxisId("object"), size=spec.DataDependentSize(),
),
# NOTE: this could be a 3 once we use multi-masking
spec.ChannelAxis(channel_names=[spec.Identifier("mask")]),
@@ -307,16 +303,13 @@ def export_sam_model(

dependency_file = os.path.join(tmp_dir, "environment.yaml")
_write_dependencies(dependency_file, require_mobile_sam=model_type.startswith("vit_t"))
# print(dependency_file)
# breakpoint()

weight_descriptions = spec.WeightsDescr(
pytorch_state_dict=spec.PytorchStateDictWeightsDescr(
source=Path(checkpoint_path),
architecture=architecture,
pytorch_version=spec.Version(torch.__version__),
# FIXME: this leads to a validation error!
# dependencies=dependency_file,
dependencies=spec.EnvironmentFileDescr(source=dependency_file),
)
)

@@ -339,11 +332,15 @@ def export_sam_model(
tags=kwargs.get("tags", DEFAULTS["tags"]),
covers=covers,
# TODO attach the decoder weights if given
# attachments=
# Can be list of files???
# attachments=[spec.FileDescr(source=file_path) for file_path in attachment_files]
# TODO write the config
# dict with yaml values, key must be a str
# micro_sam: ...
# config=
)

# TODO test the model.
# Should work, but not tested with optional.

save_bioimageio_package(model_description, output_path=output_path)