Skip to content

Commit 5fc3ecd

Browse files
committed
update response with presigend url (parsed url)
1 parent 9405af9 commit 5fc3ecd

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

services/detected_service.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
from core.s3_utils import download_image, upload_image
77
import core.load_model as load_model
88
from schemas.common import ErrorCode
9+
from urllib.parse import urlparse, urlunparse
910

1011
async def detect_cloth(download_url:str, upload_urls:List[str]):
1112

@@ -60,7 +61,13 @@ async def worker(idx, img):
6061
*[worker(idx, item) for idx, item in enumerate(crop_items)],
6162
return_exceptions=True
6263
)
63-
uploaded_urls = [upload_urls[idx] for idx, r in enumerate(results) if r["success"]]
64+
uploaded_urls = []
65+
for idx, r in enumerate(results):
66+
if r["success"]:
67+
parsed = urlparse(upload_urls[idx])
68+
clean_url = urlunparse((parsed.scheme, parsed.netloc, parsed.path, '', '', ''))
69+
uploaded_urls.append(clean_url)
70+
6471
if not uploaded_urls:
6572
return {
6673
"success": False,

services/predict_services.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
from core.s3_utils import download_image, upload_image
99
import core.load_model as load_model
1010
from rembg import remove
11+
from urllib.parse import urlparse, urlunparse
1112
from core.config import CATEGORY_EN_TO_ID, CATEGORY_EN_TO_KO, SITUATION_EN_TO_ID, SITUATION_EN_TO_KO, STYLE_EN_TO_ID, STYLE_EN_TO_KO, SEASON_EN_TO_ID, SEASON_EN_TO_KO
1213

1314

@@ -57,7 +58,10 @@ async def classify_info_with_session(session: aiohttp.ClientSession, download_ur
5758
labels[name] = [{"id":CATEGORY_EN_TO_ID[texts[i]], "name":CATEGORY_EN_TO_KO[texts[i]]} for i in idx.squeeze(0).tolist()]
5859
if name == "seasons":
5960
labels[name] = [{"id":SEASON_EN_TO_ID[texts[i]], "name":SEASON_EN_TO_KO[texts[i]]} for i in idx.squeeze(0).tolist()]
60-
61+
62+
parsed = urlparse(upload_url)
63+
clean_url = urlunparse((parsed.scheme, parsed.netloc, parsed.path, '', '', ''))
64+
labels["uploaded_url"] = clean_url
6165
return {
6266
"isSuccess":True,
6367
"result": labels

0 commit comments

Comments
 (0)