@@ -128,10 +128,12 @@ def infer(
128128
129129 if inference_parameters is not None :
130130 update_progress_callback = inference_parameters .update_progress
131- is_evaluation = inference_parameters .is_evaluation
131+ dump_soft_prediction = not inference_parameters .is_evaluation
132+ process_soft_prediction = inference_parameters .process_saliency_maps
132133 else :
133134 update_progress_callback = default_infer_progress_callback
134- is_evaluation = False
135+ dump_soft_prediction = True
136+ process_soft_prediction = False
135137
136138 update_progress_callback = default_progress_callback
137139 if inference_parameters is not None :
@@ -141,7 +143,7 @@ def infer(
141143
142144 predictions = self ._infer_model (dataset , InferenceParameters (is_evaluation = True ))
143145 prediction_results = zip (predictions ["eval_predictions" ], predictions ["feature_vectors" ])
144- self ._add_predictions_to_dataset (prediction_results , dataset , dump_soft_prediction = not is_evaluation )
146+ self ._add_predictions_to_dataset (prediction_results , dataset , dump_soft_prediction , process_soft_prediction )
145147
146148 logger .info ("Inference completed" )
147149 return dataset
@@ -266,7 +268,7 @@ def evaluate(
266268 output_resultset .performance = metric .get_performance ()
267269 logger .info ("Evaluation completed" )
268270
269- def _add_predictions_to_dataset (self , prediction_results , dataset , dump_soft_prediction ):
271+ def _add_predictions_to_dataset (self , prediction_results , dataset , dump_soft_prediction , process_soft_prediction ):
270272 """Loop over dataset again to assign predictions. Convert from MMSegmentation format to OTX format."""
271273 for dataset_item , (prediction , feature_vector ) in zip (dataset , prediction_results ):
272274 soft_prediction = np .transpose (prediction [0 ], axes = (1 , 2 , 0 ))
@@ -291,14 +293,15 @@ def _add_predictions_to_dataset(self, prediction_results, dataset, dump_soft_pre
291293 if label_index == 0 :
292294 continue
293295 current_label_soft_prediction = soft_prediction [:, :, label_index ]
294- class_act_map = get_activation_map (current_label_soft_prediction )
296+ if process_soft_prediction :
297+ current_label_soft_prediction = get_activation_map (current_label_soft_prediction )
295298 result_media = ResultMediaEntity (
296299 name = label .name ,
297300 type = "soft_prediction" ,
298301 label = label ,
299302 annotation_scene = dataset_item .annotation_scene ,
300303 roi = dataset_item .roi ,
301- numpy = class_act_map ,
304+ numpy = current_label_soft_prediction ,
302305 )
303306 dataset_item .append_metadata_item (result_media , model = self ._task_environment .model )
304307
0 commit comments