fix 代码整理
This commit is contained in:
@@ -23,7 +23,6 @@ class Backbone(object):
|
||||
secure=MINIO_SECURE)
|
||||
|
||||
@RunTime
|
||||
# TODO 用多线程读图片
|
||||
def load_image(self, img_path):
|
||||
try:
|
||||
# 从 MinIO 中获取对象(图像文件)
|
||||
|
||||
@@ -55,33 +55,30 @@ class SimilarMatch:
|
||||
def preprocess(self, img_path):
|
||||
image = self.load_image(img_path)
|
||||
image = self.resize_image(image)
|
||||
image = np.stack([[image]], axis=0)
|
||||
image = np.stack([image], axis=0)
|
||||
|
||||
category = np.stack([[1, 6]], axis=0)
|
||||
# category = np.stack([[1, 6]], axis=0)
|
||||
|
||||
mask = np.zeros((1, 1), dtype=np.float32)
|
||||
return image, category, mask
|
||||
# mask = np.zeros((1, 1), dtype=np.float32)
|
||||
return image
|
||||
# , category, mask)
|
||||
|
||||
def get_features(self):
|
||||
image, category, mask = self.preprocess(self.image_path)
|
||||
image = self.preprocess(self.image_path)
|
||||
# image, category, mask = self.preprocess(self.image_path)
|
||||
# 输入集
|
||||
inputs = [
|
||||
httpclient.InferInput("input__0", image.shape, datatype="FP32"),
|
||||
httpclient.InferInput("input__1", category.shape, datatype="INT16"),
|
||||
httpclient.InferInput("input__2", mask.shape, datatype="FP32"),
|
||||
]
|
||||
inputs[0].set_data_from_numpy(image.astype(np.float32), binary_data=True)
|
||||
inputs[1].set_data_from_numpy(category.astype(np.int16), binary_data=True)
|
||||
inputs[2].set_data_from_numpy(mask.astype(np.float32), binary_data=True)
|
||||
# 输出集
|
||||
outputs = [
|
||||
httpclient.InferRequestedOutput("output__0", binary_data=True),
|
||||
httpclient.InferRequestedOutput("output__1", binary_data=True)
|
||||
]
|
||||
results = self.triton_client.infer(model_name="outfit_matcher_type_aware", inputs=inputs, outputs=outputs)
|
||||
results = self.triton_client.infer(model_name="outfit_matcher_backbone", inputs=inputs, outputs=outputs)
|
||||
# 推理
|
||||
# 取结果
|
||||
features = results.as_numpy("output__1") # Shape (N, 64)
|
||||
features = results.as_numpy("output__0") # Shape (N, 64)
|
||||
return features
|
||||
|
||||
@RunTime
|
||||
@@ -94,7 +91,7 @@ class SimilarMatch:
|
||||
# Replace with your query vector
|
||||
data=[self.features[0]],
|
||||
limit=self.result_number, # Max. number of search results to return
|
||||
output_fields=["id", "image_path"], # Search parameters
|
||||
output_fields=["item_name", "image_path"], # Search parameters
|
||||
)
|
||||
return search_response
|
||||
finally:
|
||||
|
||||
Reference in New Issue
Block a user