feat 代码整理

fix
This commit is contained in:
zhouchengrong
2024-09-25 11:13:25 +08:00
parent 9b940c9cf8
commit e62b35a721
4 changed files with 19 additions and 23 deletions

View File

@@ -7,7 +7,6 @@ from fastapi import APIRouter, HTTPException, UploadFile, File, Form
from app.schemas.design import DesignModel, DesignProgressModel, ModelProgressModel, DBGConfigModel
from app.schemas.response_template import ResponseModel
from app.service.design.model_process_service import model_transpose
from app.service.design.service import generate
from app.service.design.service_design_batch_generate import start_design_batch_generate
from app.service.design.utils.redis_utils import Redis
from app.service.design_test.batch_design import design_generate
@@ -185,17 +184,14 @@ def design(request_data: DesignModel):
# data = generate(request_data=request_data)
# logger.info(f"design response @@@@@@:{json.dumps(data)}")
#
logger.info(f"design request item is : @@@@@@:{json.dumps(request_data.dict())}")
data = design_generate(request_data=request_data)
logger.info(f"design response @@@@@@:{json.dumps(data)}")
# try:
# logger.info(f"design request item is : @@@@@@:{json.dumps(request_data.dict())}")
# data = generate(request_data=request_data)
# logger.info(f"design response @@@@@@:{json.dumps(data)}")
# except Exception as e:
# logger.warning(f"design Run Exception @@@@@@:{e}")
# raise HTTPException(status_code=404, detail=str(e))
try:
logger.info(f"design request item is : @@@@@@:{json.dumps(request_data.dict())}")
data = design_generate(request_data=request_data)
logger.info(f"design response @@@@@@:{json.dumps(data)}")
except Exception as e:
logger.warning(f"design Run Exception @@@@@@:{e}")
raise HTTPException(status_code=404, detail=str(e))
return ResponseModel(data=data)

View File

@@ -48,9 +48,9 @@ class Segmentation:
file_path = f"{SEG_CACHE_PATH}{image_id}.npy"
try:
np.save(file_path, seg_result)
print("保存成功", os.path.abspath(file_path))
logging.info("保存成功", os.path.abspath(file_path))
except Exception as e:
print(f"保存失败: {e}")
logger.error(f"保存失败: {e}")
@staticmethod
def load_seg_result(image_id):
@@ -60,8 +60,8 @@ class Segmentation:
seg_result = np.load(file_path)
return True, seg_result
except FileNotFoundError:
print("文件不存在")
logger.warning("文件不存在")
return False, None
except Exception as e:
print(f"加载失败: {e}")
logger.error(f"加载失败: {e}")
return False, None

View File

@@ -53,9 +53,9 @@ class Segmentation(object):
file_path = f"{SEG_CACHE_PATH}{image_id}.npy"
try:
np.save(file_path, seg_result)
print("保存成功", os.path.abspath(file_path))
logger.info("保存成功", os.path.abspath(file_path))
except Exception as e:
print(f"保存失败: {e}")
logger.error(f"保存失败: {e}")
@staticmethod
def load_seg_result(image_id):
@@ -64,8 +64,8 @@ class Segmentation(object):
seg_result = np.load(file_path)
return True, seg_result
except FileNotFoundError:
print("文件不存在")
logger.warning("文件不存在")
return False, None
except Exception as e:
print(f"加载失败: {e}")
logger.error(f"加载失败: {e}")
return False, None

View File

@@ -51,9 +51,9 @@ class Segmentation:
file_path = f"{SEG_CACHE_PATH}{image_id}.npy"
try:
np.save(file_path, seg_result)
print("保存成功", os.path.abspath(file_path))
logger.info("保存成功", os.path.abspath(file_path))
except Exception as e:
print(f"保存失败: {e}")
logger.error(f"保存失败: {e}")
@staticmethod
def load_seg_result(image_id):
@@ -63,8 +63,8 @@ class Segmentation:
seg_result = np.load(file_path)
return True, seg_result
except FileNotFoundError:
print("文件不存在")
logger.warning("文件不存在")
return False, None
except Exception as e:
print(f"加载失败: {e}")
logger.error(f"加载失败: {e}")
return False, None