@@ -390,14 +390,28 @@ def initialize_model(self, **kwargs) -> None:
390390 """Initializes the ONNX model, setting up the inference session and other necessary properties."""
391391 logger .debug ("Getting model artefacts" )
392392 self .get_model_artifacts (** kwargs )
393- if self .environment .get ("RESOLUTION" ) >= RFDETR_ONNX_MAX_RESOLUTION :
393+
394+ input_resolution = self .environment .get ("RESOLUTION" )
395+ if input_resolution is None :
396+ input_resolution = self .preproc .get ("resize" , {}).get ("width" )
397+ if isinstance (input_resolution , (list , tuple )):
398+ input_resolution = input_resolution [0 ]
399+ try :
400+ input_resolution = int (input_resolution )
401+ except (TypeError , ValueError ):
402+ input_resolution = None
403+ if (
404+ input_resolution is not None
405+ and input_resolution >= RFDETR_ONNX_MAX_RESOLUTION
406+ ):
394407 logger .error (
395408 "NOT loading '%s' model, input resolution is '%s', ONNX max resolution limit set to '%s'" ,
396409 self .endpoint ,
397- self . environment . get ( "RESOLUTION" ) ,
410+ input_resolution ,
398411 RFDETR_ONNX_MAX_RESOLUTION ,
399412 )
400413 raise CannotInitialiseModelError (f"Resolution too high for RFDETR" )
414+
401415 logger .debug ("Creating inference session" )
402416 if self .load_weights or not self .has_model_metadata :
403417 t1_session = perf_counter ()
0 commit comments