from app.db.db_base import DbCommon from sqlalchemy import String, Integer, JSON from sqlalchemy.orm import Mapped, mapped_column class ProjectType(DbCommon): """ 项目类别表 - 标识项目的类型目前存在的(目标识别,OCR识别,瑕疵检测,图像分类) """ __tablename__ = "project_type" type_code: Mapped[str] = mapped_column(String(20), unique=True, nullable=False) type_name: Mapped[str] = mapped_column(String(20)) icon_path: Mapped[str] = mapped_column(String(255)) description: Mapped[str] = mapped_column(String(255)) type_status: Mapped[str] = mapped_column(String(10)) class ProjectInfo(DbCommon): """ 项目信息表 """ __tablename__ = "project_info" project_no: Mapped[str] = mapped_column(String(32), unique=True, nullable=False) project_name: Mapped[str] = mapped_column(String(32), unique=True, nullable=False) type_code: Mapped[str] = mapped_column(String(10)) description: Mapped[str] = mapped_column(String(255)) project_status: Mapped[str] = mapped_column(String(10)) user_id: Mapped[int] = mapped_column(Integer) train_version: Mapped[int] = mapped_column(Integer) del_flag: Mapped[int] = mapped_column(Integer) class ProjectLabel(DbCommon): """ 项目标签表 """ __tablename__ = "project_label" label_name: Mapped[str] = mapped_column(String(32), unique=True, nullable=False) project_id: Mapped[int] = mapped_column(Integer, nullable=False) meta: Mapped[dict] = mapped_column(JSON) class ProjectImage(DbCommon): """ 项目图片表 """ __tablename__ = "project_image" img_type: Mapped[str] = mapped_column(String(10)) file_name: Mapped[str] = mapped_column(String(64), nullable=False) image_url: Mapped[str] = mapped_column(String(255), nullable=False) thumb_image_url: Mapped[str] = mapped_column(String(255), nullable=False) project_id: Mapped[int] = mapped_column(Integer) class ProjectImgLeafer(DbCommon): """ 项目图片leafer表 """ __tablename__ = "project_img_leafer" image_id: Mapped[int] = mapped_column(Integer, nullable=False) leafer: Mapped[dict] = mapped_column(JSON) class ProjectImgLabel(DbCommon): """ 项目图片标签对应表,一张图片对应多个label """ __tablename__ = "project_img_label" image_id: Mapped[int] = mapped_column(Integer, nullable=False) label_id: Mapped[int] = mapped_column(Integer, nullable=False) mark_center_x: Mapped[str] = mapped_column(String(64), nullable=False) mark_center_y: Mapped[str] = mapped_column(String(64), nullable=False) mark_width: Mapped[str] = mapped_column(String(64), nullable=False) mark_height: Mapped[str] = mapped_column(String(64), nullable=False) class ProjectTrain(DbCommon): """ 项目训练版本信息表 """ __tablename__ = "project_train" project_id: Mapped[int] = mapped_column(Integer, nullable=False) train_version: Mapped[str] = mapped_column(String(32), nullable=False) best_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[int] = mapped_column(Integer, nullable=False) detect_name: Mapped[str] = mapped_column(String(64), nullable=False) detect_version: Mapped[int] = mapped_column(Integer) detect_no: Mapped[str] = mapped_column(String(32)) detect_status: Mapped[int] = mapped_column(Integer) file_type: Mapped[str] = mapped_column(String(10)) folder_url: Mapped[str] = mapped_column(String(255)) class ProjectDetectImg(DbCommon): """ 推理之前的图片 """ __tablename__ = "project_detect_img" detect_id: Mapped[int] = mapped_column(Integer, nullable=False) file_name: Mapped[str] = mapped_column(String(64), nullable=False) image_url: Mapped[str] = mapped_column(String(255), nullable=False) thumb_image_url: Mapped[str] = mapped_column(String(255), nullable=False) class ProjectDetectLog(DbCommon): """ 项目推理记录 """ __tablename__ = "project_detect_log" detect_id: Mapped[int] = mapped_column(Integer, nullable=False) detect_version: Mapped[str] = mapped_column(String(10)) detect_name: Mapped[str] = mapped_column(String(64), nullable=False) train_id: Mapped[int] = mapped_column(Integer, nullable=False) train_version: Mapped[str] = mapped_column(String(10)) pt_type: Mapped[str] = mapped_column(String(10)) pt_url: Mapped[str] = mapped_column(String(255)) folder_url: Mapped[str] = mapped_column(String(255)) detect_folder_url: Mapped[str] = mapped_column(String(255)) class ProjectDetectLogImg(DbCommon): """ 推理完成的图片 """ __tablename__ = "project_detect_log_img" log_id: Mapped[int] = mapped_column(Integer, nullable=False) file_name: Mapped[str] = mapped_column(String(64), nullable=False) image_url: Mapped[str] = mapped_column(String(255), nullable=False)