edit : imagen -> gemini로 변경, bingimg -> 사용불가 , 벡터검색api 이미지저장이아닌 데이터 전송하는 api 추가 , vactor -> vector 오타 수정

This commit is contained in:
2025-07-30 13:29:24 +09:00
parent 8e28a22825
commit 44bd86562d
45 changed files with 507 additions and 223 deletions

View File

@@ -1,5 +1,7 @@
import os
import shutil
import torch
import faiss
from custom_apps.faiss_imagenet.utils import preprocessing, preprocessing_quary, normalize, get_dataset_list
from custom_apps.faiss_imagenet.const import *
@@ -15,17 +17,29 @@ def search_idxs(image_path,dataset_bin=DATASET_BIN,index_type="hnsw",search_num=
DIM = 1280
# res = faiss.StandardGpuResources()
# __res = faiss.StandardGpuResources()
dataset_fvces, dataset_index = preprocessing(DIM,dataset_bin,index_type)
org_fvces, org_index = preprocessing_quary(DIM,image_path,index_type)
# cpu -> gpu
# gpu_idx = faiss.index_cpu_to_gpu_multiple_py([res], 0, dataset_index)
# __gpu_idx = faiss.index_cpu_to_gpu_multiple_py([__res], 0, org_index)
dists, idxs = dataset_index.search(normalize(org_fvces), search_num)
# print(dists[0])
# print(idxs[0])
index_image_save(image_path, dists[0], idxs[0])
# del dataset_fvces, dataset_index, org_fvces, org_index, dists, idxs
# del res, __res, gpu_idx, __gpu_idx
# torch.cuda.empty_cache()
# import gc
# gc.collect()
def index_image_save(query_image_path, dists, idxs):
directory_path, file = os.path.split(query_image_path)
_name, extension = os.path.splitext(file)