edit: ict센터입고세팅을 기본값으로 설정, ict 설정시 sftp비활성화, l14_336 사용 못하던것 수정
This commit is contained in:
@@ -49,12 +49,11 @@ class Config:
|
||||
|
||||
|
||||
@dataclass
|
||||
class LocalConfig(Config):
|
||||
class ReleaseConfig(Config):
|
||||
TRUSTED_HOSTS = ['*']
|
||||
ALLOW_SITE = ['*']
|
||||
DEBUG: bool = True
|
||||
|
||||
|
||||
@dataclass
|
||||
class ProdConfig(Config):
|
||||
TRUSTED_HOSTS = ['*']
|
||||
@@ -74,8 +73,6 @@ class DevConfig(Config):
|
||||
TRUSTED_HOSTS = ['*']
|
||||
ALLOW_SITE = ['*']
|
||||
DEBUG: bool = True
|
||||
DB_URL: str = environ.get('DB_URL', f'mysql+pymysql://{consts.DB_USER_ID}:{consts.DB_USER_PW}@{consts.DB_ADDRESS}/{consts.DB_NAME}_dev?charset={consts.DB_CHARSET}')
|
||||
REST_SERVER_PORT = consts.REST_SERVER_PORT + 1
|
||||
|
||||
SW_TITLE = '[Dev] ' + consts.SW_TITLE
|
||||
|
||||
@@ -103,9 +100,11 @@ def conf():
|
||||
환경 불러오기
|
||||
:return:
|
||||
"""
|
||||
config = dict(prod=ProdConfig, local=LocalConfig, test=TestConfig, dev=DevConfig, my=MyConfig)
|
||||
return config[environ.get('API_ENV', 'local')]()
|
||||
return config[environ.get('API_ENV', 'dev')]()
|
||||
return config[environ.get('API_ENV', 'my')]()
|
||||
return config[environ.get('API_ENV', 'test')]()
|
||||
from config import rest_config
|
||||
|
||||
config = dict(prod=ProdConfig, release=ReleaseConfig, test=TestConfig, dev=DevConfig, my=MyConfig)
|
||||
return config[environ.get('API_ENV', rest_config.config)]()
|
||||
# return config[environ.get('API_ENV', 'dev')]()
|
||||
# return config[environ.get('API_ENV', 'my')]()
|
||||
# return config[environ.get('API_ENV', 'test')]()
|
||||
|
||||
|
||||
@@ -20,9 +20,9 @@ from main_rest.app.utils.date_utils import D
|
||||
from main_rest.app.utils.parsing_utils import image_to_base64_string
|
||||
from custom_logger.main_log import main_logger as LOG
|
||||
|
||||
from custom_apps.bingimagecreator.utils import DallEArgument,dalle3_generate_image
|
||||
from custom_apps.bingart.bingart import BingArtGenerator
|
||||
from custom_apps.imagen.custom_imagen import imagen_generate_image, imagen_generate_image_path, imagen_generate_temp_image_path
|
||||
# from custom_apps.bingimagecreator.utils import DallEArgument,dalle3_generate_image
|
||||
# from custom_apps.bingart.bingart import BingArtGenerator
|
||||
# from custom_apps.imagen.custom_imagen import imagen_generate_image, imagen_generate_image_path, imagen_generate_temp_image_path
|
||||
from custom_apps.utils import cookie_manager
|
||||
from custom_apps.gemini.main import gemini_image
|
||||
from main_rest.app.utils.parsing_utils import download_range
|
||||
@@ -144,12 +144,17 @@ async def imagen(request: Request, request_body_info: M.ImageGenerateReq):
|
||||
# download_count=request_body_info.downloadCount
|
||||
# )
|
||||
temp_image_path = gemini_image(request_body_info.prompt)
|
||||
_remote_folder = os.path.join(rest_config.remote_folder,"imagen")
|
||||
|
||||
# remote save
|
||||
sftp_client.remote_copy_data(
|
||||
temp_image_path,
|
||||
os.path.join(_remote_folder,f"imagen_{request_body_info.prompt}_{1}_{D.date_file_name()}.png"))
|
||||
|
||||
if rest_config.config != 'release':
|
||||
_remote_folder = os.path.join(rest_config.remote_folder,"imagen")
|
||||
# remote save
|
||||
sftp_client.remote_copy_data(
|
||||
temp_image_path,
|
||||
os.path.join(_remote_folder,f"imagen_{request_body_info.prompt}_{1}_{D.date_file_name()}.png"))
|
||||
else:
|
||||
_local_forder = os.path.join(rest_config.local_folder,"image_generate","imagen")
|
||||
os.makedirs(_local_forder,exist_ok=True)
|
||||
shutil.copy(temp_image_path, os.path.join(_local_forder,f"imagen_{request_body_info.prompt}_{1}_{D.date_file_name()}.png"))
|
||||
|
||||
# Clean up temporary files
|
||||
if 'temp_image_path' in locals():
|
||||
@@ -266,16 +271,26 @@ async def vactor_vit(request: Request, request_body_info: M.VectorImageSearchVit
|
||||
result_image_paths = vector_response_dict.get('img_list').get('result_image_paths')
|
||||
result_percents = vector_response_dict.get('img_list').get('result_percents')
|
||||
|
||||
# 원격지 폴더 생성
|
||||
remote_directory = os.path.join(rest_config.remote_folder, f"imagen_query_{request_body_info.modelType}_{request_body_info.indexType}_{request_body_info.prompt}_{D.date_file_name()}")
|
||||
sftp_client.remote_mkdir(remote_directory)
|
||||
|
||||
# 원격지에 이미지 저장
|
||||
sftp_client.remote_copy_data(local_path=query_image_path, remote_path=os.path.join(remote_directory,"query.png"))
|
||||
|
||||
for img_path, img_percent in zip(result_image_paths,result_percents):
|
||||
sftp_client.remote_copy_data(local_path=img_path, remote_path=os.path.join(remote_directory,f"search_{img_percent}.png"))
|
||||
|
||||
if rest_config.config != 'release':
|
||||
# 원격지 폴더 생성
|
||||
remote_directory = os.path.join(rest_config.remote_folder, f"imagen_query_{request_body_info.modelType}_{request_body_info.indexType}_{request_body_info.prompt}_{D.date_file_name()}")
|
||||
sftp_client.remote_mkdir(remote_directory)
|
||||
|
||||
# 원격지에 이미지 저장
|
||||
sftp_client.remote_copy_data(local_path=query_image_path, remote_path=os.path.join(remote_directory,"query.png"))
|
||||
|
||||
for img_path, img_percent in zip(result_image_paths,result_percents):
|
||||
sftp_client.remote_copy_data(local_path=img_path, remote_path=os.path.join(remote_directory,f"search_{img_percent}.png"))
|
||||
else:
|
||||
local_directory = os.path.join(rest_config.local_folder, f"imagen_query_{request_body_info.modelType}_{request_body_info.indexType}_{request_body_info.prompt}_{D.date_file_name()}")
|
||||
os.makedirs(local_directory, exist_ok=True)
|
||||
|
||||
shutil.copy(query_image_path, os.path.join(local_directory,"query.png"))
|
||||
|
||||
for img_path, img_percent in zip(result_image_paths,result_percents):
|
||||
shutil.copy(img_path, os.path.join(local_directory,f"search_{img_percent}.png"))
|
||||
|
||||
|
||||
# Clean up temporary files
|
||||
if 'query_image_path' in locals():
|
||||
if os.path.exists(query_image_path):
|
||||
@@ -414,10 +429,13 @@ async def vactor_vit_report(request: Request, request_body_info: M.VectorImageSe
|
||||
if json.loads(vactor_response.text)["error"] != None:
|
||||
raise Exception(f"vector error: {json.loads(vactor_response.text)['error']}")
|
||||
|
||||
# remote 폴더에 이미지 저장
|
||||
sftp_client.remote_copy_data(local_path=report_image_path,
|
||||
remote_path=os.path.join(rest_config.remote_folder, f"imagen_report_vit_{request_body_info.prompt}_{D.date_file_name()}.png"))
|
||||
|
||||
if rest_config.config != 'release':
|
||||
# remote 폴더에 이미지 저장
|
||||
sftp_client.remote_copy_data(local_path=report_image_path,
|
||||
remote_path=os.path.join(rest_config.remote_folder, f"imagen_report_vit_{request_body_info.prompt}_{D.date_file_name()}.png"))
|
||||
else:
|
||||
shutil.copy(report_image_path, os.path.join(rest_config.local_folder, f"imagen_report_vit_{request_body_info.prompt}_{D.date_file_name()}.png"))
|
||||
|
||||
# Clean up temporary files
|
||||
if 'query_image_path' in locals():
|
||||
if os.path.exists(query_image_path):
|
||||
|
||||
Reference in New Issue
Block a user