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

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

View File

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