Commit 95395422 authored by 赵威's avatar 赵威

save feature to redis

parent ff32dfca
......@@ -77,21 +77,23 @@ def save_diary_image_info():
}
}
count = 0
res_dict = {}
# before_res_dict = {}
after_res_dict = {}
results = es_scan("diary", q)
for item in results:
if count <= 15:
diary_id = item["_id"]
# before_cover_url = item["_source"]["before_cover_url"] + "-w"
after_cover_url = item["_source"]["after_cover_url"] + "-w"
img = url_to_ndarray(after_cover_url)
if img.any():
count += 1
print("count: " + str(count) + " " + str(diary_id))
faces = FACE_TO_VEC_FUN(img)
for face in faces:
res_dict[diary_id] = face["feature"]
print(res_dict)
diary_id = item["_id"]
# before_cover_url = item["_source"]["before_cover_url"] + "-w"
# before_img = url_to_ndarray(before_cover_url)
after_cover_url = item["_source"]["after_cover_url"] + "-w"
img = url_to_ndarray(after_cover_url)
if img.any():
count += 1
print("count: " + str(count) + " " + str(diary_id))
faces = FACE_TO_VEC_FUN(img)
for face in faces:
after_res_dict[diary_id] = face["feature"]
redis_client_db.hmset("strategy_embedding:diary:cover:after", after_res_dict)
def save_faiss_index(load_file, save_path):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment