Commit 95395422 authored by 赵威's avatar 赵威

save feature to redis

parent ff32dfca
...@@ -77,21 +77,23 @@ def save_diary_image_info(): ...@@ -77,21 +77,23 @@ def save_diary_image_info():
} }
} }
count = 0 count = 0
res_dict = {} # before_res_dict = {}
after_res_dict = {}
results = es_scan("diary", q) results = es_scan("diary", q)
for item in results: for item in results:
if count <= 15: diary_id = item["_id"]
diary_id = item["_id"] # before_cover_url = item["_source"]["before_cover_url"] + "-w"
# 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) after_cover_url = item["_source"]["after_cover_url"] + "-w"
if img.any(): img = url_to_ndarray(after_cover_url)
count += 1 if img.any():
print("count: " + str(count) + " " + str(diary_id)) count += 1
faces = FACE_TO_VEC_FUN(img) print("count: " + str(count) + " " + str(diary_id))
for face in faces: faces = FACE_TO_VEC_FUN(img)
res_dict[diary_id] = face["feature"] for face in faces:
print(res_dict) 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): 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