attribute 模型名称错误

This commit is contained in:
zhouchengrong
2024-03-27 13:17:41 +08:00
parent 5f5617d5a3
commit d4be7b8053
14 changed files with 897 additions and 13 deletions

View File

@@ -0,0 +1,110 @@
import cv2
import mmcv
import numpy as np
import tritonclient.http as httpclient
import torch
def preprocess(img):
img = mmcv.imread(img)
ori_shape = img.shape[:2]
img_scale = (224, 224)
scale_factor = []
img, x, y = mmcv.imresize(img, img_scale, return_scale=True)
scale_factor.append(x)
scale_factor.append(y)
img = mmcv.imnormalize(img, mean=np.array([123.675, 116.28, 103.53]), std=np.array([58.395, 57.12, 57.375]), to_rgb=True)
preprocessed_img = np.expand_dims(img.transpose(2, 0, 1), axis=0)
return preprocessed_img, ori_shape
def get_attribute(model_save_name, sample):
triton_client = httpclient.InferenceServerClient(url=f"10.1.1.240:10020")
inputs = [
httpclient.InferInput("input__0", sample.shape, datatype="FP32")
]
inputs[0].set_data_from_numpy(sample, binary_data=True)
results = triton_client.infer(model_name=model_save_name, inputs=inputs)
inference_output = torch.from_numpy(results.as_numpy(f"output__0"))
scores = inference_output.detach().numpy()
print(f"{model} is ok")
image, shape = preprocess(cv2.imread("8365b04b-69d0-4f6d-a61b-a8cc136256263422b10ff45d4ae4e10be3fc25a9c36b.jpg"))
# get_attribute("attr_retrieve_D_sleeve_shape", image)
model_list = ['top_length',
'top_type',
'top_Sleeve_length',
'top_Sleeve_shape',
'top_Sleeve_shoulder',
'top_Neckline',
'top_print',
'top_material',
'top_Softness',
'top_Design',
'top_optype',
'top_Silhouette',
'top_Collar',
'bottom_sub-Type',
'bottom_length',
'bottom_print',
'bottom_material',
'bottom_Softness_B',
'bottom_Silhouette_B',
'bottom_OPType_B',
'bottom_design',
'outwear_outer_length',
# 'outwear_2_outer_type',
'outwear_outer_sleeve_length',
'outwear_outer_sleeve_shape',
'outwear_outer_sleeve_shoulder',
'outwear_outer_collar',
'outwear_print',
'outwear_material',
'outwear_outer_softness',
'outwear_outer_design',
# 'outwear_11_outer_opening',
'outwear_outer_optype',
'outwear_outer_silhouette',
'jumpsuit_length',
'jumpsuit_sleeve_length',
'jumpsuit_sleeve_shape',
'jumpsuit_sleeve_shoulder',
'jumpsuit_neckline',
'jumpsuit_collar',
'jumpsuit_print',
'jumpsuit_material',
'jumpsuit_softness',
'jumpsuit_design',
'jumpsuit_optype',
'jumpsuit_subtype',
'dress_length',
'dress_sleeve_length',
'dress_sleeve_shape',
'dress_sleeve_shoulder',
'dress_neckline',
'dress_print',
'dress_collar',
'dress_material',
'dress_design',
'dress_softness',
'dress_silohouette12',
# 'dress_'
'dress_type'
]
except_model = []
# 'attr_recong_B_optype', 'attr_recong_D_length', 'attr_recong_O_length', 'attr_recong_O_optype', 'attr_recong_material',
# 'attr_recong_print', 'attr_retrieve_D_collar', 'attr_retrieve_D_design', 'attr_retrieve_D_neckline', 'attr_retrieve_D_silohouette',
# 'attr_retrieve_D_sleeve_shape', 'attr_retrieve_D_sleeve_shoulder', 'attr_retrieve_D_type', 'attr_retrieve_T_length', 'attr_retrieve_T_optype'
# for model in model_list:
# get_attribute(model, image)
for model in model_list:
try:
get_attribute(model, image)
except Exception as e:
print(e)
except_model.append(model)
print(except_model)

56
test/attribute/model.py Normal file
View File

@@ -0,0 +1,56 @@
var = ["bottom_OPType_B",
"bottom_Silhouette_B",
"bottom_Softness_B",
"bottom_design",
"bottom_length",
"bottom_material",
"bottom_print",
"bottom_sub-Type",
"category",
"dress_collar",
"dress_design",
"dress_length",
"dress_material",
"dress_neckline",
"dress_print",
"dress_silohouette2",
"dress_sleeve_length",
"dress_sleeve_shape",
"dress_sleeve_shoulder",
"dress_softness",
"dress_type",
"jumpsuit_collar",
"jumpsuit_design",
"jumpsuit_length",
"jumpsuit_material",
"jumpsuit_optype",
"jumpsuit_print",
"jumpsuit_sleeve_length",
"jumpsuit_sleeve_shape",
"jumpsuit_sleeve_shoulder",
"jumpsuit_softness",
"jumpsuit_subtype",
"outwear_material",
"outwear_outear_length",
"outwear_outer_collar",
"outwear_outer_design",
"outwear_outer_optype",
"outwear_outer_silhouette",
"outwear_outer_sleeve_length",
"outwear_outer_sleeve_shape",
"outwear_outer_sleeve_shoulder",
"outwear_outer_softness",
"outwear_print",
"top_Collar",
"top_Design",
"top_Neckline",
"top_Silhouette",
"top_Sleeve_length",
"top_Sleeve_shape",
"top_Sleeve_shoulder",
"top_Softness",
"top_length",
"top_material",
"top_optype",
"top_print",
"top_type", ]

View File

@@ -0,0 +1,51 @@
from pprint import pprint
import cv2
import mmcv
import numpy as np
import tritonclient.http as httpclient
import torch
from app.core.config import ATT_TRITON_PORT, ATT_TRITON_IP
model_list = ['bottom_design', 'bottom_length', 'bottom_material', 'bottom_OPType_B', 'bottom_print', 'bottom_Silhouette_B', 'bottom_Softness_B', 'bottom_sub-Type', 'category', 'dress_collar', 'dress_design', 'dress_length', 'dress_material', 'dress_neckline', 'dress_print', 'dress_silohouette12', 'dress_sleeve_length', 'dress_sleeve_shape', 'dress_sleeve_shoulder', 'dress_softness', 'dress_type', 'jumpsuit_collar', 'jumpsuit_design', 'jumpsuit_length', 'jumpsuit_material', 'jumpsuit_optype',
'jumpsuit_print', 'jumpsuit_sleeve_length', 'jumpsuit_sleeve_shape', 'jumpsuit_sleeve_shoulder', 'jumpsuit_softness', 'jumpsuit_subtype', 'outwear_material', 'outwear_outear_length', 'outwear_outer_collar', 'outwear_outer_design', 'outwear_outer_optype', 'outwear_outer_silhouette', 'outwear_outer_sleeve_length', 'outwear_outer_sleeve_shape', 'outwear_outer_sleeve_shoulder', 'outwear_outer_softness', 'outwear_print', 'top_Collar', 'top_Design', 'top_length', 'top_material',
'top_Neckline', 'top_optype', 'top_print', 'top_Silhouette', 'top_Sleeve_length', 'top_Sleeve_shape', 'top_Sleeve_shoulder', 'top_Softness', 'top_type']
def preprocess(img):
img = mmcv.imread(img)
ori_shape = img.shape[:2]
img_scale = (224, 224)
scale_factor = []
img, x, y = mmcv.imresize(img, img_scale, return_scale=True)
scale_factor.append(x)
scale_factor.append(y)
img = mmcv.imnormalize(img, mean=np.array([123.675, 116.28, 103.53]), std=np.array([58.395, 57.12, 57.375]), to_rgb=True)
preprocessed_img = np.expand_dims(img.transpose(2, 0, 1), axis=0)
return preprocessed_img, ori_shape
def get_attribute(model_save_name, sample):
triton_client = httpclient.InferenceServerClient(url=f"{ATT_TRITON_IP}:{ATT_TRITON_PORT}")
inputs = [
httpclient.InferInput("input__0", sample.shape, datatype="FP32")
]
inputs[0].set_data_from_numpy(sample, binary_data=True)
results = triton_client.infer(model_name=model_save_name, inputs=inputs)
inference_output = torch.from_numpy(results.as_numpy(f"output__0"))
scores = inference_output.detach().numpy()
pprint(scores)
print(f"{model_save_name} is ok")
image, shape = preprocess(cv2.imread("test_top1.jpg"))
except_model = []
for model in model_list:
try:
get_attribute(model, image)
except Exception as e:
print(e)
except_model.append(model)
print(except_model)

View File

@@ -0,0 +1,273 @@
a = [{'best_outfits': [({'image_path': 'test/2024 SS/MKTS27047.jpg',
'item_name': 'MKTS27047',
'mapped_cate': 'all-body',
'semantic_category': 'ONE PIECE/DRESS'},
{'image_path': 'test/2024 SS/MLSS27156.jpg',
'item_name': 'MLSS27156',
'mapped_cate': 'outerwear',
'semantic_category': 'TOP/VEST'}),
({'image_path': 'test/2024 SS/MKTS27047.jpg',
'item_name': 'MKTS27047',
'mapped_cate': 'all-body',
'semantic_category': 'ONE PIECE/DRESS'},
{'image_path': 'test/2024 SS/MLSS27157.jpg',
'item_name': 'MLSS27157',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/WINDBREAKER'}),
({'image_path': 'test/2024 SS/MKTS27047.jpg',
'item_name': 'MKTS27047',
'mapped_cate': 'all-body',
'semantic_category': 'ONE PIECE/DRESS'},
{'image_path': 'test/2024 SS/MLSS27150.jpg',
'item_name': 'MLSS27150',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/JACKET'}),
({'image_path': 'test/2024 SS/MKTS27047.jpg',
'item_name': 'MKTS27047',
'mapped_cate': 'all-body',
'semantic_category': 'ONE PIECE/DRESS'},
{'image_path': 'test/2024 SS/MSE_56720.jpg',
'item_name': 'MSE_56720',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/BLAZER'}),
({'image_path': 'test/2024 SS/MKTS27047.jpg',
'item_name': 'MKTS27047',
'mapped_cate': 'all-body',
'semantic_category': 'ONE PIECE/DRESS'},
{'image_path': 'test/2024 SS/MLSS27109.jpg',
'item_name': 'MLSS27109',
'mapped_cate': 'outerwear',
'semantic_category': 'JEANS/JEANS JACKET'})],
'best_scores': [-0.111208215,
-0.120505564,
-0.1213615,
-0.12190802,
-0.12419219]},
{'best_outfits': [({'image_path': 'test/2024 SS/MKTS27028.jpg',
'item_name': 'MKTS27028',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/JACKET'},
{'image_path': 'test/2024 SS/MSE_58107.jpg',
'item_name': 'MSE_58107',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27133.jpg',
'item_name': 'MLSS27133',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/SKIRT'}),
({'image_path': 'test/2024 SS/MKTS27028.jpg',
'item_name': 'MKTS27028',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/JACKET'},
{'image_path': 'test/2024 SS/MLSS27132.jpg',
'item_name': 'MLSS27132',
'mapped_cate': 'tops',
'semantic_category': 'TOP/TOP'},
{'image_path': 'test/2024 SS/MLSS27159.jpg',
'item_name': 'MLSS27159',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'}),
({'image_path': 'test/2024 SS/MKTS27028.jpg',
'item_name': 'MKTS27028',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/JACKET'},
{'image_path': 'test/2024 SS/MLSS27132.jpg',
'item_name': 'MLSS27132',
'mapped_cate': 'tops',
'semantic_category': 'TOP/TOP'},
{'image_path': 'test/2024 SS/MLSS27133.jpg',
'item_name': 'MLSS27133',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/SKIRT'}),
({'image_path': 'test/2024 SS/MKTS27028.jpg',
'item_name': 'MKTS27028',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/JACKET'},
{'image_path': 'test/2024 SS/MKTS27039.jpg',
'item_name': 'MKTS27039',
'mapped_cate': 'tops',
'semantic_category': 'TOP/TOP'},
{'image_path': 'test/2024 SS/MLSS27226.jpg',
'item_name': 'MLSS27226',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/SKIRT'}),
({'image_path': 'test/2024 SS/MKTS27028.jpg',
'item_name': 'MKTS27028',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/JACKET'},
{'image_path': 'test/2024 SS/MLSS27146.jpg',
'item_name': 'MLSS27146',
'mapped_cate': 'tops',
'semantic_category': 'TOP/TOP'},
{'image_path': 'test/2024 SS/MSE_58518.jpg',
'item_name': 'MSE_58518',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/SKIRT'})],
'best_scores': [-0.111208215,
-0.11449928,
-0.11642833,
-0.120505564,
-0.1213615]},
{'best_outfits': [({'image_path': 'test/2024 SS/MSE_58057.jpg',
'item_name': 'MSE_58057',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/BLAZER'},
{'image_path': 'test/2024 SS/MKTS27046.jpg',
'item_name': 'MKTS27046',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MSE_58518.jpg',
'item_name': 'MSE_58518',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/SKIRT'}),
({'image_path': 'test/2024 SS/MSE_58057.jpg',
'item_name': 'MSE_58057',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/BLAZER'},
{'image_path': 'test/2024 SS/MSE_58473.jpg',
'item_name': 'MSE_58473',
'mapped_cate': 'tops',
'semantic_category': 'KNIT/KNIT TOP'},
{'image_path': 'test/2024 SS/MKTS27031.jpg',
'item_name': 'MKTS27031',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/SKIRT'}),
({'image_path': 'test/2024 SS/MSE_58057.jpg',
'item_name': 'MSE_58057',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/BLAZER'},
{'image_path': 'test/2024 SS/MPO_SP7687.jpg',
'item_name': 'MPO_SP7687',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27107.jpg',
'item_name': 'MLSS27107',
'mapped_cate': 'bottoms',
'semantic_category': 'JEANS/JEANS'}),
({'image_path': 'test/2024 SS/MSE_58057.jpg',
'item_name': 'MSE_58057',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/BLAZER'},
{'image_path': 'test/2024 SS/MLSS27142.jpg',
'item_name': 'MLSS27142',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27159.jpg',
'item_name': 'MLSS27159',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'}),
({'image_path': 'test/2024 SS/MSE_58057.jpg',
'item_name': 'MSE_58057',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/BLAZER'},
{'image_path': 'test/2024 SS/MLSS27142.jpg',
'item_name': 'MLSS27142',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27226.jpg',
'item_name': 'MLSS27226',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/SKIRT'})],
'best_scores': [-0.111208215,
-0.11449928,
-0.11642833,
-0.120505564,
-0.1213615]},
{'best_outfits': [({'image_path': 'test/2024 SS/MSE_58107.jpg',
'item_name': 'MSE_58107',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27159.jpg',
'item_name': 'MLSS27159',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'},
{'image_path': 'test/2024 SS/MSE_58289.jpg',
'item_name': 'MSE_58289',
'mapped_cate': 'outerwear',
'semantic_category': 'OUTERWEAR/BLAZER'}),
({'image_path': 'test/2024 SS/MSE_58107.jpg',
'item_name': 'MSE_58107',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27111.jpg',
'item_name': 'MLSS27111',
'mapped_cate': 'bottoms',
'semantic_category': 'JEANS/JEANS PANTS'}),
({'image_path': 'test/2024 SS/MSE_58107.jpg',
'item_name': 'MSE_58107',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27104.jpg',
'item_name': 'MLSS27104',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/SHORTS'}),
({'image_path': 'test/2024 SS/MSE_58107.jpg',
'item_name': 'MSE_58107',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27159.jpg',
'item_name': 'MLSS27159',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'}),
({'image_path': 'test/2024 SS/MSE_58107.jpg',
'item_name': 'MSE_58107',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27160.jpg',
'item_name': 'MLSS27160',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'})],
'best_scores': [-0.111208215,
-0.11449928,
-0.120505564,
-0.1213615,
-0.12190802]},
{'best_outfits': [({'image_path': 'test/2024 SS/MSE_58495.jpg',
'item_name': 'MSE_58495',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27159.jpg',
'item_name': 'MLSS27159',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'}),
({'image_path': 'test/2024 SS/MSE_58495.jpg',
'item_name': 'MSE_58495',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27160.jpg',
'item_name': 'MLSS27160',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'}),
({'image_path': 'test/2024 SS/MSE_58495.jpg',
'item_name': 'MSE_58495',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27159.jpg',
'item_name': 'MLSS27159',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'},
{'image_path': 'test/2024 SS/MLSS27109.jpg',
'item_name': 'MLSS27109',
'mapped_cate': 'outerwear',
'semantic_category': 'JEANS/JEANS JACKET'}),
({'image_path': 'test/2024 SS/MSE_58495.jpg',
'item_name': 'MSE_58495',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MLSS27119.jpg',
'item_name': 'MLSS27119',
'mapped_cate': 'bottoms',
'semantic_category': 'JEANS/JEANS SKIRT'}),
({'image_path': 'test/2024 SS/MSE_58495.jpg',
'item_name': 'MSE_58495',
'mapped_cate': 'tops',
'semantic_category': 'TOP/SHIRT'},
{'image_path': 'test/2024 SS/MKTS27000.jpg',
'item_name': 'MKTS27000',
'mapped_cate': 'bottoms',
'semantic_category': 'BOTTOM/PANTS'})],
'best_scores': [-0.111208215,
-0.11449928,
-0.120505564,
-0.1213615,
-0.12190802]}]

View File

@@ -0,0 +1,12 @@
from minio import Minio
from app.core.config import MINIO_PORT, MINIO_IP, MINIO_ACCESS, MINIO_SECRET, MINIO_SECURE
minio_client = Minio(
f"{MINIO_IP}:{MINIO_PORT}",
access_key=MINIO_ACCESS,
secret_key=MINIO_SECRET,
secure=MINIO_SECURE)
for i in minio_client.list_objects('test'):
print(i.object_name)

View File