Compare commits
6 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b508d32aff | |||
| 80f5e50c31 | |||
| e2190eadba | |||
| 113626cc5d | |||
| 7eed2e9868 | |||
| fce9eedfae |
3
.gitignore
vendored
3
.gitignore
vendored
@@ -147,4 +147,5 @@ log
|
||||
*temp
|
||||
datas/*
|
||||
|
||||
*result
|
||||
*result
|
||||
*.env
|
||||
@@ -15,6 +15,8 @@ class Config:
|
||||
self.sftp_port = 22
|
||||
self.sftp_id = "fermat"
|
||||
self.sftp_pw = "1234"
|
||||
|
||||
self.api_path = "./gemini.env"
|
||||
|
||||
def set_dev(self):
|
||||
"""
|
||||
@@ -28,6 +30,8 @@ class Config:
|
||||
self.sftp_pw = "fermat3514"
|
||||
self.db_pw = "1234"
|
||||
|
||||
self.api_path = "./gemini.env"
|
||||
|
||||
if not os.path.exists(self.remote_folder):
|
||||
os.makedirs(self.remote_folder)
|
||||
|
||||
@@ -37,6 +41,8 @@ class Config:
|
||||
|
||||
self.db_pw = "Fermat3514!"
|
||||
|
||||
self.api_path = "../gemini.env"
|
||||
|
||||
if not os.path.exists(self.local_folder):
|
||||
os.makedirs(self.local_folder)
|
||||
|
||||
|
||||
6
const.py
6
const.py
@@ -1,3 +1,7 @@
|
||||
from utils.api_key_manager import ApiKeyManager
|
||||
|
||||
TEMP_FOLDER = "./temp"
|
||||
|
||||
ILLEGAL_FILE_NAME = ['<', '>', ':', '"', '/', '\ ', '|', '?', '*']
|
||||
ILLEGAL_FILE_NAME = ['<', '>', ':', '"', '/', '\ ', '|', '?', '*']
|
||||
|
||||
API_KEY_MANAGER = ApiKeyManager()
|
||||
@@ -126,8 +126,18 @@ def get_clip_info(model, query_image_path, item_info, top_k=4):
|
||||
# save_txt_dir=VECTOR_IMG_LIST_PATH,
|
||||
# item_info=item_info,
|
||||
# index_type=model.value[1].index_type)
|
||||
|
||||
inference_times, result_img_paths, result_percents = vector_model.query_faiss(query_image_path, top_k=top_k)
|
||||
|
||||
if os.path.exists(query_image_path):
|
||||
inference_times, result_img_paths, result_percents = vector_model.query_faiss(query_image_path, top_k=top_k)
|
||||
elif query_image_path is None or query_image_path == "":
|
||||
raise ValueError("query_image is None or empty.")
|
||||
else:
|
||||
inference_times, result_img_paths, result_percents = vector_model.query_faiss_image_data(query_image_path, top_k=top_k)
|
||||
|
||||
for i in range(len(result_percents)):
|
||||
if float(result_percents[i]) < 0.0:
|
||||
result_percents[i] = None
|
||||
result_img_paths[i] = None
|
||||
|
||||
report_info = ReportInfo(
|
||||
feature_extraction_model=ReportInfoConst.feature_extraction_model,
|
||||
|
||||
@@ -53,7 +53,7 @@ from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS import feature_extraction_model
|
||||
# 사용할 이미지 임베딩 모델 클래스 추가
|
||||
from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS.fem_openaiclipvit import FEOpenAIClipViT
|
||||
from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS.const import *
|
||||
|
||||
from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS.utils import get_base64_bytes
|
||||
|
||||
"""
|
||||
Definition
|
||||
@@ -218,6 +218,24 @@ class VectorSimilarity:
|
||||
image_data_np = Image.open(image_file).convert('RGB')
|
||||
feature_vectors = self.fem_model.image_embedding(image_data_np)
|
||||
return feature_vectors
|
||||
|
||||
def image_embedding_from_b64data(self, b64_data=None):
|
||||
"""
|
||||
이미지 데이터(base64)에서 특징 벡터 추출
|
||||
:param image_data_np: 이미지 데이터(numpy)
|
||||
:return: 특징 벡터 or None
|
||||
"""
|
||||
import io
|
||||
feature_vectors = None
|
||||
|
||||
if b64_data is None:
|
||||
log.error(f'invalid data[{b64_data}]')
|
||||
return feature_vectors
|
||||
|
||||
image = Image.open(io.BytesIO(b64_data)).convert("RGB")
|
||||
|
||||
feature_vectors = self.fem_model.image_embedding(image)
|
||||
return feature_vectors
|
||||
|
||||
def image_embedding_from_data(self, image_data_np=None):
|
||||
"""
|
||||
@@ -371,6 +389,53 @@ class VectorSimilarity:
|
||||
result_percents.append(f"{((1 - dist)*100):.2f}")
|
||||
|
||||
return inference_times, result_img_paths, result_percents
|
||||
|
||||
def query_faiss_image_data(self, query_image_data=None, top_k=4):
|
||||
|
||||
if os.path.exists(self.txt_file_path):
|
||||
with open(self.txt_file_path, 'r') as f:
|
||||
image_paths = [line.strip() for line in f.readlines()]
|
||||
else:
|
||||
logging.error("Image path list TXT file not found.")
|
||||
image_paths = []
|
||||
|
||||
b64_data = get_base64_bytes(query_image_data)
|
||||
|
||||
start_vector_time = datetime.now()
|
||||
index = self.load_index(self.index_file_path)
|
||||
query_vector = self.image_embedding_from_b64data(b64_data)
|
||||
end_vector_time = datetime.now()
|
||||
|
||||
diff_vector_time = self.time_diff(start_vector_time,end_vector_time)
|
||||
|
||||
if self.index_type == INDEX_TYPE_COSINE:
|
||||
faiss.normalize_L2(query_vector)
|
||||
|
||||
start_search_time = datetime.now()
|
||||
distances, indices = index.search(query_vector, top_k)
|
||||
end_search_time = datetime.now()
|
||||
|
||||
diff_search_time = self.time_diff(start_search_time,end_search_time)
|
||||
diff_total_time = self.time_diff(start_vector_time,end_search_time)
|
||||
inference_times = f"Total time - {diff_total_time}, vector_time - {diff_vector_time}, search_time - {diff_search_time}"
|
||||
|
||||
result_img_paths = []
|
||||
result_percents = []
|
||||
|
||||
# 결과
|
||||
# for i in range(top_k):
|
||||
# print(f"{i + 1}: {image_paths[indices[0][i]]}, Distance: {distances[0][i]}")
|
||||
for idx, dist in zip(indices[0], distances[0]):
|
||||
log.debug(f"{idx} (거리: {dist:.4f})")
|
||||
|
||||
result_img_paths.append(image_paths[idx])
|
||||
|
||||
if self.index_type == INDEX_TYPE_COSINE:
|
||||
result_percents.append(f"{dist*100:.2f}")
|
||||
else:
|
||||
result_percents.append(f"{((1 - dist)*100):.2f}")
|
||||
|
||||
return inference_times, result_img_paths, result_percents
|
||||
|
||||
# def test():
|
||||
# """
|
||||
|
||||
@@ -31,6 +31,8 @@ import os, sys
|
||||
|
||||
from transformers import CLIPProcessor, CLIPModel
|
||||
from huggingface_hub import login as huggingface_login
|
||||
from huggingface_hub import whoami, logout
|
||||
from huggingface_hub.utils import LocalTokenNotFoundError
|
||||
|
||||
"""
|
||||
Package: custom
|
||||
@@ -104,7 +106,18 @@ class FEOpenAIClipViT(FEM.FeatureExtractionModel):
|
||||
|
||||
# huggingface token
|
||||
if self.huggingface_token:
|
||||
huggingface_login(fem_arguments.token)
|
||||
"""
|
||||
토큰이 있다면 로그인이 되어있는지 확인
|
||||
안되어있다면 로그인 시도
|
||||
"""
|
||||
try:
|
||||
user_info = whoami()
|
||||
except Exception as LocalTokenNotFoundError:
|
||||
huggingface_login(fem_arguments.token)
|
||||
|
||||
except Exception as e:
|
||||
log.error(f'Huggingface login error: {e}')
|
||||
raise e
|
||||
|
||||
# model path check
|
||||
if not os.path.exists(fem_arguments.trained_model):
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import os
|
||||
import base64
|
||||
from pathlib import Path
|
||||
|
||||
from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS.const import *
|
||||
@@ -7,6 +8,14 @@ def search_glass_parts(image_path_list):
|
||||
result = []
|
||||
|
||||
for image_path in image_path_list:
|
||||
|
||||
if image_path is None:
|
||||
result.append(None)
|
||||
continue
|
||||
elif not os.path.exists(image_path):
|
||||
result.append(None)
|
||||
continue
|
||||
|
||||
parts_path = Path(os.path.join(os.path.dirname(os.path.dirname(image_path)),ImageDepths.parts))
|
||||
parts_files_generator = parts_path.rglob('*.png')
|
||||
|
||||
@@ -35,5 +44,29 @@ def file_name_to_parts(file_path):
|
||||
|
||||
return result
|
||||
|
||||
|
||||
def get_base64_bytes(data: str) -> bytes:
|
||||
"""
|
||||
문자열을 검사하여 유효한 Base64라면 디코딩된 bytes 데이터를 반환하고,
|
||||
그렇지 않으면 ValueError 예외를 발생시킵니다.
|
||||
"""
|
||||
|
||||
try:
|
||||
# 1. 입력 문자열 전처리 (공백 제거 등)
|
||||
stripped_data = data.strip()
|
||||
|
||||
# 2. bytes로 인코딩 (b64decode는 bytes-like object를 필요로 함)
|
||||
encoded_input = stripped_data.encode('ascii')
|
||||
|
||||
# 3. Base64 디코딩 수행 (validate=True로 엄격한 검사)
|
||||
# 성공 시 b'...' 형태의 바이트 데이터가 생성됨
|
||||
decoded_bytes = base64.b64decode(encoded_input, validate=True)
|
||||
|
||||
return decoded_bytes
|
||||
|
||||
except Exception as e:
|
||||
# Base64 형식이 아니거나 패딩 오류 등 발생 시
|
||||
raise ValueError(f"유효한 Base64 데이터가 아닙니다. 변환 불가: {e}")
|
||||
|
||||
if __name__ == '__main__':
|
||||
print(file_name_to_parts(os.path.join(FAISS_VECTOR_PATH,"Glass_001",ImageDepths.parts,"Glass_001_Temple_L.png")))
|
||||
@@ -7,14 +7,18 @@ from PIL import Image
|
||||
from io import BytesIO
|
||||
|
||||
from main_rest.app.utils.date_utils import D
|
||||
from const import TEMP_FOLDER
|
||||
|
||||
from const import TEMP_FOLDER, API_KEY_MANAGER
|
||||
|
||||
def gemini_image(prompt, folder=None):
|
||||
from custom_logger.main_log import main_logger as LOG
|
||||
|
||||
image_path = ''
|
||||
client = genai.Client(api_key="AIzaSyCSw4pcPDYdAnjzBB7J9ZKXtRJJvunjWtA") # a2tec key
|
||||
api_key = API_KEY_MANAGER.get_api_key()
|
||||
|
||||
if api_key is None:
|
||||
raise Exception("API 키 세팅 필요! - 서버를 다시 구동하거나, API키 파일을 확인")
|
||||
|
||||
client = genai.Client(api_key=API_KEY_MANAGER.get_api_key()) # a2tec key
|
||||
|
||||
for i in range(3):
|
||||
response = client.models.generate_content(
|
||||
|
||||
@@ -34,7 +34,6 @@ from custom_logger.main_log import main_logger as LOG
|
||||
|
||||
API_KEY_HEADER = APIKeyHeader(name='Authorization', auto_error=False)
|
||||
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
# When service starts.
|
||||
@@ -42,6 +41,10 @@ async def lifespan(app: FastAPI):
|
||||
|
||||
import os
|
||||
import const
|
||||
from const import API_KEY_MANAGER
|
||||
|
||||
API_KEY_MANAGER.set_api_key()
|
||||
|
||||
if os.path.exists(const.TEMP_FOLDER):
|
||||
for _file in os.scandir(const.TEMP_FOLDER):
|
||||
os.remove(_file)
|
||||
|
||||
@@ -659,8 +659,8 @@ class VectorGlassesImageResult(BaseModel):
|
||||
|
||||
class VectorPartsImageResult(BaseModel):
|
||||
image : str | None = Field("", description='이미지 데이터', example='')
|
||||
percents: float = Field(0.0, description='percents 값', example='')
|
||||
imageInfo : str = Field("", description='원본이미지 이름', example='')
|
||||
percents: float | None = Field(0.0, description='percents 값', example='')
|
||||
imageInfo : str | None = Field("", description='원본이미지 이름', example='')
|
||||
#===============================================================================
|
||||
#===============================================================================
|
||||
#===============================================================================
|
||||
|
||||
@@ -507,9 +507,12 @@ async def vactor_vit_input_glasses_img_data(request: Request, request_body_info:
|
||||
raise Exception(f"indexType is invalid (current value = {request_body_info.indexType})")
|
||||
|
||||
query_image_data = request_body_info.inputImage
|
||||
query_image_path = os.path.join(TEMP_FOLDER, f'input_{D.date_file_name()}_query.png')
|
||||
os.makedirs(TEMP_FOLDER, exist_ok=True)
|
||||
save_base64_as_image_file(request_body_info.inputImage ,query_image_path)
|
||||
|
||||
# query_image_path = os.path.join(TEMP_FOLDER, f'input_{D.date_file_name()}_query.png')
|
||||
# os.makedirs(TEMP_FOLDER, exist_ok=True)
|
||||
# save_base64_as_image_file(request_body_info.inputImage ,query_image_path)
|
||||
|
||||
query_image_path = query_image_data
|
||||
|
||||
vector_request_data = {'query_image_path' : query_image_path,
|
||||
'index_type' : request_body_info.indexType,
|
||||
@@ -535,11 +538,19 @@ async def vactor_vit_input_glasses_img_data(request: Request, request_body_info:
|
||||
for img, percents, parts in zip(result_image_paths, result_percents, result_parts):
|
||||
|
||||
b64_data = None
|
||||
if os.path.exists(img):
|
||||
b64_data = image_to_base64_string(img)
|
||||
float_percent = float(percents)
|
||||
float_percent = None
|
||||
img_info = None
|
||||
|
||||
info = M.VectorGlassesImageResult(image=b64_data, percents=float_percent, imageInfo=os.path.split(img)[-1], parts=parts)
|
||||
if img is not None:
|
||||
if os.path.exists(img):
|
||||
b64_data = image_to_base64_string(img)
|
||||
img_info = os.path.split(img)[-1]
|
||||
|
||||
if percents is not None:
|
||||
if percents.isnumeric:
|
||||
float_percent = float(percents)
|
||||
|
||||
info = M.VectorGlassesImageResult(image=b64_data, percents=float_percent, imageInfo=img_info, parts=parts)
|
||||
|
||||
vector_image_results.append(info)
|
||||
|
||||
@@ -621,11 +632,19 @@ async def vactor_vit_input_parts_img_data(request: Request, request_body_info: M
|
||||
for img, percents in zip(result_image_paths, result_percents):
|
||||
|
||||
b64_data = None
|
||||
if os.path.exists(img):
|
||||
b64_data = image_to_base64_string(img)
|
||||
float_percent = float(percents)
|
||||
float_percent = None
|
||||
img_info = None
|
||||
|
||||
info = M.VectorPartsImageResult(image=b64_data, percents=float_percent, imageInfo=os.path.split(img)[-1])
|
||||
if img is not None:
|
||||
if os.path.exists(img):
|
||||
b64_data = image_to_base64_string(img)
|
||||
img_info = os.path.split(img)[-1]
|
||||
|
||||
if percents is not None:
|
||||
if percents.isnumeric:
|
||||
float_percent = float(percents)
|
||||
|
||||
info = M.VectorPartsImageResult(image=b64_data, percents=float_percent, imageInfo=img_info)
|
||||
|
||||
vector_image_results.append(info)
|
||||
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
# from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS.faiss_functions import get_clip_info
|
||||
import os
|
||||
import logging
|
||||
import matplotlib.pyplot as plt
|
||||
|
||||
from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS.faiss_similarity_search import VectorSimilarity
|
||||
from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS.const import *
|
||||
from custom_apps.FEATURE_VECTOR_SIMILARITY_FAISS.faiss_functions import get_models, find_glass_folder_images, find_parts_folder_images
|
||||
from vector_rest.app import models as VM
|
||||
|
||||
|
||||
#log level
|
||||
os.environ["HF_HUB_VERBOSITY"] = "info"
|
||||
matplotlib_logger = logging.getLogger("matplotlib")
|
||||
matplotlib_logger.setLevel(logging.INFO)
|
||||
|
||||
def make_image_files(item_info, index_type:VM.VitIndexType, model_type:VM.VitModelType):
|
||||
model = get_models(index_type=index_type, model_type=model_type)
|
||||
|
||||
@@ -53,7 +61,7 @@ def make_vector_files(item_info, index_type:VM.VitIndexType, model_type:VM.VitMo
|
||||
|
||||
txt_file_path = make_image_files(item_info=item_info, index_type=index_type, model_type=model_type)
|
||||
|
||||
index_file_path = os.path.join(IMG_LIST_PATH,f'{model.name}_{os.path.basename(model.value[1].trained_model)}_{model.value[1].index_type}_{item_info}_{DEFAULT_INDEX_NAME_SUFFIX}')
|
||||
index_file_path = os.path.join(FAISS_VECTOR_PATH,f'{model.name}_{os.path.basename(model.value[1].trained_model)}_{model.value[1].index_type}_{item_info}_{DEFAULT_INDEX_NAME_SUFFIX}')
|
||||
|
||||
if not os.path.exists(index_file_path):
|
||||
|
||||
@@ -66,12 +74,11 @@ def make_vector_files(item_info, index_type:VM.VitIndexType, model_type:VM.VitMo
|
||||
|
||||
vector_model.save_index_from_files(images_path_lists=image_lists,
|
||||
save_index_dir=FAISS_VECTOR_PATH,
|
||||
save_txt_dir=IMG_LIST_PATH,
|
||||
item_info=item_info,
|
||||
index_type=model.value[1].index_type)
|
||||
|
||||
else:
|
||||
temp_path = os.path.join(IMG_LIST_PATH,f'{model.name}_{os.path.basename(model.value[1].trained_model)}_{model.value[1].index_type}_{item_info}_{DEFAULT_INDEX_NAME_SUFFIX}.bak')
|
||||
temp_path = os.path.join(FAISS_VECTOR_PATH,f'{model.name}_{os.path.basename(model.value[1].trained_model)}_{model.value[1].index_type}_{item_info}_{DEFAULT_INDEX_NAME_SUFFIX}.bak')
|
||||
|
||||
try:
|
||||
os.rename(index_file_path, temp_path)
|
||||
@@ -85,7 +92,6 @@ def make_vector_files(item_info, index_type:VM.VitIndexType, model_type:VM.VitMo
|
||||
|
||||
vector_model.save_index_from_files(images_path_lists=image_lists,
|
||||
save_index_dir=FAISS_VECTOR_PATH,
|
||||
save_txt_dir=IMG_LIST_PATH,
|
||||
item_info=item_info,
|
||||
index_type=model.value[1].index_type)
|
||||
except Exception as e:
|
||||
@@ -102,7 +108,6 @@ def make_vector_files(item_info, index_type:VM.VitIndexType, model_type:VM.VitMo
|
||||
|
||||
if __name__ == '__main__':
|
||||
|
||||
import time
|
||||
class_attributes = dict(VectorSearchItem.__dict__)
|
||||
|
||||
pure_data_dict = {
|
||||
@@ -112,6 +117,4 @@ if __name__ == '__main__':
|
||||
}
|
||||
|
||||
for item_key, item_value in pure_data_dict.items():
|
||||
make_vector_files(item_info=item_value, index_type=VM.VitIndexType.l2, model_type=VM.VitModelType.b32)
|
||||
|
||||
time.sleep(5) # huggingface api 요청 제한 회피 위해 대기 TODO(jwkim) huggingface 로그인은 한번만 진행하게 변경
|
||||
make_vector_files(item_info=item_value, index_type=VM.VitIndexType.l2, model_type=VM.VitModelType.b32)
|
||||
@@ -13,6 +13,7 @@ pycryptodomex
|
||||
pycryptodome
|
||||
email-validator
|
||||
requests
|
||||
python-dotenv
|
||||
|
||||
#imagen
|
||||
google-cloud-aiplatform
|
||||
|
||||
26
rest.main.service
Normal file
26
rest.main.service
Normal file
@@ -0,0 +1,26 @@
|
||||
[Unit]
|
||||
Description=Main REST Service for Glasses AI
|
||||
After=rest.vector.service
|
||||
Requires=rest.vector.service
|
||||
|
||||
[Service]
|
||||
User=user
|
||||
Group=user
|
||||
|
||||
# User=fermat
|
||||
# Group=fermat
|
||||
|
||||
WorkingDirectory=/home/user/a2tec/glasses_ai
|
||||
# WorkingDirectory=/home/fermat/project/glasses/rest
|
||||
|
||||
# 51002 포트가 열릴 때까지 대기 (bash 내장 TCP 체크 활용)
|
||||
ExecStartPre=/bin/bash -c 'until timeout 1s bash -c "cat < /dev/null > /dev/tcp/localhost/51002"; do echo "Waiting for Vector Service on port 51002..."; sleep 2; done'
|
||||
|
||||
# rest 가상환경 파이썬 사용
|
||||
ExecStart=/home/user/anaconda3/envs/rest/bin/python rest_main.py
|
||||
# ExecStart=/mnt/clover_1TB/anaconda_data/fm_rest/bin/python rest_main.py
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
24
rest.vector.service
Normal file
24
rest.vector.service
Normal file
@@ -0,0 +1,24 @@
|
||||
[Unit]
|
||||
Description=Vector Service for Glasses AI
|
||||
After=network-online.target
|
||||
Wants=network-online.target
|
||||
PartOf=rest.main.service
|
||||
|
||||
[Service]
|
||||
User=user
|
||||
Group=user
|
||||
|
||||
# User=fermat
|
||||
# Group=fermat
|
||||
|
||||
WorkingDirectory=/home/user/a2tec/glasses_ai
|
||||
# WorkingDirectory=/home/fermat/project/glasses/rest
|
||||
|
||||
ExecStart=/home/user/anaconda3/envs/rest_vector/bin/python rest_vector.py
|
||||
# ExecStart=/mnt/clover_1TB/anaconda_data/fm_rest_vector/bin/python rest_vector.py
|
||||
|
||||
Restart=always
|
||||
RestartSec=3
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
33
utils/api_key_manager.py
Normal file
33
utils/api_key_manager.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import os
|
||||
from dotenv import load_dotenv
|
||||
|
||||
from config import rest_config
|
||||
from custom_logger.main_log import main_logger as LOG
|
||||
|
||||
|
||||
class ApiKeyManager:
|
||||
|
||||
def __init__(self):
|
||||
self.api_key = None
|
||||
|
||||
def set_api_key(self, env_path=rest_config.api_path):
|
||||
|
||||
if os.path.exists(env_path):
|
||||
|
||||
load_dotenv(dotenv_path=env_path)
|
||||
key = os.getenv("GEMINI_API_KEY")
|
||||
|
||||
if key is None:
|
||||
LOG.error(f"api key 파일에 GEMINI_API_KEY라는 변수가 없습니다")
|
||||
elif key == "":
|
||||
LOG.error(f"api key 파일에 내부 변수 GEMINI_API_KEY 값이 빈값입니다 값을 설정해주세요")
|
||||
else:
|
||||
self.api_key = key
|
||||
|
||||
else:
|
||||
LOG.error(f"api key 파일이 없습니다 : {os.path.abspath(env_path)}")
|
||||
|
||||
def get_api_key(self):
|
||||
if self.api_key is not None:
|
||||
return self.api_key
|
||||
|
||||
@@ -84,8 +84,8 @@ async def vactor_vit(request: Request, request_body_info: M.VectorSearchVitReq):
|
||||
"""
|
||||
response = M.VectorSearchVitRes()
|
||||
try:
|
||||
if not os.path.exists(request_body_info.query_image_path):
|
||||
raise FileNotFoundError(f"File {request_body_info.query_image_path} does not exist.")
|
||||
# if not os.path.exists(request_body_info.query_image_path):
|
||||
# raise FileNotFoundError(f"File {request_body_info.query_image_path} does not exist.")
|
||||
|
||||
model = get_models(index_type=request_body_info.index_type, model_type=request_body_info.model_type)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user