1.新增是否推理获取特征判断
2.取消搭配不足异常逻辑
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import logging
|
||||
import os
|
||||
import time
|
||||
from copy import deepcopy
|
||||
|
||||
@@ -36,20 +37,22 @@ def outfit_matcher(request_item: OutfitMatcher):
|
||||
# 查询数据库,分成两批 需要过模型推理的和不需要的
|
||||
have_features_data = []
|
||||
no_have_features_data = []
|
||||
for ai in all_items:
|
||||
|
||||
temp_data = deepcopy(all_items)
|
||||
for td in temp_data:
|
||||
for sd in search_data:
|
||||
if ai['item_name'] == sd['item_name']:
|
||||
ai['features'] = sd['features']
|
||||
if "features" not in ai.keys():
|
||||
no_have_features_data.append(ai)
|
||||
if td['item_name'] == sd['item_name']:
|
||||
td['features'] = sd['features']
|
||||
if "features" not in td.keys():
|
||||
no_have_features_data.append(td)
|
||||
else:
|
||||
have_features_data.append(ai)
|
||||
have_features_data.append(td)
|
||||
|
||||
if len(no_have_features_data) > 0:
|
||||
extracted_features = backbone_service.get_result(no_have_features_data)
|
||||
|
||||
# 准备数据
|
||||
data = deepcopy(all_items) # 做深拷贝 , all_items 是list 可变数组
|
||||
data = deepcopy(no_have_features_data) # 做深拷贝 , all_items 是list 可变数组
|
||||
for i, feature in enumerate(extracted_features):
|
||||
data[i]['features'] = feature
|
||||
if 'mapped_cate' in data[i].keys():
|
||||
@@ -68,17 +71,17 @@ def outfit_matcher(request_item: OutfitMatcher):
|
||||
result = []
|
||||
start_time = time.time()
|
||||
for item in request_item['query']:
|
||||
try:
|
||||
outfits = fashion_dataset.generate_outfit(item, request_item["topk"], request_item["max_outfits"])
|
||||
except ValueError as e:
|
||||
logger.warning(e)
|
||||
return {"code": 500, "message": f"valueError : {e}", "data": e}
|
||||
# try:
|
||||
outfits = fashion_dataset.generate_outfit(item, request_item["topk"], request_item["max_outfits"])
|
||||
# except ValueError as e:
|
||||
# logger.warning(e)
|
||||
# return {"code": 500, "message": f"valueError : {e}", "data": e}
|
||||
|
||||
scores = service.get_result(outfits, prepared_feature)
|
||||
|
||||
if request_item['is_best']:
|
||||
best_outfits, best_scores = service.visualize(outfits, scores, request_item["topk"], best=True,
|
||||
# output_path=os.path.join(r"E:\workspace\outfit_matcher\2024 SS Outfit", f"{item['item_name']}_best_{param['topk']}.png")
|
||||
# output_path=rf"E:\workspace\trinity_client_mixi\app\service\outfit_matcher\output_outfit\{item['item_name']}_best_{request_item['topk']}.png"
|
||||
)
|
||||
result.append({"outfits": best_outfits, "scores": best_scores})
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user