diff --git a/cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py b/cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py index c004dd0..a59a653 100755 --- a/cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py +++ b/cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py @@ -34,9 +34,14 @@ def sbt_predict(image_url, engine, metadata={}) -> None: img = cv2.imdecode(arr, -1) save_dir = "./tmp_results" - parsed_url = urllib.parse.urlparse(image_url) - query_params = urllib.parse.parse_qs(parsed_url.query) - file_name = query_params['file_name'][0] + try: + + parsed_url = urllib.parse.urlparse(image_url) + query_params = urllib.parse.parse_qs(parsed_url.query) + file_name = query_params['file_name'][0] + except Exception as e: + print(f"[ERROR]: Error extracting file name from url: {image_url}") + file_name = f"{uuid.uuid4()}.jpg" os.makedirs(save_dir, exist_ok=True) # image_path = os.path.join(save_dir, f"{image_url}.jpg") os.makedirs(save_dir, exist_ok = True)