增加对训练和推理中图片情况的判断
This commit is contained in:
@ -45,6 +45,36 @@ def get_image_pager2(image: ProjectImage, session: Session):
|
||||
return pager
|
||||
|
||||
|
||||
def check_image_label(project_id: int, img_type: str, session: Session):
|
||||
"""
|
||||
检验是否所有图片都标注
|
||||
:param project_id:
|
||||
:param img_type:
|
||||
:param session:
|
||||
:return:
|
||||
"""
|
||||
# 1 子查询
|
||||
subquery = (
|
||||
session.query(
|
||||
ProjectImgLabel.image_id,
|
||||
func.ifnull(func.count(ProjectImgLabel.id), 0).label('label_count')
|
||||
)
|
||||
.group_by(ProjectImgLabel.image_id)
|
||||
.subquery()
|
||||
)
|
||||
# 2 主查询
|
||||
query = (
|
||||
session.query(
|
||||
piModel,
|
||||
func.ifnull(subquery.c.label_count, 0).label('label_count')
|
||||
)
|
||||
.outerjoin(subquery, piModel.id == subquery.c.image_id)
|
||||
)
|
||||
query = query.filter(piModel.project_id == project_id)\
|
||||
.filter(piModel.img_type == img_type).filter(subquery.c.label_count.is_(None))
|
||||
return query.count()
|
||||
|
||||
|
||||
def check_img_name(project_id: int, img_type: str, file_name: str, session: Session):
|
||||
"""
|
||||
根据项目id和文件名称进行查重
|
||||
|
Reference in New Issue
Block a user