Commit fb62b9a0 authored by 赵威's avatar 赵威

add bindings

parent 6f5af821
...@@ -117,6 +117,7 @@ def save_faiss_index(load_file, save_path): ...@@ -117,6 +117,7 @@ def save_faiss_index(load_file, save_path):
print("faiss index saved") print("faiss index saved")
@bind("strategy_embedding/face_similarity/diary/url")
def get_similar_diary_ids_by_url(url, limit=0.1): def get_similar_diary_ids_by_url(url, limit=0.1):
img = url_to_ndarray(url) img = url_to_ndarray(url)
if img.any(): if img.any():
...@@ -137,6 +138,7 @@ def get_similar_diary_ids_by_url(url, limit=0.1): ...@@ -137,6 +138,7 @@ def get_similar_diary_ids_by_url(url, limit=0.1):
return [] return []
@bind("strategy_embedding/face_similarity/diary/feature")
def get_similar_diary_ids_by_face_features(feature, limit=0.1): def get_similar_diary_ids_by_face_features(feature, limit=0.1):
feature = np.array(feature).astype("float32") feature = np.array(feature).astype("float32")
_sources, _ids = FAISS_DIARY_INDEX.search(np.array([feature]), 10) _sources, _ids = FAISS_DIARY_INDEX.search(np.array([feature]), 10)
......
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