@@ -217,7 +217,7 @@ def _get_input_tensor(path, name, step, min_shape, data_range, axes, preprocessi
217
217
data_range = _get_data_range (data_range , test_in .dtype )
218
218
kwargs = {}
219
219
if preprocessing is not None :
220
- kwargs ["preprocessing" ] = [{ "name" : k , "kwargs" : v } for k , v in preprocessing . items ()]
220
+ kwargs ["preprocessing" ] = preprocessing
221
221
222
222
inputs = model_spec .raw_nodes .InputTensor (
223
223
name = "input" if name is None else name ,
@@ -245,7 +245,7 @@ def _get_output_tensor(path, name, reference_tensor, scale, offset, axes, data_r
245
245
data_range = _get_data_range (data_range , test_out .dtype )
246
246
kwargs = {}
247
247
if postprocessing is not None :
248
- kwargs ["postprocessing" ] = [{ "name" : k , "kwargs" : v } for k , v in postprocessing . items ()]
248
+ kwargs ["postprocessing" ] = postprocessing
249
249
if halo is not None :
250
250
kwargs ["halo" ] = halo
251
251
@@ -260,9 +260,16 @@ def _get_output_tensor(path, name, reference_tensor, scale, offset, axes, data_r
260
260
return outputs
261
261
262
262
263
- # TODO The citation entry should be improved so that we can properly derive doi vs. url
264
- def _build_cite (cite : Dict [str , str ]):
265
- citation_list = [spec .rdf .raw_nodes .CiteEntry (text = k , url = v ) for k , v in cite .items ()]
263
+ def _build_cite (cite : List [Dict [str , str ]]):
264
+ citation_list = []
265
+ for entry in cite :
266
+ if "doi" in entry :
267
+ spec_entry = spec .rdf .raw_nodes .CiteEntry (text = entry ["text" ], doi = entry ["doi" ])
268
+ elif "url" in entry :
269
+ spec_entry = spec .rdf .raw_nodes .CiteEntry (text = entry ["text" ], url = entry ["url" ])
270
+ else :
271
+ raise ValueError (f"Expect one of doi or url in citation enrty { entry } " )
272
+ citation_list .append (spec_entry )
266
273
return citation_list
267
274
268
275
@@ -346,7 +353,7 @@ def _get_deepimagej_config(
346
353
if any (preproc is not None for preproc in preprocessing ):
347
354
assert len (preprocessing ) == 1
348
355
preprocess_ij = [
349
- _get_deepimagej_macro (name , kwargs , export_folder ) for name , kwargs in preprocessing [0 ]. items ()
356
+ _get_deepimagej_macro (preproc [ " name" ], preproc [ " kwargs" ] , export_folder ) for preproc in preprocessing [0 ]
350
357
]
351
358
attachments = [preproc ["kwargs" ] for preproc in preprocess_ij ]
352
359
else :
@@ -356,7 +363,7 @@ def _get_deepimagej_config(
356
363
if any (postproc is not None for postproc in postprocessing ):
357
364
assert len (postprocessing ) == 1
358
365
postprocess_ij = [
359
- _get_deepimagej_macro (name , kwargs , export_folder ) for name , kwargs in postprocessing [0 ]. items ()
366
+ _get_deepimagej_macro (postproc [ " name" ], postproc [ " kwargs" ] , export_folder ) for postproc in postprocessing [0 ]
360
367
]
361
368
if attachments is None :
362
369
attachments = [postproc ["kwargs" ] for postproc in postprocess_ij ]
@@ -595,7 +602,7 @@ def build_model(
595
602
authors : List [Dict [str , str ]],
596
603
tags : List [Union [str , Path ]],
597
604
documentation : Union [str , Path ],
598
- cite : Dict [str , str ],
605
+ cite : List [ Dict [str , str ] ],
599
606
output_path : Union [str , Path ],
600
607
# model specific optional
601
608
architecture : Optional [str ] = None ,
@@ -614,8 +621,8 @@ def build_model(
614
621
output_offset : Optional [List [List [int ]]] = None ,
615
622
output_data_range : Optional [List [List [Union [int , str ]]]] = None ,
616
623
halo : Optional [List [List [int ]]] = None ,
617
- preprocessing : Optional [List [Dict [str , Dict [str , Union [int , float , str ]]]]] = None ,
618
- postprocessing : Optional [List [Dict [str , Dict [str , Union [int , float , str ]]]]] = None ,
624
+ preprocessing : Optional [List [List [ Dict [str , Dict [str , Union [int , float , str ] ]]]]] = None ,
625
+ postprocessing : Optional [List [List [ Dict [str , Dict [str , Union [int , float , str ] ]]]]] = None ,
619
626
pixel_sizes : Optional [List [Dict [str , float ]]] = None ,
620
627
# general optional
621
628
maintainers : Optional [List [Dict [str , str ]]] = None ,
@@ -625,7 +632,7 @@ def build_model(
625
632
attachments : Optional [Dict [str , Union [str , List [str ]]]] = None ,
626
633
packaged_by : Optional [List [str ]] = None ,
627
634
run_mode : Optional [str ] = None ,
628
- parent : Optional [Tuple [str , str ]] = None ,
635
+ parent : Optional [Dict [str , str ]] = None ,
629
636
config : Optional [Dict [str , Any ]] = None ,
630
637
dependencies : Optional [Union [Path , str ]] = None ,
631
638
links : Optional [List [str ]] = None ,
@@ -655,7 +662,7 @@ def build_model(
655
662
tags=["segmentation", "light sheet data"],
656
663
license="CC-BY-4.0",
657
664
documentation="./documentation.md",
658
- cite={"Architecture ": "https://my_architecture.com"} ,
665
+ cite=[{"text ": "Ronneberger et al. U-Net", "doi": "10.1007/978-3-319-24574-4_28"}] ,
659
666
output_path="my-model.zip"
660
667
)
661
668
```
@@ -671,7 +678,7 @@ def build_model(
671
678
authors: the authors of this model.
672
679
tags: list of tags for this model.
673
680
documentation: relative file path to markdown documentation for this model.
674
- cite: citations for this model.
681
+ cite: references for this model.
675
682
output_path: where to save the zipped model package.
676
683
architecture: the file with the source code for the model architecture and the corresponding class.
677
684
Only required for models with pytorch_state_dict weight format.
@@ -701,7 +708,7 @@ def build_model(
701
708
attachments: list of additional files to package with the model.
702
709
packaged_by: list of authors that have packaged this model.
703
710
run_mode: custom run mode for this model.
704
- parent: id of the parent model from which this model is derived and sha256 of the corresponding weight file.
711
+ parent: id of the parent model from which this model is derived and sha256 of the corresponding rdf file.
705
712
config: custom configuration for this model.
706
713
dependencies: relative path to file with dependencies for this model.
707
714
root: optional root path for relative paths. This can be helpful when building a spec from another model spec.
@@ -882,7 +889,7 @@ def build_model(
882
889
kwargs ["maintainers" ] = [model_spec .raw_nodes .Maintainer (** m ) for m in maintainers ]
883
890
if parent is not None :
884
891
assert len (parent ) == 2
885
- kwargs ["parent" ] = { "uri" : parent [ 0 ], "sha256" : parent [ 1 ]}
892
+ kwargs ["parent" ] = parent
886
893
887
894
try :
888
895
model = model_spec .raw_nodes .Model (
0 commit comments