完善推理模块的主体功能
This commit is contained in:
@ -4,7 +4,7 @@ from starlette.responses import FileResponse
|
|||||||
from sqlalchemy.orm import Session
|
from sqlalchemy.orm import Session
|
||||||
|
|
||||||
from app.model.crud.project_image_crud import get_img_url
|
from app.model.crud.project_image_crud import get_img_url
|
||||||
from app.model.crud.project_detect_crud import get_detect_img_url
|
from app.model.crud.project_detect_crud import get_detect_img_url, get_log_img_url
|
||||||
from app.config.config_reader import images_url
|
from app.config.config_reader import images_url
|
||||||
from app.db.db_session import get_db
|
from app.db.db_session import get_db
|
||||||
|
|
||||||
@ -75,4 +75,19 @@ def view_detect_thumb(image_id: int, session: Session = Depends(get_db)):
|
|||||||
return FileResponse(image_path, media_type='image/jpeg')
|
return FileResponse(image_path, media_type='image/jpeg')
|
||||||
|
|
||||||
|
|
||||||
|
@view.get("/view_log_img/{image_id}")
|
||||||
|
def view_log_img(image_id: int, session: Session = Depends(get_db)):
|
||||||
|
"""
|
||||||
|
查看推理完成后图片
|
||||||
|
:param session:
|
||||||
|
:param image_id: 图片id
|
||||||
|
:return:
|
||||||
|
"""
|
||||||
|
url = get_log_img_url(image_id, session)
|
||||||
|
image_path = os.path.join(url)
|
||||||
|
# 检查文件是否存在以及是否是文件
|
||||||
|
if not os.path.isfile(image_path):
|
||||||
|
raise HTTPException(status_code=404, detail="Image not found")
|
||||||
|
return FileResponse(image_path, media_type='image/jpeg')
|
||||||
|
|
||||||
|
|
||||||
|
@ -5,7 +5,7 @@ from jwt import PyJWTError
|
|||||||
from app.common import reponse_code as rc
|
from app.common import reponse_code as rc
|
||||||
from app.common import jwt_check as jc
|
from app.common import jwt_check as jc
|
||||||
|
|
||||||
green = ['/login', '/view_img', 'view_thumb']
|
green = ['/login', '/view_img', 'view_thumb', 'view_detect_img', 'view_detect_thumb', 'view_log_img']
|
||||||
|
|
||||||
|
|
||||||
def check_green(s: str):
|
def check_green(s: str):
|
||||||
|
@ -171,3 +171,10 @@ def get_log_imgs(log_id: int, session: Session):
|
|||||||
result = [ProjectDetectLogImgOut.from_orm(img) for img in query.all()]
|
result = [ProjectDetectLogImgOut.from_orm(img) for img in query.all()]
|
||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
def get_log_img_url(img_id: int, session: Session):
|
||||||
|
result = session.query(ProjectDetectLogImg).filter_by(id=img_id).first()
|
||||||
|
if result is None:
|
||||||
|
return None
|
||||||
|
else:
|
||||||
|
return result.image_url
|
||||||
|
@ -64,7 +64,7 @@ class ProjectDetectLogOut(BaseModel):
|
|||||||
detect_version: Optional[str]
|
detect_version: Optional[str]
|
||||||
detect_name: Optional[str]
|
detect_name: Optional[str]
|
||||||
train_id: Optional[int]
|
train_id: Optional[int]
|
||||||
train_version: Optional[int]
|
train_version: Optional[str]
|
||||||
pt_type: Optional[str]
|
pt_type: Optional[str]
|
||||||
create_time: Optional[datetime]
|
create_time: Optional[datetime]
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user