@@ -71,7 +71,6 @@ def validate_processing_kwargs(self, data, **kwargs):
7171 axes = data ["axes" ]
7272 processing_list = data .get (self .processing_name , [])
7373 for processing in processing_list :
74- name = processing .name
7574 kwargs = processing .kwargs or {}
7675 kwarg_axes = kwargs .get ("axes" , "" )
7776 if any (a not in axes for a in kwarg_axes ):
@@ -94,17 +93,22 @@ class clip(SharedProcessingSchema):
9493 class scale_linear (SharedProcessingSchema ):
9594 bioimageio_description = "Fixed linear scaling."
9695 axes = fields .Axes (
97- required = True ,
9896 valid_axes = "czyx" ,
9997 bioimageio_description = "The subset of axes to scale jointly. "
10098 "For example xy to scale the two image axes for 2d data jointly. "
10199 "The batch axis (b) is not valid here." ,
102100 )
103101 gain = fields .Array (
104- fields .Float (), missing = fields .Float (missing = 1.0 ), bioimageio_description = "multiplicative factor"
102+ fields .Float (),
103+ bioimageio_maybe_required = True ,
104+ missing = fields .Float (missing = 1.0 ),
105+ bioimageio_description = "multiplicative factor" ,
105106 ) # todo: check if gain match input axes
106107 offset = fields .Array (
107- fields .Float (), missing = fields .Float (missing = 0.0 ), bioimageio_description = "additive term"
108+ fields .Float (),
109+ bioimageio_maybe_required = True ,
110+ missing = fields .Float (missing = 0.0 ),
111+ bioimageio_description = "additive term" ,
108112 ) # todo: check if offset match input axes
109113
110114 @validates_schema
@@ -140,9 +144,8 @@ class sigmoid(SharedProcessingSchema):
140144
141145 class zero_mean_unit_variance (SharedProcessingSchema ):
142146 bioimageio_description = "Subtract mean and divide by variance."
143- mode = fields .ProcMode (required = True )
147+ mode = fields .ProcMode ()
144148 axes = fields .Axes (
145- required = True ,
146149 valid_axes = "czyx" ,
147150 bioimageio_description = "The subset of axes to normalize jointly. For example xy to normalize the two image "
148151 "axes for 2d data jointly. The batch axis (b) is not valid here." ,
@@ -164,12 +167,12 @@ class zero_mean_unit_variance(SharedProcessingSchema):
164167
165168 @validates_schema
166169 def mean_and_std_match_mode (self , data , ** kwargs ):
167- if data [ "mode" ] == "fixed" and ("mean" not in data or "std" not in data ):
170+ if data . get ( "mode" , "fixed" ) == "fixed" and ("mean" not in data or "std" not in data ):
168171 raise ValidationError (
169172 "`kwargs` for 'zero_mean_unit_variance' preprocessing with `mode` 'fixed' require additional "
170173 "`kwargs`: `mean` and `std`."
171174 )
172- elif data [ "mode" ] != "fixed" and ("mean" in data or "std" in data ):
175+ elif data . get ( "mode" , "fixed" ) != "fixed" and ("mean" in data or "std" in data ):
173176 raise ValidationError (
174177 "`kwargs`: `mean` and `std` for 'zero_mean_unit_variance' preprocessing are only valid for `mode` 'fixed'."
175178 )
@@ -189,9 +192,8 @@ class Preprocessing(Processing):
189192
190193 class scale_range (SharedProcessingSchema ):
191194 bioimageio_description = "Scale with percentiles."
192- mode = fields .ProcMode (required = True , valid_modes = ("per_dataset" , "per_sample" ))
195+ mode = fields .ProcMode (valid_modes = ("per_dataset" , "per_sample" ))
193196 axes = fields .Axes (
194- required = True ,
195197 valid_axes = "czyx" ,
196198 bioimageio_description = "The subset of axes to normalize jointly. For example xy to normalize the two image "
197199 "axes for 2d data jointly. The batch axis (b) is not valid here." ,
@@ -245,7 +247,7 @@ class scale_range(Preprocessing.scale_range):
245247
246248 class scale_mean_variance (SharedProcessingSchema ):
247249 bioimageio_description = "Scale the tensor s.t. its mean and variance match a reference tensor."
248- mode = fields .ProcMode (required = True , valid_modes = ("per_dataset" , "per_sample" ))
250+ mode = fields .ProcMode (valid_modes = ("per_dataset" , "per_sample" ))
249251 reference_tensor = fields .String (
250252 required = True ,
251253 validate = field_validators .Predicate ("isidentifier" ),
0 commit comments