@@ -144,18 +144,19 @@ def on_predict(self):
144144 # Get the model and postprocessing settings.
145145 model_type = self .model_selector .currentText ()
146146 custom_model_path = self .checkpoint_param .text ()
147- if model_type == "- choose -" and custom_model_path is None :
147+ if model_type == "- choose -" :
148148 show_info ("INFO: Please choose a model." )
149149 return
150150
151151 device = get_device (self .device_dropdown .currentText ())
152152
153- # Load the model. Override if user chose custom model
153+ # Load the model. Override if user chose custom model.
154+ rescale_input = True
154155 if custom_model_path :
155156 model = _load_custom_model (custom_model_path , device )
157+ rescale_input = False
156158 if model :
157159 show_info (f"INFO: Using custom model from path: { custom_model_path } " )
158- model_type = "custom"
159160 else :
160161 show_info (f"ERROR: Failed to load custom model from path: { custom_model_path } " )
161162 return
@@ -177,22 +178,19 @@ def on_predict(self):
177178
178179 # Determine the scaling based on the voxel size.
179180 scale = None
180- if voxel_size :
181- if model_type == "custom" :
182- show_info ("INFO: The image is not rescaled for a custom model." )
183- else :
184- # calculate scale so voxel_size is the same as in training
185- scale = compute_scale_from_voxel_size (voxel_size , model_type )
186- scale_info = list (map (lambda x : np .round (x , 2 ), scale ))
187- show_info (f"INFO: Rescaled the image by { scale_info } to optimize for the selected model." )
181+ if voxel_size and rescale_input :
182+ # Calculate scale so voxel_size is the same as in training.
183+ scale = compute_scale_from_voxel_size (voxel_size , model_type )
184+ scale_info = list (map (lambda x : np .round (x , 2 ), scale ))
185+ show_info (f"INFO: Rescaled the image by { scale_info } to optimize for the selected model." )
188186
189187 # Some models require an additional segmentation for inference or postprocessing.
190188 # For these models we read out the 'Extra Segmentation' widget.
191189 if model_type == "ribbon" : # Currently only the ribbon model needs the extra seg.
192190 extra_seg = self ._get_layer_selector_data (self .extra_seg_selector_name )
193191 resolution = tuple (voxel_size [ax ] for ax in "zyx" )
194192 kwargs = {"extra_segmentation" : extra_seg , "resolution" : resolution , "min_membrane_size" : 50_000 }
195- elif model_type == "cristae" or model_type == "cristae2" or model_type == "cristae3" : # Cristae model expects 2 3D volumes
193+ elif model_type . startswith ( "cristae" ) : # Cristae model expects 2 3D volumes
196194 kwargs = {
197195 "extra_segmentation" : self ._get_layer_selector_data (self .extra_seg_selector_name ),
198196 "with_channels" : True ,
0 commit comments