attribute 模型名称错误
This commit is contained in:
@@ -10,6 +10,8 @@ from pymilvus import MilvusClient
|
||||
from app.core.config import *
|
||||
from torchvision import transforms
|
||||
|
||||
from app.service.utils.decorator import RunTime
|
||||
|
||||
|
||||
class SimilarMatch:
|
||||
def __init__(self):
|
||||
@@ -77,19 +79,20 @@ class SimilarMatch:
|
||||
features = results.as_numpy("output__1") # Shape (N, 64)
|
||||
return features
|
||||
|
||||
@RunTime
|
||||
def match_features(self, features):
|
||||
# 连接milvus
|
||||
# 连接milvus
|
||||
client = MilvusClient(uri="http://10.1.1.240:19530", db_name="mixi")
|
||||
try:
|
||||
res = client.search(
|
||||
search_response = client.search(
|
||||
collection_name="mixi_outfit", # Replace with the actual name of your collection
|
||||
# Replace with your query vector
|
||||
data=[features[0]],
|
||||
limit=5, # Max. number of search results to return
|
||||
output_fields=["id", "image_path"], # Search parameters
|
||||
)
|
||||
return res
|
||||
return search_response
|
||||
finally:
|
||||
client.close()
|
||||
|
||||
@@ -97,6 +100,6 @@ class SimilarMatch:
|
||||
if __name__ == '__main__':
|
||||
service = SimilarMatch()
|
||||
features = service.get_features(img_path="test/2024 SS/MKTS27000.jpg")
|
||||
res = service.match_features(features)
|
||||
search_response = service.match_features(features)
|
||||
|
||||
print(json.dumps(res, indent=4))
|
||||
print(json.dumps(search_response, indent=4))
|
||||
|
||||
Reference in New Issue
Block a user