From 25245aa770af1eecad61e5342e1b301cd7e8d13c Mon Sep 17 00:00:00 2001 From: TannedCung Date: Thu, 6 Jun 2024 14:08:10 +0700 Subject: [PATCH] Fix: logging file name for AI service --- cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py b/cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py index 3a4bed3..c004dd0 100755 --- a/cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py +++ b/cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py @@ -4,6 +4,7 @@ import urllib import random import numpy as np from pathlib import Path +import urllib.parse import uuid from copy import deepcopy import sys, os @@ -33,10 +34,13 @@ 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] 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) - tmp_image_path = os.path.join(save_dir, f"{uuid.uuid4()}.jpg") + tmp_image_path = os.path.join(save_dir, file_name) cv2.imwrite(tmp_image_path, img) extra_params = {'sub': metadata.get("subsidiary", None)} # example of 'AU' outputs = process_img(img=tmp_image_path,