feat 更新响应模板
fix
This commit is contained in:
@@ -23,11 +23,11 @@ DEBUG = False
|
|||||||
if DEBUG:
|
if DEBUG:
|
||||||
LOGS_PATH = "logs/"
|
LOGS_PATH = "logs/"
|
||||||
CATEGORY_PATH = "service/attribute/config/descriptor/category/category_dis.csv"
|
CATEGORY_PATH = "service/attribute/config/descriptor/category/category_dis.csv"
|
||||||
FACE_CLASSIFIER = "service/generate_image/utils/haarcascade_frontalface_alt.xml"
|
# FACE_CLASSIFIER = "service/generate_image/utils/haarcascade_frontalface_alt.xml"
|
||||||
else:
|
else:
|
||||||
LOGS_PATH = "app/logs/"
|
LOGS_PATH = "app/logs/"
|
||||||
CATEGORY_PATH = "app/service/attribute/config/descriptor/category/category_dis.csv"
|
CATEGORY_PATH = "app/service/attribute/config/descriptor/category/category_dis.csv"
|
||||||
FACE_CLASSIFIER = 'app/service/generate_image/utils/haarcascade_frontalface_alt.xml'
|
# FACE_CLASSIFIER = 'app/service/generate_image/utils/haarcascade_frontalface_alt.xml'
|
||||||
|
|
||||||
# RABBITMQ_ENV = "" # 生产环境
|
# RABBITMQ_ENV = "" # 生产环境
|
||||||
# RABBITMQ_ENV = "-dev" # 开发环境
|
# RABBITMQ_ENV = "-dev" # 开发环境
|
||||||
@@ -60,9 +60,9 @@ RABBITMQ_PARAMS = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# milvus 配置
|
# milvus 配置
|
||||||
MILVUS_DB_HOST = "10.1.1.240"
|
MILVUS_URL = "http://10.1.1.240:19530http://127.0.0.1:8000/docs#/design/design_api_design_post"
|
||||||
|
MILVUS_TOKEN = "root:Milvus"
|
||||||
MILVUS_ALIAS = "default"
|
MILVUS_ALIAS = "default"
|
||||||
MILVUS_PORT = "19530"
|
|
||||||
MILVUS_TABLE_KEYPOINT = "keypoint_cache"
|
MILVUS_TABLE_KEYPOINT = "keypoint_cache"
|
||||||
MILVUS_TABLE_SEG = "seg_cache"
|
MILVUS_TABLE_SEG = "seg_cache"
|
||||||
|
|
||||||
|
|||||||
@@ -14,17 +14,17 @@ class KeypointDetection(object):
|
|||||||
path here: abstract path
|
path here: abstract path
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
# def __init__(self):
|
||||||
self.client = MilvusClient(
|
# self.client = MilvusClient(
|
||||||
uri="http://10.1.1.240:19530",
|
# uri="http://10.1.1.240:19530",
|
||||||
token="root:Milvus",
|
# token="root:Milvus",
|
||||||
db_name=MILVUS_ALIAS
|
# db_name=MILVUS_ALIAS
|
||||||
)
|
# )
|
||||||
|
|
||||||
def __del__(self):
|
# def __del__(self):
|
||||||
# start_time = time.time()
|
# start_time = time.time()
|
||||||
self.client.close()
|
# self.client.close()
|
||||||
# print(f"client close time : {time.time() - start_time}")
|
# print(f"client close time : {time.time() - start_time}")
|
||||||
|
|
||||||
# @ RunTime
|
# @ RunTime
|
||||||
def __call__(self, result):
|
def __call__(self, result):
|
||||||
@@ -69,24 +69,19 @@ class KeypointDetection(object):
|
|||||||
"keypoint_vector": result.tolist()
|
"keypoint_vector": result.tolist()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
client = MilvusClient(
|
|
||||||
uri="http://10.1.1.240:19530",
|
|
||||||
token="root:Milvus",
|
|
||||||
db_name=MILVUS_ALIAS
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
|
client = MilvusClient(uri=MILVUS_URL, token=MILVUS_TOKEN, db_name=MILVUS_ALIAS)
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
res = client.upsert(
|
res = client.upsert(
|
||||||
collection_name=MILVUS_TABLE_KEYPOINT,
|
collection_name=MILVUS_TABLE_KEYPOINT,
|
||||||
data=data,
|
data=data,
|
||||||
)
|
)
|
||||||
# logging.info(f"save keypoint time : {time.time() - start_time}")
|
# logging.info(f"save keypoint time : {time.time() - start_time}")
|
||||||
|
client.close()
|
||||||
return dict(zip(KEYPOINT_RESULT_TABLE_FIELD_SET, result.reshape(12, 2).astype(int).tolist()))
|
return dict(zip(KEYPOINT_RESULT_TABLE_FIELD_SET, result.reshape(12, 2).astype(int).tolist()))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logging.info(f"save keypoint cache milvus error : {e}")
|
logging.info(f"save keypoint cache milvus error : {e}")
|
||||||
return dict(zip(KEYPOINT_RESULT_TABLE_FIELD_SET, result.reshape(12, 2).astype(int).tolist()))
|
return dict(zip(KEYPOINT_RESULT_TABLE_FIELD_SET, result.reshape(12, 2).astype(int).tolist()))
|
||||||
finally:
|
|
||||||
client.close()
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def update_keypoint_cache(keypoint_id, infer_result, search_result, site):
|
def update_keypoint_cache(keypoint_id, infer_result, search_result, site):
|
||||||
@@ -102,12 +97,9 @@ class KeypointDetection(object):
|
|||||||
"keypoint_vector": result.tolist()
|
"keypoint_vector": result.tolist()
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
client = MilvusClient(
|
|
||||||
uri="http://10.1.1.240:19530",
|
|
||||||
token="root:Milvus",
|
|
||||||
db_name=MILVUS_ALIAS
|
|
||||||
)
|
|
||||||
try:
|
try:
|
||||||
|
client = MilvusClient(uri=MILVUS_URL, token=MILVUS_TOKEN, db_name=MILVUS_ALIAS)
|
||||||
# connections.connect(alias=MILVUS_ALIAS, host=MILVUS_DB_HOST, port=MILVUS_PORT)
|
# connections.connect(alias=MILVUS_ALIAS, host=MILVUS_DB_HOST, port=MILVUS_PORT)
|
||||||
start_time = time.time()
|
start_time = time.time()
|
||||||
# collection = Collection(MILVUS_TABLE_KEYPOINT) # Get an existing collection.
|
# collection = Collection(MILVUS_TABLE_KEYPOINT) # Get an existing collection.
|
||||||
@@ -125,8 +117,9 @@ class KeypointDetection(object):
|
|||||||
# @ RunTime
|
# @ RunTime
|
||||||
def keypoint_cache(self, result, site):
|
def keypoint_cache(self, result, site):
|
||||||
try:
|
try:
|
||||||
|
client = MilvusClient(uri=MILVUS_URL, token=MILVUS_TOKEN, db_name=MILVUS_ALIAS)
|
||||||
keypoint_id = result['image_id']
|
keypoint_id = result['image_id']
|
||||||
res = self.client.query(
|
res = client.query(
|
||||||
collection_name=MILVUS_TABLE_KEYPOINT,
|
collection_name=MILVUS_TABLE_KEYPOINT,
|
||||||
# ids=[keypoint_id],
|
# ids=[keypoint_id],
|
||||||
filter=f"keypoint_id == {keypoint_id}",
|
filter=f"keypoint_id == {keypoint_id}",
|
||||||
|
|||||||
Reference in New Issue
Block a user