Commit ff32dfca authored by 赵威's avatar 赵威

get result

parent e0f8a405
......@@ -7,7 +7,7 @@ import dlib
import faiss
import numpy as np
from gm_rpcd.all import bind
from utils.cache import redis_client3
from utils.cache import redis_client3, redis_client_db
from utils.es import es_query, es_scan
from utils.images import face_to_vec, url_to_ndarray
......@@ -32,7 +32,8 @@ def hello():
return ["hello", "world"]
def save_diary_image_info(save_file):
# curl "http://172.16.31.17:9200/gm-dbmw-diary/_search?pretty&size=0" -d '
def save_diary_image_info():
q = {
"query": {
"bool": {
......@@ -76,25 +77,21 @@ def save_diary_image_info(save_file):
}
}
count = 0
res_dict = {}
results = es_scan("diary", q)
with open(save_file, "w") as f:
for item in results:
count += 1
print(item["_id"], item["_source"]["after_cover_url"] + "-w", + str(count))
# res_dict = es_query("diary", q, offset=0, size=200000)
# for item in res_dict["hits"]["hits"]:
# diary_id = item["_source"]["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:
# line = str(diary_id) + "\t" + face["feature"] + "\n"
# # print(line)
# f.write(line)
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)
def save_faiss_index(load_file, save_path):
......@@ -182,7 +179,7 @@ def get_similar_diary_ids_by_face_features(feature, limit=0.1):
def main():
save_diary_image_info(diary_after_cover_vec_file)
save_diary_image_info()
# save_faiss_index(diary_after_cover_vec_file, faiss_index_path)
# imgs = [
......
......@@ -4,3 +4,5 @@ redis_client = redis.StrictRedis.from_url("redis://:ReDis!GmTx*0aN6@172.16.40.13
redis_client2 = redis.StrictRedis.from_url("redis://:ReDis!GmTx*0aN9@172.16.40.173:6379")
redis_client3 = redis.StrictRedis.from_url("redis://:ReDis!GmTx*0aN12@172.16.40.164:6379")
redis_client4 = redis.StrictRedis.from_url("redis://:XfkMCCdWDIU%ls$h@172.16.50.145:6379")
redis_client_db = redis.StrictRedis.from_url("redis://:ReDis!GmTx*0aN14@172.16.40.146:6379")
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