@@ -616,8 +616,10 @@ def build_model(
616616 documentation: relative file path to markdown documentation for this model.
617617 cite: citations for this model.
618618 output_path: where to save the zipped model package.
619- source: the file with the source code for the model architecture and the corresponding class.
619+ architecture: the file with the source code for the model architecture and the corresponding class.
620+ Only required for models with pytorch_state_dict weight format.
620621 model_kwargs: the keyword arguments for the model class.
622+ Only required for models with pytorch_state_dict weight format.
621623 weight_type: the type of the weights.
622624 sample_inputs: list of sample inputs to demonstrate the model performance.
623625 sample_outputs: list of sample outputs corresponding to sample_inputs.
@@ -648,8 +650,9 @@ def build_model(
648650 root: optional root path for relative paths. This can be helpful when building a spec from another model spec.
649651 add_deepimagej_config: add the deepimagej config to the model.
650652 tensorflow_version: the tensorflow version used for training the model.
651- Needs to be passed for tensorflow or keras models.
652- opset_version: the opset version used in this model. Needs to be passed for onnx models.
653+ Only requred for models with tensorflow or keras weight format.
654+ opset_version: the opset version used in this model.
655+ Only requred for models with onnx weight format.
653656 weight_kwargs: additional keyword arguments for this weight type.
654657 """
655658 if root is None :
@@ -848,35 +851,3 @@ def build_model(
848851
849852 model = load_raw_resource_description (model_package )
850853 return model
851-
852-
853- def add_weights (
854- model ,
855- weight_uri : Union [str , Path ],
856- weight_type : Optional [str ] = None ,
857- output_path : Optional [Union [str , Path ]] = None ,
858- architecture : Optional [str ] = None ,
859- model_kwargs : Optional [Dict [str , Union [int , float , str ]]] = None ,
860- tensorflow_version : Optional [str ] = None ,
861- opset_version : Optional [str ] = None ,
862- ** weight_kwargs ,
863- ):
864- """Add weight entry to bioimage.io model."""
865- # we need to pass the weight path as abs path to avoid confusion with different root directories
866- new_weights , tmp_arch = _get_weights (
867- Path (weight_uri ).absolute (),
868- weight_type ,
869- root = Path ("." ),
870- architecture = architecture ,
871- model_kwargs = model_kwargs ,
872- tensorflow_version = tensorflow_version ,
873- opset_version = opset_version ,
874- ** weight_kwargs ,
875- )
876- model .weights .update (new_weights )
877- if output_path is not None :
878- model_package = export_resource_package (model , output_path = output_path )
879- model = load_raw_resource_description (model_package )
880- if tmp_arch is not None :
881- os .remove (tmp_arch )
882- return model
0 commit comments