@@ -86,6 +86,8 @@ def __init__(
8686 self .runtime = self .settings .gui_runtime
8787 self .use_gpu = self .settings .gui_use_gpu
8888 self .gpu_index = self .settings .gui_gpu_index
89+ config_default : BabbleConfig = BabbleConfig ()
90+ self .default_model = config_default .settings .gui_model_file
8991 self .output = []
9092 self .val_list = []
9193 self .calibrate_config = np .empty ((1 , 45 ))
@@ -103,12 +105,24 @@ def __init__(
103105 provider = "DmlExecutionProvider"
104106 else :
105107 provider = "CPUExecutionProvider" # Build onnxruntime to get both DML and OpenVINO
106- self .sess = ort .InferenceSession (
107- f"{ self .model } onnx/model.onnx" ,
108- self .opts ,
109- providers = [provider ],
110- provider_options = [{"device_id" : self .gpu_index }],
111- )
108+ try :
109+ self .sess = ort .InferenceSession (
110+ f"{ self .model } /onnx/model.onnx" ,
111+ self .opts ,
112+ providers = [provider ],
113+ provider_options = [{"device_id" : self .gpu_index }],
114+ )
115+ except : # Load default model if we can't find the specified model
116+ print (
117+ f'\033 [91m[{ lang ._instance .get_string ("log.error" )} ] { lang ._instance .get_string ("error.modelLoad" )} { self .model } \033 [0m'
118+ )
119+ print (f'\033 [91mLoading Default model: { self .default_model } .\033 [0m' )
120+ self .sess = ort .InferenceSession (
121+ f"{ self .default_model } /onnx/model.onnx" ,
122+ self .opts ,
123+ providers = [provider ],
124+ provider_options = [{"device_id" : self .gpu_index }],
125+ )
112126 self .input_name = self .sess .get_inputs ()[0 ].name
113127 self .output_name = self .sess .get_outputs ()[0 ].name
114128 try :
0 commit comments