Merge pull request #132 from SDSRV-IDP/BE/review_page

Be/review page
This commit is contained in:
Lê Hà Phan 2024-06-06 14:11:35 +07:00 committed by GitHub Enterprise
commit 57bceea5a9
2 changed files with 10 additions and 2 deletions

View File

@ -4,6 +4,7 @@ import urllib
import random import random
import numpy as np import numpy as np
from pathlib import Path from pathlib import Path
import urllib.parse
import uuid import uuid
from copy import deepcopy from copy import deepcopy
import sys, os import sys, os
@ -33,10 +34,18 @@ def sbt_predict(image_url, engine, metadata={}) -> None:
img = cv2.imdecode(arr, -1) img = cv2.imdecode(arr, -1)
save_dir = "./tmp_results" save_dir = "./tmp_results"
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) os.makedirs(save_dir, exist_ok=True)
# image_path = os.path.join(save_dir, f"{image_url}.jpg") # image_path = os.path.join(save_dir, f"{image_url}.jpg")
os.makedirs(save_dir, exist_ok = True) 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) cv2.imwrite(tmp_image_path, img)
extra_params = {'sub': metadata.get("subsidiary", None)} # example of 'AU' extra_params = {'sub': metadata.get("subsidiary", None)} # example of 'AU'
outputs = process_img(img=tmp_image_path, outputs = process_img(img=tmp_image_path,

View File

@ -847,7 +847,6 @@ def calculate_a_request(report, request):
rv_avg_acc = avg_dict(att["acc"]["reviewed"]) rv_avg_acc = avg_dict(att["acc"]["reviewed"])
image.is_required = fb_avg_acc < settings.BAD_THRESHOLD image.is_required = fb_avg_acc < settings.BAD_THRESHOLD
image.is_reviewed = rv_avg_acc > 0
if image.processing_time < 0: if image.processing_time < 0:
continue continue