@@ -100,10 +100,7 @@ def _get_weights(weight_uri, weight_type, source, root, **kwargs):
100
100
101
101
elif weight_type == "onnx" :
102
102
weights = model_spec .raw_nodes .OnnxWeightsEntry (
103
- source = weight_source ,
104
- sha256 = weight_hash ,
105
- opset_version = kwargs .get ("opset_version" , 12 ),
106
- ** attachments
103
+ source = weight_source , sha256 = weight_hash , opset_version = kwargs .get ("opset_version" , 12 ), ** attachments
107
104
)
108
105
language = None
109
106
framework = None
@@ -197,9 +194,7 @@ def _get_input_tensor(path, name, step, min_shape, data_range, axes, preprocessi
197
194
198
195
kwargs = {}
199
196
if preprocessing is not None :
200
- kwargs ["preprocessing" ] = [
201
- {"name" : k , "kwargs" : v } for k , v in preprocessing .items ()
202
- ]
197
+ kwargs ["preprocessing" ] = [{"name" : k , "kwargs" : v } for k , v in preprocessing .items ()]
203
198
204
199
inputs = model_spec .raw_nodes .InputTensor (
205
200
name = "input" if name is None else name ,
@@ -229,9 +224,7 @@ def _get_output_tensor(path, name, reference_tensor, scale, offset, axes, data_r
229
224
230
225
kwargs = {}
231
226
if postprocessing is not None :
232
- kwargs ["postprocessing" ] = [
233
- {"name" : k , "kwargs" : v } for k , v in postprocessing .items ()
234
- ]
227
+ kwargs ["postprocessing" ] = [{"name" : k , "kwargs" : v } for k , v in postprocessing .items ()]
235
228
if halo is not None :
236
229
kwargs ["halo" ] = halo
237
230
@@ -389,8 +382,9 @@ def build_model(
389
382
390
383
inputs = [
391
384
_get_input_tensor (test_in , name , step , min_shape , axes , data_range , preproc )
392
- for test_in , name , step , min_shape , axes , data_range , preproc in
393
- zip (test_inputs , input_name , input_step , input_min_shape , input_axes , input_data_range , preprocessing )
385
+ for test_in , name , step , min_shape , axes , data_range , preproc in zip (
386
+ test_inputs , input_name , input_step , input_min_shape , input_axes , input_data_range , preprocessing
387
+ )
394
388
]
395
389
396
390
n_outputs = len (test_outputs )
@@ -405,8 +399,7 @@ def build_model(
405
399
406
400
outputs = [
407
401
_get_output_tensor (test_out , name , reference , scale , offset , axes , data_range , postproc , hal )
408
- for test_out , name , reference , scale , offset , axes , data_range , postproc , hal in
409
- zip (
402
+ for test_out , name , reference , scale , offset , axes , data_range , postproc , hal in zip (
410
403
test_outputs ,
411
404
output_name ,
412
405
output_reference ,
@@ -415,7 +408,7 @@ def build_model(
415
408
output_axes ,
416
409
output_data_range ,
417
410
postprocessing ,
418
- halo
411
+ halo ,
419
412
)
420
413
]
421
414
@@ -449,7 +442,7 @@ def build_model(
449
442
"source" : source ,
450
443
"sha256" : source_hash ,
451
444
"kwargs" : model_kwargs ,
452
- "links" : links
445
+ "links" : links ,
453
446
}
454
447
kwargs = {k : v for k , v in optional_kwargs .items () if v is not None }
455
448
if dependencies is not None :
@@ -495,13 +488,13 @@ def add_weights(
495
488
weight_uri : Union [str , Path ],
496
489
weight_type : Optional [str ] = None ,
497
490
output_path : Optional [Union [str , Path ]] = None ,
498
- ** weight_kwargs
491
+ ** weight_kwargs ,
499
492
):
500
493
"""Add weight entry to bioimage.io model."""
501
494
# we need to patss the weight path as abs path to avoid confusion with different root directories
502
- new_weights = _get_weights (
503
- Path ( weight_uri ). absolute (), weight_type , source = None , root = Path ( "." ), ** weight_kwargs
504
- )[ 0 ]
495
+ new_weights = _get_weights (Path ( weight_uri ). absolute (), weight_type , source = None , root = Path ( "." ), ** weight_kwargs )[
496
+ 0
497
+ ]
505
498
model .weights .update (new_weights )
506
499
if output_path is not None :
507
500
model_package = export_resource_package (model , output_path = output_path )
0 commit comments