Skip to content

Commit 9405af9

Browse files
committed
update results content to ko and id
1 parent e2fce5e commit 9405af9

5 files changed

Lines changed: 141 additions & 13 deletions

File tree

core/config.py

Lines changed: 127 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
CLOTH_LABELS = {
77
"categories" : [
8-
"t-shirt", "short sleeve shirt or blouse", "long sleeve shirt or blouse", "knitwear or sweater",
8+
"t-shirt", "shirt or blouse", "knitwear or sweater", "hoodie",
99
"sweatshirt", "short sleeve t-shirt", "tank top", "denim pants or jeans", "half pants", "jogger pants",
1010
"cotton pants", "slacks", "leggings", "mini skirt", "midi skirt", "long skirt", "onepiece dress",
1111
"short padding", "sheepskin jacket", "zip-up hoodie", "windbreak", "leather jacket", "denim jacket",
@@ -14,10 +14,133 @@
1414
"crossbody bag", "shoulder bag", "backpack", "tote bag", "eco bag",
1515
"hat", "scarf", "socks", "wristwatch", "ring or necklace or jewelry", "belt", "glasses"
1616
],
17-
"colors" : ["white", "black", "blue", "red", "green", "beige", "gray", "brown", "navy", "yellow", "pink", "purple"],
1817
"seasons" : ["spring", "summer", "autumn", "winter"],
1918
}
2019
RECORD_LABELS = {
21-
"styles" : ["casual", "street", "minimal", "classic", "chic", "vintage", "formal", "sporty", "retro", "office", "outdoor"],
22-
"situations" : ["daily", "travel", "date", "party", "work", "exercise"]
20+
"styles" : ["casual", "street", "minimal", "classic", "chic", "vintage", "girlish", "sporty", "lovely", "office look", "highteen"],
21+
"situations" : ["daily", "travel", "date", "party", "work", "exercise", "festival"]
22+
}
23+
24+
STYLE_EN_TO_ID = {
25+
"casual": 1,
26+
"street": 2,
27+
"minimal": 3,
28+
"classic": 4,
29+
"chic": 5,
30+
"vintage": 6,
31+
"girlish": 7,
32+
"sporty": 8,
33+
"lovely": 9,
34+
"office look": 10,
35+
"highteen": 11
36+
}
37+
38+
STYLE_EN_TO_KO = {
39+
"casual": "캐주얼",
40+
"street": "스트릿",
41+
"minimal": "미니멀",
42+
"classic": "클래식",
43+
"chic": "시크",
44+
"vintage": "빈티지",
45+
"girlish": "걸리시",
46+
"sporty": "스포티",
47+
"lovely": "러블리",
48+
"office look": "오피스룩",
49+
"highteen": "하이틴"
50+
}
51+
52+
SITUATION_EN_TO_ID = {
53+
"daily": 1,
54+
"travel": 2,
55+
"date": 3,
56+
"party": 4,
57+
"work": 5,
58+
"exercise": 6,
59+
"festival": 7
60+
}
61+
62+
SITUATION_EN_TO_KO = {
63+
"daily": "데일리",
64+
"travel": "여행",
65+
"date": "데이트",
66+
"party": "파티",
67+
"work": "출근룩",
68+
"exercise": "운동",
69+
"festival": "축제"
70+
}
71+
72+
73+
CATEGORY_EN_TO_ID = {
74+
"t-shirt":8,
75+
"shirt or blouse":12, "knitwear or sweater":9, "hoodie":11,
76+
"sweatshirt":10, "short sleeve t-shirt":13, "tank top":14, "denim pants or jeans":16, "half pants":17, "jogger pants":18,
77+
"cotton pants":19, "slacks":20, "leggings":21, "mini skirt":23, "midi skirt":24, "long skirt":25, "onepiece dress":26,
78+
"short padding":29, "sheepskin jacket":30, "zip-up hoodie":31, "windbreak":32, "leather jacket":33, "denim jacket":34,
79+
"blazer":35, "cardigan":36, "anorak":37, "fleece":38, "coat":39, "long padding":40, "padding vest":41,
80+
"sneakers":43, "boots":44, "dress shoes":45, "sandal or slipper":46,
81+
"crossbody bag":48, "shoulder bag":49, "backpack":50, "tote bag":51, "eco bag":52,
82+
"hat":54, "scarf":55, "socks":56, "wristwatch":57, "ring or necklace or jewelry":58, "belt":59, "glasses":60
83+
}
84+
85+
CATEGORY_EN_TO_KO = {
86+
"t-shirt": "티셔츠",
87+
"shirt or blouse": "셔츠/블라우스",
88+
"knitwear or sweater": "니트/스웨터",
89+
"hoodie": "후드티",
90+
"sweatshirt": "맨투맨",
91+
"short sleeve t-shirt": "반팔티",
92+
"tank top": "나시",
93+
"denim pants or jeans": "청바지",
94+
"half pants": "반바지",
95+
"jogger pants": "트레이닝/조거팬츠",
96+
"cotton pants": "면바지",
97+
"slacks": "슈트팬츠/슬랙스",
98+
"leggings": "레깅스",
99+
"mini skirt": "미니스커트",
100+
"midi skirt": "미디스커트",
101+
"long skirt": "롱스커트",
102+
"onepiece dress": "원피스",
103+
"short padding": "숏패딩/헤비 아우터",
104+
"sheepskin jacket": "무스탕/퍼",
105+
"zip-up hoodie": "후드집업",
106+
"windbreak": "점퍼/바람막이",
107+
"leather jacket": "가죽자켓",
108+
"denim jacket": "청자켓",
109+
"blazer": "슈트/블레이저",
110+
"cardigan": "가디건",
111+
"anorak": "아노락",
112+
"fleece": "후리스/양털",
113+
"coat": "코트",
114+
"long padding": "롱패딩",
115+
"padding vest": "패딩조끼",
116+
"sneakers": "스니커즈",
117+
"boots": "부츠/워커",
118+
"dress shoes": "구두",
119+
"sandal or slipper": "샌들/슬리퍼",
120+
"crossbody bag": "메신저/크로스백",
121+
"shoulder bag": "숄더백",
122+
"backpack": "백팩",
123+
"tote bag": "토트백",
124+
"eco bag": "에코백",
125+
"hat": "모자",
126+
"scarf": "머플러",
127+
"socks": "양말/레그웨어",
128+
"wristwatch": "시계",
129+
"ring or necklace or jewelry": "주얼리",
130+
"belt": "벨트",
131+
"glasses": "선글라스/안경"
132+
}
133+
134+
SEASON_EN_TO_ID = {
135+
"spring":1,
136+
"summer":2,
137+
"autumn":3,
138+
"winter":4
139+
}
140+
141+
SEASON_EN_TO_KO = {
142+
"spring":"봄",
143+
"summer":"여름",
144+
"autumn":"가을",
145+
"winter":"겨울"
23146
}

core/load_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020

2121
# 함수 모드에 따른 임베딩 키 설정
2222
EMBEDS_CONFIG_KEYS = {
23-
"cloth-plus": ["CATEGORIES", "COLORS", "SEASONS"],
23+
"cloth-plus": ["CATEGORIES", "SEASONS"],
2424
"record-plus": ["STYLES", "SITUATIONS"],
2525
}
2626

core/s3_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,12 @@ async def upload_image(session: aiohttp.ClientSession, url: str, image_bytes: by
3333
"error_code": ErrorCode.INVALID_REQUEST
3434
}
3535
request = session.put if method == "PUT" else session.post
36-
async with request(url, data=image_bytes) as response:
36+
async with request(url, data=image_bytes, headers={"Content-Type": "image/jpeg"}) as response:
3737
if response.status in (200, 204):
3838
return {"success": True}
3939
return {
4040
"success": False,
4141
"error_code": ErrorCode.S3_UPLOAD_FAILED,
42-
"http_status": response.status
4342
}
4443
except Exception as e:
4544
return {

services/detected_service.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,8 +60,8 @@ async def worker(idx, img):
6060
*[worker(idx, item) for idx, item in enumerate(crop_items)],
6161
return_exceptions=True
6262
)
63-
uploaded_idxs = [idx for idx, r in enumerate(results) if r["success"]]
64-
if not uploaded_idxs:
63+
uploaded_urls = [upload_urls[idx] for idx, r in enumerate(results) if r["success"]]
64+
if not uploaded_urls:
6565
return {
6666
"success": False,
6767
"error_code": ErrorCode.DETECT_BUT_UPLOAD_FAILED
@@ -71,7 +71,7 @@ async def worker(idx, img):
7171
"success": True,
7272
"result": {
7373
"detected_cnt": len(crop_items),
74-
"uploaded_cnt": len(uploaded_idxs),
75-
"uploaded_idxs": uploaded_idxs
74+
"uploaded_cnt": len(uploaded_urls),
75+
"uploaded_urls": uploaded_urls
7676
}
7777
}

services/predict_services.py

Lines changed: 8 additions & 2 deletions
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 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
1112

1213

1314
# 정보 분류 함수 구현
@@ -48,10 +49,14 @@ async def classify_info_with_session(session: aiohttp.ClientSession, download_ur
4849
logit_scale = load_model.GLOBAL_MODEL.logit_scale.exp()
4950

5051
labels = {}
52+
5153
for name, (embeds, texts) in embed_dict.items():
5254
logits = logit_scale * img_feats @ embeds.T
5355
_, idx = logits.topk(top_k, dim=-1)
54-
labels[name] = [texts[i] for i in idx.squeeze(0).tolist()]
56+
if name == "categories":
57+
labels[name] = [{"id":CATEGORY_EN_TO_ID[texts[i]], "name":CATEGORY_EN_TO_KO[texts[i]]} for i in idx.squeeze(0).tolist()]
58+
if name == "seasons":
59+
labels[name] = [{"id":SEASON_EN_TO_ID[texts[i]], "name":SEASON_EN_TO_KO[texts[i]]} for i in idx.squeeze(0).tolist()]
5560

5661
return {
5762
"isSuccess":True,
@@ -114,9 +119,10 @@ async def classify_style_with_session(session: aiohttp.ClientSession, download_u
114119
logits = logit_scale * img_feats @ embeds.T
115120
if name == "situations":
116121
_, idx = logits.topk(1, dim=-1)
122+
labels[name] = [{"id":SITUATION_EN_TO_ID[texts[i]], "name":SITUATION_EN_TO_KO[texts[i]]} for i in idx.squeeze(0).tolist()]
117123
else:
118124
_, idx = logits.topk(top_k, dim=-1)
119-
labels[name] = [texts[i] for i in idx.squeeze(0).tolist()]
125+
labels[name] = [{"id":STYLE_EN_TO_ID[texts[i]], "name":STYLE_EN_TO_KO[texts[i]]} for i in idx.squeeze(0).tolist()]
120126

121127
return {
122128
"isSuccess":True,

0 commit comments

Comments
 (0)