@@ -189,6 +189,8 @@ def _ensure_str_list(config_names):
189
189
self .config_names : List [str ] = _ensure_str_list (config_names )
190
190
191
191
192
+ DEFAULT_BundleConfigNames = BundleConfigNames ()
193
+
192
194
# The operator env decorator defines the required pip packages commonly used in the Bundles.
193
195
# The MONAI Deploy App SDK packager currently relies on the App to consolidate all required packages in order to
194
196
# install them in the MAP Docker image.
@@ -222,22 +224,22 @@ class MonaiBundleInferenceOperator(InferenceOperator):
222
224
a pickle file whose name is the same as the output name.
223
225
"""
224
226
225
- DISALLOWED_TRANSFORMS = ["LoadImage" , "SaveImage" ]
226
-
227
227
known_io_data_types = {
228
228
"image" : Image , # Image object
229
229
"series" : np .ndarray ,
230
230
"tuples" : np .ndarray ,
231
231
"probabilities" : Dict [str , Any ], # dictionary containing probabilities and predicted labels
232
232
}
233
233
234
+ kw_preprocessed_inputs = "preprocessed_inputs"
235
+
234
236
def __init__ (
235
237
self ,
236
238
input_mapping : List [IOMapping ],
237
239
output_mapping : List [IOMapping ],
238
240
model_name : Optional [str ] = "" ,
239
- bundle_path : Optional [str ] = None ,
240
- bundle_config_names : Optional [BundleConfigNames ] = None ,
241
+ bundle_path : Optional [str ] = "" ,
242
+ bundle_config_names : Optional [BundleConfigNames ] = DEFAULT_BundleConfigNames ,
241
243
* args ,
242
244
** kwargs ,
243
245
):
@@ -391,7 +393,7 @@ def _get_meta_key_postfix(self, compose: Compose, key_name: str = "meta_key_post
391
393
post_fix = getattr (t , key_name )
392
394
# For some reason the attr is a tuple
393
395
if isinstance (post_fix , tuple ):
394
- post_fix = post_fix [0 ]
396
+ post_fix = str ( post_fix [0 ])
395
397
break
396
398
397
399
return str (post_fix )
@@ -496,7 +498,8 @@ def compute(self, op_input: InputContext, op_output: OutputContext, context: Exe
496
498
# TODO: Does this work for models where multiple outputs are returned?
497
499
# Note that the inputs are needed because the invert transform requires it.
498
500
start = time .time ()
499
- outputs = self .post_process (ensure_tuple (outputs )[0 ], preprocessed_inputs = inputs )
501
+ kw_args = {self .kw_preprocessed_inputs : inputs }
502
+ outputs = self .post_process (ensure_tuple (outputs )[0 ], ** kw_args )
500
503
logging .debug (f"Post-processing elapsed time (seconds): { time .time () - start } " )
501
504
if isinstance (outputs , (tuple , list )):
502
505
output_dict = dict (zip (self ._outputs .keys (), outputs ))
@@ -530,7 +533,7 @@ def post_process(self, data: Any, *args, **kwargs) -> Union[Image, Any, Tuple[An
530
533
"""
531
534
532
535
# Expect the inputs be passed in so that the inversion can work.
533
- inputs = kwargs .get ("preprocessed_inputs" , {})
536
+ inputs = kwargs .get (self . kw_preprocessed_inputs , {})
534
537
535
538
if is_map_compose (self ._postproc ):
536
539
if isinstance (data , (list , tuple )):
0 commit comments