Commit ff32dfca authored by 赵威's avatar 赵威

get result

parent e0f8a405
...@@ -7,7 +7,7 @@ import dlib ...@@ -7,7 +7,7 @@ import dlib
import faiss import faiss
import numpy as np import numpy as np
from gm_rpcd.all import bind 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.es import es_query, es_scan
from utils.images import face_to_vec, url_to_ndarray from utils.images import face_to_vec, url_to_ndarray
...@@ -32,7 +32,8 @@ def hello(): ...@@ -32,7 +32,8 @@ def hello():
return ["hello", "world"] 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 = { q = {
"query": { "query": {
"bool": { "bool": {
...@@ -76,25 +77,21 @@ def save_diary_image_info(save_file): ...@@ -76,25 +77,21 @@ def save_diary_image_info(save_file):
} }
} }
count = 0 count = 0
res_dict = {}
results = es_scan("diary", q) results = es_scan("diary", q)
with open(save_file, "w") as f: for item in results:
for item in results: if count <= 15:
count += 1 diary_id = item["_id"]
print(item["_id"], item["_source"]["after_cover_url"] + "-w", + str(count)) # before_cover_url = item["_source"]["before_cover_url"] + "-w"
# res_dict = es_query("diary", q, offset=0, size=200000) after_cover_url = item["_source"]["after_cover_url"] + "-w"
# for item in res_dict["hits"]["hits"]: img = url_to_ndarray(after_cover_url)
# diary_id = item["_source"]["id"] if img.any():
# # before_cover_url = item["_source"]["before_cover_url"] + "-w" count += 1
# after_cover_url = item["_source"]["after_cover_url"] + "-w" print("count: " + str(count) + " " + str(diary_id))
# img = url_to_ndarray(after_cover_url) faces = FACE_TO_VEC_FUN(img)
# if img.any(): for face in faces:
# count += 1 res_dict[diary_id] = face["feature"]
# print("count: " + str(count) + " " + str(diary_id)) print(res_dict)
# faces = FACE_TO_VEC_FUN(img)
# for face in faces:
# line = str(diary_id) + "\t" + face["feature"] + "\n"
# # print(line)
# f.write(line)
def save_faiss_index(load_file, save_path): def save_faiss_index(load_file, save_path):
...@@ -182,7 +179,7 @@ def get_similar_diary_ids_by_face_features(feature, limit=0.1): ...@@ -182,7 +179,7 @@ def get_similar_diary_ids_by_face_features(feature, limit=0.1):
def main(): 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) # save_faiss_index(diary_after_cover_vec_file, faiss_index_path)
# imgs = [ # imgs = [
......
...@@ -4,3 +4,5 @@ redis_client = redis.StrictRedis.from_url("redis://:ReDis!GmTx*0aN6@172.16.40.13 ...@@ -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_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_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_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