修改部分问题

This commit is contained in:
2025-02-26 15:06:13 +08:00
parent 584c6c5364
commit 0301e41e96
4 changed files with 43 additions and 15 deletions

View File

@ -5,7 +5,7 @@ from app.model.crud import project_image_crud as pimc
from app.model.crud import project_train_crud as ptnc from app.model.crud import project_train_crud as ptnc
from app.model.schemas.project_info_schemas import ProjectInfoIn, ProjectInfoPager from app.model.schemas.project_info_schemas import ProjectInfoIn, ProjectInfoPager
from app.model.schemas.project_label_schemas import ProjectLabel from app.model.schemas.project_label_schemas import ProjectLabel
from app.model.schemas.project_image_schemas import ProjectImgLeaferLabel from app.model.schemas.project_image_schemas import ProjectImgLeaferLabel, ProjectImagePager
from app.model.bussiness_model import ProjectLabel as pl from app.model.bussiness_model import ProjectLabel as pl
from app.common.jwt_check import get_user_id from app.common.jwt_check import get_user_id
from app.common import reponse_code as rc from app.common import reponse_code as rc
@ -147,17 +147,21 @@ def upload_project_image(project_id: int = Form(...),
return rc.response_success(msg="上传成功") return rc.response_success(msg="上传成功")
@project.get("/img_list/{project_id}") @project.get("/img_list")
def get_image_list(project_id: int, session: Session = Depends(get_db)): def get_image_list(image: ProjectImagePager, session: Session = Depends(get_db)):
""" """
获取项目图片列表 获取项目图片列表
:param project_id: 项目id :param image:
:param session: :param session:
:return: :return:
""" """
image_list = pimc.get_image_list(project_id, session) if image.pagerNum is None and image.pagerSize is None:
image_list = pimc.get_image_list(image.project_id, session)
result = jsonable_encoder(image_list) result = jsonable_encoder(image_list)
return rc.response_success(data=result) return rc.response_success(data=result)
else:
pager = pimc.get_image_pager(image, session)
return rc.response_success_pager(pager)
@project.post("/save_img_label") @project.post("/save_img_label")

View File

@ -16,7 +16,9 @@ class ProjectType(DbCommon):
class ProjectInfo(DbCommon): class ProjectInfo(DbCommon):
"""项目信息表""" """
项目信息表
"""
__tablename__ = "project_info" __tablename__ = "project_info"
project_no: Mapped[str] = mapped_column(String(32), unique=True, nullable=False) project_no: Mapped[str] = mapped_column(String(32), unique=True, nullable=False)
project_name: Mapped[str] = mapped_column(String(32), unique=True, nullable=False) project_name: Mapped[str] = mapped_column(String(32), unique=True, nullable=False)
@ -28,7 +30,9 @@ class ProjectInfo(DbCommon):
class ProjectLabel(DbCommon): class ProjectLabel(DbCommon):
"""项目标签表""" """
项目标签表
"""
__tablename__ = "project_label" __tablename__ = "project_label"
label_name: Mapped[str] = mapped_column(String(32), unique=True, nullable=False) label_name: Mapped[str] = mapped_column(String(32), unique=True, nullable=False)
project_id: Mapped[int] = mapped_column(Integer, nullable=False) project_id: Mapped[int] = mapped_column(Integer, nullable=False)
@ -36,7 +40,9 @@ class ProjectLabel(DbCommon):
class ProjectImage(DbCommon): class ProjectImage(DbCommon):
"""项目图片表""" """
项目图片表
"""
__tablename__ = "project_image" __tablename__ = "project_image"
file_name: Mapped[str] = mapped_column(String(64), nullable=False) file_name: Mapped[str] = mapped_column(String(64), nullable=False)
image_url: Mapped[str] = mapped_column(String(255), nullable=False) image_url: Mapped[str] = mapped_column(String(255), nullable=False)
@ -45,14 +51,18 @@ class ProjectImage(DbCommon):
class ProjectImgLeafer(DbCommon): class ProjectImgLeafer(DbCommon):
"""项目图片leafer表""" """
项目图片leafer表
"""
__tablename__ = "project_img_leafer" __tablename__ = "project_img_leafer"
image_id: Mapped[int] = mapped_column(Integer, nullable=False) image_id: Mapped[int] = mapped_column(Integer, nullable=False)
leafer: Mapped[dict] = mapped_column(JSON) leafer: Mapped[dict] = mapped_column(JSON)
class ProjectImgLabel(DbCommon): class ProjectImgLabel(DbCommon):
"""项目图片标签对应表一张图片对应多个label""" """
项目图片标签对应表一张图片对应多个label
"""
__tablename__ = "project_img_label" __tablename__ = "project_img_label"
image_id: Mapped[int] = mapped_column(Integer, nullable=False) image_id: Mapped[int] = mapped_column(Integer, nullable=False)
label_id: Mapped[int] = mapped_column(Integer, nullable=False) label_id: Mapped[int] = mapped_column(Integer, nullable=False)
@ -69,3 +79,13 @@ class ProjectTrain(DbCommon):
train_version: Mapped[str] = mapped_column(String(32), nullable=False) train_version: Mapped[str] = mapped_column(String(32), nullable=False)
best_pt: Mapped[str] = mapped_column(String(255), nullable=False) best_pt: Mapped[str] = mapped_column(String(255), nullable=False)
last_pt: Mapped[str] = mapped_column(String(255), nullable=False) last_pt: Mapped[str] = mapped_column(String(255), nullable=False)
class ProjectDetect(DbCommon):
"""
训练推理集合
"""
__tablename__ = "project_detect"
project_id: Mapped[str] = mapped_column(Integer, nullable=False)

View File

@ -1,5 +1,4 @@
import datetime from datetime import datetime
from pydantic import BaseModel, Field from pydantic import BaseModel, Field
from typing import Optional from typing import Optional
@ -8,7 +7,10 @@ class ProjectTrainOut(BaseModel):
"""项目训练版本信息表""" """项目训练版本信息表"""
id: Optional[int] = Field(None, description="训练id") id: Optional[int] = Field(None, description="训练id")
train_version: Optional[str] = Field(None, description="训练版本号") train_version: Optional[str] = Field(None, description="训练版本号")
create_time: Optional[datetime.datetime] = Field(None, description="训练时间") create_time: Optional[datetime] = Field(None, description="训练时间")
class Config: class Config:
orm_mode = True orm_mode = True
json_encoders = {
datetime: lambda v: v.strftime("%Y-%m-%d %H:%M:%S")
}

View File

@ -95,6 +95,8 @@ def get_img_leafer(image_id: int, session: Session):
:return: :return:
""" """
img_leafer = pillc.get_img_leafer(image_id, session) img_leafer = pillc.get_img_leafer(image_id, session)
if img_leafer is None:
return None
img_leafer_out = ProjectImgLeaferOut.from_orm(img_leafer).dict() img_leafer_out = ProjectImgLeaferOut.from_orm(img_leafer).dict()
return img_leafer_out return img_leafer_out