You've already forked DataMate
feat(annotation): 添加标注类型显示功能
- 在前端页面中新增标注类型列并使用Tag组件展示 - 添加AnnotationTypeMap常量用于标注类型的映射 - 修改接口定义支持labelingType字段的传递 - 更新后端项目创建和更新逻辑以存储标注类型 - 添加标注类型配置键常量统一管理 - 扩展数据传输对象支持标注类型属性 - 实现模板标注类型的继承逻辑
This commit is contained in:
@@ -7,7 +7,7 @@ from datetime import datetime
|
||||
import uuid
|
||||
|
||||
from app.core.logging import get_logger
|
||||
from app.db.models import LabelingProject, AnnotationTemplate, AnnotationResult, LabelingProjectFile
|
||||
from app.db.models import LabelingProject, AnnotationResult, LabelingProjectFile
|
||||
from app.db.models.annotation_management import ANNOTATION_STATUS_IN_PROGRESS
|
||||
from app.db.models.dataset_management import Dataset, DatasetFiles
|
||||
from app.module.annotation.schema import (
|
||||
@@ -18,6 +18,7 @@ from app.module.annotation.schema import (
|
||||
)
|
||||
|
||||
logger = get_logger(__name__)
|
||||
LABELING_TYPE_CONFIG_KEY = "labeling_type"
|
||||
|
||||
class DatasetMappingService:
|
||||
"""数据集映射服务"""
|
||||
@@ -106,10 +107,12 @@ class DatasetMappingService:
|
||||
label_config = None
|
||||
description = None
|
||||
segmentation_enabled = None
|
||||
labeling_type = None
|
||||
if isinstance(configuration, dict):
|
||||
label_config = configuration.get('label_config')
|
||||
description = configuration.get('description')
|
||||
segmentation_enabled = configuration.get('segmentation_enabled')
|
||||
labeling_type = configuration.get(LABELING_TYPE_CONFIG_KEY)
|
||||
|
||||
# Optionally fetch full template details
|
||||
template_response = None
|
||||
@@ -119,6 +122,9 @@ class DatasetMappingService:
|
||||
template_response = await template_service.get_template(self.db, template_id)
|
||||
logger.debug(f"Included template details for template_id: {template_id}")
|
||||
|
||||
if not labeling_type and template_response:
|
||||
labeling_type = getattr(template_response, "labeling_type", None)
|
||||
|
||||
# 获取统计数据
|
||||
total_count, annotated_count, in_progress_count = await self._get_project_stats(
|
||||
mapping.id, mapping.dataset_id
|
||||
@@ -132,6 +138,7 @@ class DatasetMappingService:
|
||||
"name": mapping.name,
|
||||
"description": description,
|
||||
"template_id": template_id,
|
||||
"labeling_type": labeling_type,
|
||||
"template": template_response,
|
||||
"label_config": label_config,
|
||||
"segmentation_enabled": segmentation_enabled,
|
||||
@@ -174,10 +181,12 @@ class DatasetMappingService:
|
||||
label_config = None
|
||||
description = None
|
||||
segmentation_enabled = None
|
||||
labeling_type = None
|
||||
if isinstance(configuration, dict):
|
||||
label_config = configuration.get('label_config')
|
||||
description = configuration.get('description')
|
||||
segmentation_enabled = configuration.get('segmentation_enabled')
|
||||
labeling_type = configuration.get(LABELING_TYPE_CONFIG_KEY)
|
||||
|
||||
# Optionally fetch full template details
|
||||
template_response = None
|
||||
@@ -187,6 +196,9 @@ class DatasetMappingService:
|
||||
template_response = await template_service.get_template(self.db, template_id)
|
||||
logger.debug(f"Included template details for template_id: {template_id}")
|
||||
|
||||
if not labeling_type and template_response:
|
||||
labeling_type = getattr(template_response, "labeling_type", None)
|
||||
|
||||
# 获取统计数据
|
||||
total_count, annotated_count, in_progress_count = 0, 0, 0
|
||||
if dataset_id:
|
||||
@@ -203,6 +215,7 @@ class DatasetMappingService:
|
||||
"name": mapping.name,
|
||||
"description": description,
|
||||
"template_id": template_id,
|
||||
"labeling_type": labeling_type,
|
||||
"template": template_response,
|
||||
"label_config": label_config,
|
||||
"segmentation_enabled": segmentation_enabled,
|
||||
|
||||
Reference in New Issue
Block a user