edit : 요청값보다 벡터파일에 등록된 갯수가 적을경우 각 항목 null로 처리
This commit is contained in:
@@ -129,6 +129,11 @@ def get_clip_info(model, query_image_path, item_info, top_k=4):
|
|||||||
|
|
||||||
inference_times, result_img_paths, result_percents = vector_model.query_faiss(query_image_path, top_k=top_k)
|
inference_times, result_img_paths, result_percents = vector_model.query_faiss(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(
|
report_info = ReportInfo(
|
||||||
feature_extraction_model=ReportInfoConst.feature_extraction_model,
|
feature_extraction_model=ReportInfoConst.feature_extraction_model,
|
||||||
model_architecture=ReportInfoConst.model_architecture,
|
model_architecture=ReportInfoConst.model_architecture,
|
||||||
|
|||||||
@@ -7,6 +7,14 @@ def search_glass_parts(image_path_list):
|
|||||||
result = []
|
result = []
|
||||||
|
|
||||||
for image_path in image_path_list:
|
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_path = Path(os.path.join(os.path.dirname(os.path.dirname(image_path)),ImageDepths.parts))
|
||||||
parts_files_generator = parts_path.rglob('*.png')
|
parts_files_generator = parts_path.rglob('*.png')
|
||||||
|
|
||||||
|
|||||||
@@ -659,8 +659,8 @@ class VectorGlassesImageResult(BaseModel):
|
|||||||
|
|
||||||
class VectorPartsImageResult(BaseModel):
|
class VectorPartsImageResult(BaseModel):
|
||||||
image : str | None = Field("", description='이미지 데이터', example='')
|
image : str | None = Field("", description='이미지 데이터', example='')
|
||||||
percents: float = Field(0.0, description='percents 값', example='')
|
percents: float | None = Field(0.0, description='percents 값', example='')
|
||||||
imageInfo : str = Field("", description='원본이미지 이름', example='')
|
imageInfo : str | None = Field("", description='원본이미지 이름', example='')
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
#===============================================================================
|
#===============================================================================
|
||||||
|
|||||||
@@ -535,11 +535,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):
|
for img, percents, parts in zip(result_image_paths, result_percents, result_parts):
|
||||||
|
|
||||||
b64_data = None
|
b64_data = None
|
||||||
|
float_percent = None
|
||||||
|
img_info = None
|
||||||
|
|
||||||
|
if img is not None:
|
||||||
if os.path.exists(img):
|
if os.path.exists(img):
|
||||||
b64_data = image_to_base64_string(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)
|
float_percent = float(percents)
|
||||||
|
|
||||||
info = M.VectorGlassesImageResult(image=b64_data, percents=float_percent, imageInfo=os.path.split(img)[-1], parts=parts)
|
info = M.VectorGlassesImageResult(image=b64_data, percents=float_percent, imageInfo=img_info, parts=parts)
|
||||||
|
|
||||||
vector_image_results.append(info)
|
vector_image_results.append(info)
|
||||||
|
|
||||||
@@ -621,11 +629,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):
|
for img, percents in zip(result_image_paths, result_percents):
|
||||||
|
|
||||||
b64_data = None
|
b64_data = None
|
||||||
|
float_percent = None
|
||||||
|
img_info = None
|
||||||
|
|
||||||
|
if img is not None:
|
||||||
if os.path.exists(img):
|
if os.path.exists(img):
|
||||||
b64_data = image_to_base64_string(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)
|
float_percent = float(percents)
|
||||||
|
|
||||||
info = M.VectorPartsImageResult(image=b64_data, percents=float_percent, imageInfo=os.path.split(img)[-1])
|
info = M.VectorPartsImageResult(image=b64_data, percents=float_percent, imageInfo=img_info)
|
||||||
|
|
||||||
vector_image_results.append(info)
|
vector_image_results.append(info)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user