From 4c075aea699daa00975a7e504839d5a28547670c Mon Sep 17 00:00:00 2001 From: TannedCung Date: Thu, 6 Jun 2024 13:15:42 +0700 Subject: [PATCH 1/3] Fix: empty accuracy requests --- cope2n-api/fwd_api/utils/accuracy.py | 1 - 1 file changed, 1 deletion(-) diff --git a/cope2n-api/fwd_api/utils/accuracy.py b/cope2n-api/fwd_api/utils/accuracy.py index ceced56..66bea04 100755 --- a/cope2n-api/fwd_api/utils/accuracy.py +++ b/cope2n-api/fwd_api/utils/accuracy.py @@ -847,7 +847,6 @@ def calculate_a_request(report, request): rv_avg_acc = avg_dict(att["acc"]["reviewed"]) image.is_required = fb_avg_acc < settings.BAD_THRESHOLD - image.is_reviewed = rv_avg_acc > 0 if image.processing_time < 0: continue From 25245aa770af1eecad61e5342e1b301cd7e8d13c Mon Sep 17 00:00:00 2001 From: TannedCung Date: Thu, 6 Jun 2024 14:08:10 +0700 Subject: [PATCH 2/3] 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, From e4b3d1079f2fdfb20e82ea80ab7dd88d89961084 Mon Sep 17 00:00:00 2001 From: TannedCung Date: Thu, 6 Jun 2024 14:10:38 +0700 Subject: [PATCH 3/3] Add: Try for filename exrtaction --- cope2n-ai-fi/api/sdsap_sbt/prediction_sbt.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) 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)