Skip to content

Commit 186cb1e

Browse files
Merge branch 'update-build-model' into add-training-data
2 parents ab23716 + ab4725a commit 186cb1e

File tree

2 files changed

+18
-76
lines changed

2 files changed

+18
-76
lines changed

bioimageio/core/build_spec/build_model.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ def build_model(
632632
attachments: Optional[Dict[str, Union[str, List[str]]]] = None,
633633
packaged_by: Optional[List[str]] = None,
634634
run_mode: Optional[str] = None,
635-
parent: Optional[Tuple[str, str]] = None,
635+
parent: Optional[Dict[str, str]] = None,
636636
config: Optional[Dict[str, Any]] = None,
637637
dependencies: Optional[Union[Path, str]] = None,
638638
links: Optional[List[str]] = None,
@@ -709,7 +709,7 @@ def build_model(
709709
attachments: list of additional files to package with the model.
710710
packaged_by: list of authors that have packaged this model.
711711
run_mode: custom run mode for this model.
712-
parent: id of the parent model from which this model is derived and sha256 of the corresponding weight file.
712+
parent: id of the parent model from which this model is derived and sha256 of the corresponding rdf file.
713713
config: custom configuration for this model.
714714
dependencies: relative path to file with dependencies for this model.
715715
training_data: the training data for this model, either id for a bioimageio dataset or a dataset spec.
@@ -892,7 +892,7 @@ def build_model(
892892

893893
if parent is not None:
894894
assert len(parent) == 2
895-
kwargs["parent"] = {"uri": parent[0], "sha256": parent[1]}
895+
kwargs["parent"] = parent
896896

897897
if training_data is not None:
898898
if "id" in training_data:

example/bioimageio-core-usage.ipynb

Lines changed: 15 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,10 @@
1010
},
1111
{
1212
"cell_type": "code",
13-
"execution_count": 1,
13+
"execution_count": null,
1414
"id": "c72ba149",
1515
"metadata": {},
16-
"outputs": [
17-
{
18-
"name": "stderr",
19-
"output_type": "stream",
20-
"text": [
21-
"/home/pape/Work/bioimageio/spec-bioimage-io/bioimageio/spec/shared/_resolve_source.py:326: UserWarning: found cached /tmp/bioimageio_cache/https/raw.githubusercontent.com/bioimage-io/bioimage.io/main/site.config.json. Skipping download of https://raw.githubusercontent.com/bioimage-io/bioimage.io/main/site.config.json.\n",
22-
" warnings.warn(f\"found cached {local_path}. Skipping download of {uri}.\")\n"
23-
]
24-
}
25-
],
16+
"outputs": [],
2617
"source": [
2718
"import os\n",
2819
"import hashlib\n",
@@ -39,7 +30,7 @@
3930
},
4031
{
4132
"cell_type": "code",
42-
"execution_count": 2,
33+
"execution_count": null,
4334
"id": "74613461",
4435
"metadata": {},
4536
"outputs": [],
@@ -69,18 +60,18 @@
6960
},
7061
{
7162
"cell_type": "code",
72-
"execution_count": 6,
63+
"execution_count": null,
7364
"id": "2de51dae",
7465
"metadata": {},
7566
"outputs": [],
7667
"source": [
7768
"# the model can be loaded using different representations:\n",
7869
"\n",
7970
"# the doi of the zenodo entry corresponding to the model\n",
80-
"rdf_doi = \"10.5281/zenodo.6028056\"\n",
71+
"rdf_doi = \"10.5281/zenodo.6287342\"\n",
8172
"\n",
8273
"# the url of the yaml file containing the model resource description\n",
83-
"rdf_url = \"https://zenodo.org/record/6028056/files/rdf.yaml\"\n",
74+
"rdf_url = \"https://zenodo.org/record/6287342/files/rdf.yaml\"\n",
8475
"\n",
8576
"# FIXME the model currently does not show up on the website\n",
8677
"# filepath to the downloaded model (either zipped package or yaml)\n",
@@ -90,70 +81,21 @@
9081
},
9182
{
9283
"cell_type": "code",
93-
"execution_count": 7,
84+
"execution_count": null,
9485
"id": "ce884f8c",
9586
"metadata": {},
96-
"outputs": [
97-
{
98-
"name": "stderr",
99-
"output_type": "stream",
100-
"text": [
101-
"rdf.yaml: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 3.20k/3.20k [00:00<00:00, 1.28MiB/s]\n",
102-
"/home/pape/Work/bioimageio/spec-bioimage-io/bioimageio/spec/shared/schema.py:46: ValidationWarning: tags: Missing tags for categories: ['dims', 'framework', 'software']\n",
103-
" warnings.warn(msg, category=ValidationWarning)\n"
104-
]
105-
},
106-
{
107-
"ename": "ValidationError",
108-
"evalue": "{'_schema': ['Minimal shape [ 1. 2. 32. 32.] of output output0 is too small for halo [0, 0, 16, 16].']}",
109-
"output_type": "error",
110-
"traceback": [
111-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
112-
"\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)",
113-
"\u001b[0;32m/tmp/ipykernel_44819/830282669.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# load model from link to rdf.yaml\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mmodel_resource\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbioimageio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcore\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_resource_description\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrdf_url\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
114-
"\u001b[0;32m~/Work/bioimageio/core-bioimage-io-python/bioimageio/core/resource_io/io_.py\u001b[0m in \u001b[0;36mload_resource_description\u001b[0;34m(source, weights_priority_order)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0msource\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m \u001b[0mraw_rd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mload_raw_resource_description\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msource\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mupdate_to_format\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"latest\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 42\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mraw_rd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtype\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"model\"\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mweights_priority_order\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
115-
"\u001b[0;32m~/Work/bioimageio/spec-bioimage-io/bioimageio/spec/io_.py\u001b[0m in \u001b[0;36mload_raw_resource_description\u001b[0;34m(source, update_to_format)\u001b[0m\n\u001b[1;32m 189\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 190\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msub_spec\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconverters\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmaybe_convert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 191\u001b[0;31m \u001b[0mraw_rd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mschema\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 192\u001b[0m \u001b[0mraw_rd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mroot_path\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mroot\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 193\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
116-
"\u001b[0;32m~/software/conda/miniconda3/envs/main39/lib/python3.9/site-packages/marshmallow/schema.py\u001b[0m in \u001b[0;36mload\u001b[0;34m(self, data, many, partial, unknown)\u001b[0m\n\u001b[1;32m 717\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0minvalid\u001b[0m \u001b[0mdata\u001b[0m \u001b[0mare\u001b[0m \u001b[0mpassed\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 718\u001b[0m \"\"\"\n\u001b[0;32m--> 719\u001b[0;31m return self._do_load(\n\u001b[0m\u001b[1;32m 720\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmany\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmany\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpartial\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpartial\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0munknown\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0munknown\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpostprocess\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 721\u001b[0m )\n",
117-
"\u001b[0;32m~/software/conda/miniconda3/envs/main39/lib/python3.9/site-packages/marshmallow/schema.py\u001b[0m in \u001b[0;36m_do_load\u001b[0;34m(self, data, many, partial, unknown, postprocess)\u001b[0m\n\u001b[1;32m 902\u001b[0m \u001b[0mexc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mValidationError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0merrors\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalid_data\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mresult\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 903\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhandle_error\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmany\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmany\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpartial\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpartial\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 904\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 905\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 906\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
118-
"\u001b[0;31mValidationError\u001b[0m: {'_schema': ['Minimal shape [ 1. 2. 32. 32.] of output output0 is too small for halo [0, 0, 16, 16].']}"
119-
]
120-
}
121-
],
87+
"outputs": [],
12288
"source": [
12389
"# load model from link to rdf.yaml\n",
124-
"# FIXME need to update the min shape, but can't right now because the model is not on the website\n",
12590
"model_resource = bioimageio.core.load_resource_description(rdf_url)"
12691
]
12792
},
12893
{
12994
"cell_type": "code",
130-
"execution_count": 5,
95+
"execution_count": null,
13196
"id": "c1230b2d",
13297
"metadata": {},
133-
"outputs": [
134-
{
135-
"name": "stderr",
136-
"output_type": "stream",
137-
"text": [
138-
"rdf.yaml: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 2.92k/2.92k [00:00<00:00, 1.02MiB/s]\n"
139-
]
140-
},
141-
{
142-
"ename": "ValidationError",
143-
"evalue": "{'_schema': ['Minimal shape [ 1. 2. 32. 32.] of output output is too small for halo [0, 0, 16, 16].']}",
144-
"output_type": "error",
145-
"traceback": [
146-
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
147-
"\u001b[0;31mValidationError\u001b[0m Traceback (most recent call last)",
148-
"\u001b[0;32m/tmp/ipykernel_44819/725076596.py\u001b[0m in \u001b[0;36m<module>\u001b[0;34m\u001b[0m\n\u001b[1;32m 1\u001b[0m \u001b[0;31m# load model from doi\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mmodel_resource\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mbioimageio\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mcore\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload_resource_description\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mrdf_doi\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
149-
"\u001b[0;32m~/Work/bioimageio/core-bioimage-io-python/bioimageio/core/resource_io/io_.py\u001b[0m in \u001b[0;36mload_resource_description\u001b[0;34m(source, weights_priority_order)\u001b[0m\n\u001b[1;32m 39\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0msource\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 40\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 41\u001b[0;31m \u001b[0mraw_rd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mload_raw_resource_description\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0msource\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mupdate_to_format\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;34m\"latest\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 42\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 43\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mraw_rd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtype\u001b[0m \u001b[0;34m==\u001b[0m \u001b[0;34m\"model\"\u001b[0m \u001b[0;32mand\u001b[0m \u001b[0mweights_priority_order\u001b[0m \u001b[0;32mis\u001b[0m \u001b[0;32mnot\u001b[0m \u001b[0;32mNone\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
150-
"\u001b[0;32m~/Work/bioimageio/spec-bioimage-io/bioimageio/spec/io_.py\u001b[0m in \u001b[0;36mload_raw_resource_description\u001b[0;34m(source, update_to_format)\u001b[0m\n\u001b[1;32m 189\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 190\u001b[0m \u001b[0mdata\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0msub_spec\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mconverters\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mmaybe_convert\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 191\u001b[0;31m \u001b[0mraw_rd\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mschema\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mload\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 192\u001b[0m \u001b[0mraw_rd\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mroot_path\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mroot\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 193\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n",
151-
"\u001b[0;32m~/software/conda/miniconda3/envs/main39/lib/python3.9/site-packages/marshmallow/schema.py\u001b[0m in \u001b[0;36mload\u001b[0;34m(self, data, many, partial, unknown)\u001b[0m\n\u001b[1;32m 717\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0minvalid\u001b[0m \u001b[0mdata\u001b[0m \u001b[0mare\u001b[0m \u001b[0mpassed\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 718\u001b[0m \"\"\"\n\u001b[0;32m--> 719\u001b[0;31m return self._do_load(\n\u001b[0m\u001b[1;32m 720\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmany\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmany\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpartial\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpartial\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0munknown\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0munknown\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpostprocess\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0;32mTrue\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 721\u001b[0m )\n",
152-
"\u001b[0;32m~/software/conda/miniconda3/envs/main39/lib/python3.9/site-packages/marshmallow/schema.py\u001b[0m in \u001b[0;36m_do_load\u001b[0;34m(self, data, many, partial, unknown, postprocess)\u001b[0m\n\u001b[1;32m 902\u001b[0m \u001b[0mexc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mValidationError\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0merrors\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mvalid_data\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mresult\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 903\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mhandle_error\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mexc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdata\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mmany\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mmany\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mpartial\u001b[0m\u001b[0;34m=\u001b[0m\u001b[0mpartial\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 904\u001b[0;31m \u001b[0;32mraise\u001b[0m \u001b[0mexc\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 905\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 906\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
153-
"\u001b[0;31mValidationError\u001b[0m: {'_schema': ['Minimal shape [ 1. 2. 32. 32.] of output output is too small for halo [0, 0, 16, 16].']}"
154-
]
155-
}
156-
],
98+
"outputs": [],
15799
"source": [
158100
"# load model from doi\n",
159101
"model_resource = bioimageio.core.load_resource_description(rdf_doi)"
@@ -451,13 +393,13 @@
451393
"\n",
452394
"# we use the `parent` field to indicate that the new model is created based on\n",
453395
"# the nucleus segmentation model we have obtained from bioimage.io\n",
454-
"# this field is optional and only needs to be given for models that are created based on\n",
455-
"# other models from bioimage.io\n",
396+
"# this field is optional and only needs to be given for models that are created based on other models from bioimage.io\n",
456397
"# the parent is specified via it's doi and the hash of its rdf file\n",
457-
"rdf_file = os.path.join(model_resource.root_path, \"rdf.yaml\")\n",
398+
"model_root_folder = os.path.split(model_resource.weights[\"pytorch_state_dict\"].source)[0]\n",
399+
"rdf_file = os.path.join(model_root_folder, \"rdf.yaml\")\n",
458400
"with open(rdf_file, \"rb\") as f:\n",
459-
" weight_hash = hashlib.sha256(f.read()).hexdigest()\n",
460-
"parent = (rdf_doi, weight_hash)\n",
401+
" rdf_hash = hashlib.sha256(f.read()).hexdigest()\n",
402+
"parent = {\"uri\": rdf_doi, \"sha256\": rdf_hash}\n",
461403
"\n",
462404
"# the name of the new model and where to save the zipped model package\n",
463405
"name = \"new-model1\"\n",

0 commit comments

Comments
 (0)