修改数据标注:标注模板到主流语言。

This commit is contained in:
uname
2025-12-09 20:00:43 +08:00
parent 015e738a7f
commit a728bc3100
2 changed files with 85 additions and 130 deletions

View File

@@ -19,61 +19,61 @@ const TemplateDetail: React.FC<TemplateDetailProps> = ({
return (
<Modal
title="Template Details"
title="模板详情"
open={visible}
onCancel={onClose}
footer={null}
width={800}
>
<Descriptions bordered column={2}>
<Descriptions.Item label="Name" span={2}>
<Descriptions.Item label="名称" span={2}>
{template.name}
</Descriptions.Item>
<Descriptions.Item label="Description" span={2}>
<Descriptions.Item label="描述" span={2}>
{template.description || "-"}
</Descriptions.Item>
<Descriptions.Item label="Data Type">
<Descriptions.Item label="数据类型">
<Tag color="cyan">{template.dataType}</Tag>
</Descriptions.Item>
<Descriptions.Item label="Labeling Type">
<Descriptions.Item label="标注类型">
<Tag color="geekblue">{template.labelingType}</Tag>
</Descriptions.Item>
<Descriptions.Item label="Category">
<Descriptions.Item label="分类">
<Tag color="blue">{template.category}</Tag>
</Descriptions.Item>
<Descriptions.Item label="Style">
<Descriptions.Item label="样式">
{template.style}
</Descriptions.Item>
<Descriptions.Item label="Type">
<Descriptions.Item label="类型">
<Tag color={template.builtIn ? "gold" : "default"}>
{template.builtIn ? "Built-in" : "Custom"}
{template.builtIn ? "系统内置" : "自定义"}
</Tag>
</Descriptions.Item>
<Descriptions.Item label="Version">
<Descriptions.Item label="版本">
{template.version}
</Descriptions.Item>
<Descriptions.Item label="Created At" span={2}>
<Descriptions.Item label="创建时间" span={2}>
{new Date(template.createdAt).toLocaleString()}
</Descriptions.Item>
{template.updatedAt && (
<Descriptions.Item label="Updated At" span={2}>
<Descriptions.Item label="更新时间" span={2}>
{new Date(template.updatedAt).toLocaleString()}
</Descriptions.Item>
)}
</Descriptions>
<Divider>Configuration</Divider>
<Divider></Divider>
<Card title="Data Objects" size="small" style={{ marginBottom: 16 }}>
<Card title="数据对象" size="small" style={{ marginBottom: 16 }}>
<Space direction="vertical" style={{ width: "100%" }}>
{template.configuration.objects.map((obj, index) => (
<Card key={index} size="small" type="inner">
<Space>
<Text strong>Name:</Text>
<Text strong></Text>
<Tag>{obj.name}</Tag>
<Text strong>Type:</Text>
<Text strong></Text>
<Tag color="blue">{obj.type}</Tag>
<Text strong>Value:</Text>
<Text strong></Text>
<Tag color="green">{obj.value}</Tag>
</Space>
</Card>
@@ -81,31 +81,34 @@ const TemplateDetail: React.FC<TemplateDetailProps> = ({
</Space>
</Card>
<Card title="Label Controls" size="small" style={{ marginBottom: 16 }}>
<Card title="标注控件" size="small" style={{ marginBottom: 16 }}>
<Space direction="vertical" style={{ width: "100%" }} size="middle">
{template.configuration.labels.map((label, index) => (
<Card key={index} size="small" type="inner" title={`Control ${index + 1}`}>
<Card key={index} size="small" type="inner" title={`控件 ${index + 1}`}>
<Space direction="vertical" style={{ width: "100%" }}>
<div>
<Text strong>From Name: </Text>
<Text strong></Text>
<Tag>{label.fromName}</Tag>
<Text strong style={{ marginLeft: 16 }}>To Name: </Text>
<Text strong style={{ marginLeft: 16 }}></Text>
<Tag>{label.toName}</Tag>
<Text strong style={{ marginLeft: 16 }}>Type: </Text>
<Text strong style={{ marginLeft: 16 }}></Text>
<Tag color="purple">{label.type}</Tag>
{label.required && <Tag color="red">Required</Tag>}
{label.required && <Tag color="red"></Tag>}
</div>
{label.description && (
<div>
<Text strong>Description: </Text>
<Text strong></Text>
<Text type="secondary">{label.description}</Text>
</div>
)}
{label.options && label.options.length > 0 && (
<div>
<Text strong>Options: </Text>
<Text strong></Text>
<div style={{ marginTop: 4 }}>
{label.options.map((opt, i) => (
<Tag key={i} color="cyan">{opt}</Tag>
@@ -116,7 +119,7 @@ const TemplateDetail: React.FC<TemplateDetailProps> = ({
{label.labels && label.labels.length > 0 && (
<div>
<Text strong>Labels: </Text>
<Text strong></Text>
<div style={{ marginTop: 4 }}>
{label.labels.map((lbl, i) => (
<Tag key={i} color="geekblue">{lbl}</Tag>
@@ -131,7 +134,7 @@ const TemplateDetail: React.FC<TemplateDetailProps> = ({
</Card>
{template.labelConfig && (
<Card title="Label Studio XML Configuration" size="small">
<Card title="Label Studio XML 配置" size="small">
<Paragraph>
<pre style={{
background: "#f5f5f5",

View File

@@ -44,23 +44,14 @@ CREATE TABLE t_dm_labeling_projects (
-- 1. 图像分类模板
INSERT INTO t_dm_annotation_templates (
id,
name,
description,
data_type,
labeling_type,
configuration,
style,
category,
built_in,
version,
created_at
id, name, description, data_type, labeling_type,
configuration, style, category, built_in, version, created_at
) VALUES (
'tpl-image-classification-001',
'Image Classification',
'Simple image classification with multiple choice labels',
'image',
'classification',
'图像分类',
'简单的多标签图像分类模板',
'图像',
'分类',
JSON_OBJECT(
'labels', JSON_ARRAY(
JSON_OBJECT(
@@ -69,7 +60,7 @@ INSERT INTO t_dm_annotation_templates (
'type', 'Choices',
'options', JSON_ARRAY('Cat', 'Dog', 'Bird', 'Other'),
'required', true,
'description', 'Select the category that best describes the image'
'description', '选择最符合图像内容的标签'
)
),
'objects', JSON_ARRAY(
@@ -81,7 +72,7 @@ INSERT INTO t_dm_annotation_templates (
)
),
'horizontal',
'computer-vision',
'计算机视觉',
1,
'1.0.0',
NOW()
@@ -98,25 +89,17 @@ ON DUPLICATE KEY UPDATE
version = VALUES(version),
updated_at = NOW();
-- 2. 目标检测模板(矩形框)
INSERT INTO t_dm_annotation_templates (
id,
name,
description,
data_type,
labeling_type,
configuration,
style,
category,
built_in,
version,
created_at
id, name, description, data_type, labeling_type,
configuration, style, category, built_in, version, created_at
) VALUES (
'tpl-object-detection-001',
'Object Detection (Bounding Box)',
'Object detection using rectangular bounding boxes',
'image',
'object-detection',
'目标检测(边界框)',
'使用矩形边界框进行目标检测',
'图像',
'目标检测',
JSON_OBJECT(
'labels', JSON_ARRAY(
JSON_OBJECT(
@@ -125,7 +108,7 @@ INSERT INTO t_dm_annotation_templates (
'type', 'RectangleLabels',
'labels', JSON_ARRAY('Person', 'Vehicle', 'Animal', 'Object'),
'required', false,
'description', 'Draw bounding boxes around objects'
'description', '在图像中框出目标并标注类别'
)
),
'objects', JSON_ARRAY(
@@ -137,7 +120,7 @@ INSERT INTO t_dm_annotation_templates (
)
),
'horizontal',
'computer-vision',
'计算机视觉',
1,
'1.0.0',
NOW()
@@ -154,25 +137,17 @@ ON DUPLICATE KEY UPDATE
version = VALUES(version),
updated_at = NOW();
-- 3. 图像分割模板(多边形)
INSERT INTO t_dm_annotation_templates (
id,
name,
description,
data_type,
labeling_type,
configuration,
style,
category,
built_in,
version,
created_at
id, name, description, data_type, labeling_type,
configuration, style, category, built_in, version, created_at
) VALUES (
'tpl-image-segmentation-001',
'Image Segmentation (Polygon)',
'Semantic segmentation using polygon annotations',
'image',
'segmentation',
'图像分割(多边形)',
'使用多边形标注进行语义分割',
'图像',
'分割',
JSON_OBJECT(
'labels', JSON_ARRAY(
JSON_OBJECT(
@@ -181,7 +156,7 @@ INSERT INTO t_dm_annotation_templates (
'type', 'PolygonLabels',
'labels', JSON_ARRAY('Background', 'Foreground', 'Person', 'Car'),
'required', false,
'description', 'Draw polygons to segment regions'
'description', '使用多边形框选需要分割的区域'
)
),
'objects', JSON_ARRAY(
@@ -193,7 +168,7 @@ INSERT INTO t_dm_annotation_templates (
)
),
'horizontal',
'computer-vision',
'计算机视觉',
1,
'1.0.0',
NOW()
@@ -210,25 +185,17 @@ ON DUPLICATE KEY UPDATE
version = VALUES(version),
updated_at = NOW();
-- 4. 文本分类模板
INSERT INTO t_dm_annotation_templates (
id,
name,
description,
data_type,
labeling_type,
configuration,
style,
category,
built_in,
version,
created_at
id, name, description, data_type, labeling_type,
configuration, style, category, built_in, version, created_at
) VALUES (
'tpl-text-classification-001',
'Text Classification',
'Classify text into predefined categories',
'text',
'classification',
'文本分类',
'将文本划分到预定义的类别',
'文本',
'分类',
JSON_OBJECT(
'labels', JSON_ARRAY(
JSON_OBJECT(
@@ -237,7 +204,7 @@ INSERT INTO t_dm_annotation_templates (
'type', 'Choices',
'options', JSON_ARRAY('Positive', 'Negative', 'Neutral'),
'required', true,
'description', 'Sentiment classification'
'description', '对文本的情感或类别进行选择'
)
),
'objects', JSON_ARRAY(
@@ -249,7 +216,7 @@ INSERT INTO t_dm_annotation_templates (
)
),
'vertical',
'nlp',
'自然语言处理',
1,
'1.0.0',
NOW()
@@ -266,25 +233,17 @@ ON DUPLICATE KEY UPDATE
version = VALUES(version),
updated_at = NOW();
-- 5. 命名实体识别(NER)模板
-- 5. 命名实体识别(NER)
INSERT INTO t_dm_annotation_templates (
id,
name,
description,
data_type,
labeling_type,
configuration,
style,
category,
built_in,
version,
created_at
id, name, description, data_type, labeling_type,
configuration, style, category, built_in, version, created_at
) VALUES (
'tpl-ner-001',
'Named Entity Recognition',
'Extract and label named entities in text',
'text',
'ner',
'命名实体识别',
'从文本中抽取并标注命名实体',
'文本',
'实体识别',
JSON_OBJECT(
'labels', JSON_ARRAY(
JSON_OBJECT(
@@ -293,7 +252,7 @@ INSERT INTO t_dm_annotation_templates (
'type', 'Labels',
'labels', JSON_ARRAY('PERSON', 'ORG', 'LOC', 'DATE', 'MISC'),
'required', false,
'description', 'Highlight and classify named entities'
'description', '在文本中标注人物、地点等实体'
)
),
'objects', JSON_ARRAY(
@@ -305,7 +264,7 @@ INSERT INTO t_dm_annotation_templates (
)
),
'vertical',
'nlp',
'自然语言处理',
1,
'1.0.0',
NOW()
@@ -322,25 +281,17 @@ ON DUPLICATE KEY UPDATE
version = VALUES(version),
updated_at = NOW();
-- 6. 音频分类模板
INSERT INTO t_dm_annotation_templates (
id,
name,
description,
data_type,
labeling_type,
configuration,
style,
category,
built_in,
version,
created_at
id, name, description, data_type, labeling_type,
configuration, style, category, built_in, version, created_at
) VALUES (
'tpl-audio-classification-001',
'Audio Classification',
'Classify audio clips into categories',
'audio',
'classification',
'音频分类',
'将音频片段划分到不同类别',
'音频',
'分类',
JSON_OBJECT(
'labels', JSON_ARRAY(
JSON_OBJECT(
@@ -349,7 +300,7 @@ INSERT INTO t_dm_annotation_templates (
'type', 'Choices',
'options', JSON_ARRAY('Speech', 'Music', 'Noise', 'Silence'),
'required', true,
'description', 'Audio content classification'
'description', '选择音频片段对应的类别'
)
),
'objects', JSON_ARRAY(
@@ -361,7 +312,7 @@ INSERT INTO t_dm_annotation_templates (
)
),
'horizontal',
'audio',
'音频',
1,
'1.0.0',
NOW()
@@ -377,3 +328,4 @@ ON DUPLICATE KEY UPDATE
built_in = VALUES(built_in),
version = VALUES(version),
updated_at = NOW();