|
|
@@ -69,7 +69,12 @@ POST /api/external/projects/init
|
|
|
}
|
|
|
}
|
|
|
],
|
|
|
- "external_id": "sample_center_proj_001"
|
|
|
+ "external_id": "sample_center_proj_001",
|
|
|
+ "tags": [
|
|
|
+ {"tag": "猫猫", "color": "#FF5733"},
|
|
|
+ {"tag": "狗狗", "color": "#33FF57"},
|
|
|
+ {"tag": "其他"}
|
|
|
+ ]
|
|
|
}
|
|
|
```
|
|
|
|
|
|
@@ -85,8 +90,13 @@ POST /api/external/projects/init
|
|
|
| data[].content | string | 是 | 数据内容(文本或图像URL) |
|
|
|
| data[].metadata | object | 否 | 额外元数据 |
|
|
|
| external_id | string | 否 | 外部系统的项目ID,用于关联查询 |
|
|
|
+| tags | array | 否 | 标签列表,用于预定义标注选项 |
|
|
|
+| tags[].tag | string | 是 | 标签名称 |
|
|
|
+| tags[].color | string | 否 | 标签颜色,格式: #RRGGBB,不传则自动生成 |
|
|
|
|
|
|
-**注意**:标签(labels)由标注平台管理员在项目配置阶段设置,样本中心无需提供。
|
|
|
+**注意**:
|
|
|
+- 如果传入 `tags` 参数,系统会自动根据标签生成对应的XML配置
|
|
|
+- 如果不传 `tags` 参数,标签由标注平台管理员在项目配置阶段设置
|
|
|
|
|
|
**支持的任务类型**
|
|
|
|
|
|
@@ -94,8 +104,9 @@ POST /api/external/projects/init
|
|
|
|-----------|------|-------------------|
|
|
|
| text_classification | 文本分类 | 文本内容 |
|
|
|
| image_classification | 图像分类 | 图像URL |
|
|
|
-| object_detection | 目标检测 | 图像URL |
|
|
|
+| object_detection | 目标检测(矩形框) | 图像URL |
|
|
|
| ner | 命名实体识别 | 文本内容 |
|
|
|
+| polygon | 多边形标注 | 图像URL |
|
|
|
|
|
|
**响应**
|
|
|
|
|
|
@@ -254,6 +265,7 @@ POST /api/external/projects/{project_id}/export
|
|
|
| yolo | YOLO目标检测格式 | YOLO模型训练 |
|
|
|
| coco | COCO数据集格式 | 目标检测/分割模型训练 |
|
|
|
| alpaca | Alpaca指令微调格式 | LLM指令微调 |
|
|
|
+| pascal_voc | PascalVOC XML格式 | 经典目标检测模型训练 |
|
|
|
|
|
|
**响应**
|
|
|
|
|
|
@@ -340,6 +352,23 @@ POST /api/external/projects/{project_id}/export
|
|
|
]
|
|
|
```
|
|
|
|
|
|
+**PascalVOC格式**:
|
|
|
+```json
|
|
|
+[
|
|
|
+ {
|
|
|
+ "image": "https://example.com/img1.jpg",
|
|
|
+ "filename": "img1.jpg",
|
|
|
+ "xml_content": "<?xml version=\"1.0\"?>...",
|
|
|
+ "objects": [
|
|
|
+ {
|
|
|
+ "name": "cat",
|
|
|
+ "bndbox": {"xmin": 100, "ymin": 50, "xmax": 300, "ymax": 250}
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ }
|
|
|
+]
|
|
|
+```
|
|
|
+
|
|
|
---
|
|
|
|
|
|
## 错误响应
|
|
|
@@ -385,7 +414,7 @@ headers = {
|
|
|
"Content-Type": "application/json"
|
|
|
}
|
|
|
|
|
|
-# 1. 创建项目
|
|
|
+# 1. 创建项目(带标签)
|
|
|
init_data = {
|
|
|
"name": "文本分类项目",
|
|
|
"description": "对用户评论进行情感分类",
|
|
|
@@ -395,7 +424,12 @@ init_data = {
|
|
|
{"id": "2", "content": "质量太差了,不推荐"},
|
|
|
{"id": "3", "content": "一般般,没什么特别的"}
|
|
|
],
|
|
|
- "external_id": "sample_center_001"
|
|
|
+ "external_id": "sample_center_001",
|
|
|
+ "tags": [
|
|
|
+ {"tag": "正面", "color": "#4CAF50"},
|
|
|
+ {"tag": "负面", "color": "#F44336"},
|
|
|
+ {"tag": "中性"} # 不指定颜色,系统自动生成
|
|
|
+ ]
|
|
|
}
|
|
|
|
|
|
response = requests.post(
|
|
|
@@ -407,7 +441,30 @@ project = response.json()
|
|
|
project_id = project["project_id"]
|
|
|
print(f"项目创建成功: {project_id}")
|
|
|
|
|
|
-# 2. 查询进度
|
|
|
+# 2. 创建多边形标注项目
|
|
|
+polygon_data = {
|
|
|
+ "name": "多边形标注项目",
|
|
|
+ "description": "标注图像中的不规则区域",
|
|
|
+ "task_type": "polygon",
|
|
|
+ "data": [
|
|
|
+ {"id": "1", "content": "https://example.com/img1.jpg"},
|
|
|
+ {"id": "2", "content": "https://example.com/img2.jpg"}
|
|
|
+ ],
|
|
|
+ "tags": [
|
|
|
+ {"tag": "区域A", "color": "#FF5722"},
|
|
|
+ {"tag": "区域B", "color": "#607D8B"}
|
|
|
+ ]
|
|
|
+}
|
|
|
+
|
|
|
+response = requests.post(
|
|
|
+ f"{BASE_URL}/projects/init",
|
|
|
+ json=polygon_data,
|
|
|
+ headers=headers
|
|
|
+)
|
|
|
+polygon_project = response.json()
|
|
|
+print(f"多边形项目创建成功: {polygon_project['project_id']}")
|
|
|
+
|
|
|
+# 3. 查询进度
|
|
|
response = requests.get(
|
|
|
f"{BASE_URL}/projects/{project_id}/progress",
|
|
|
headers=headers
|
|
|
@@ -415,7 +472,7 @@ response = requests.get(
|
|
|
progress = response.json()
|
|
|
print(f"完成进度: {progress['completion_percentage']}%")
|
|
|
|
|
|
-# 3. 导出数据(ShareGPT格式)
|
|
|
+# 4. 导出数据(ShareGPT格式)
|
|
|
export_data = {
|
|
|
"format": "sharegpt",
|
|
|
"completed_only": True,
|
|
|
@@ -444,7 +501,7 @@ print(f"文件已保存: {export_result['file_name']}")
|
|
|
### cURL 示例
|
|
|
|
|
|
```bash
|
|
|
-# 1. 创建项目
|
|
|
+# 1. 创建项目(带标签)
|
|
|
curl -X POST "http://localhost:8003/api/external/projects/init" \
|
|
|
-H "Authorization: Bearer your_admin_token" \
|
|
|
-H "Content-Type: application/json" \
|
|
|
@@ -455,20 +512,40 @@ curl -X POST "http://localhost:8003/api/external/projects/init" \
|
|
|
{"id": "1", "content": "https://example.com/img1.jpg"},
|
|
|
{"id": "2", "content": "https://example.com/img2.jpg"}
|
|
|
],
|
|
|
- "external_id": "sample_center_proj_001"
|
|
|
+ "external_id": "sample_center_proj_001",
|
|
|
+ "tags": [
|
|
|
+ {"tag": "猫猫", "color": "#FF9800"},
|
|
|
+ {"tag": "狗狗", "color": "#2196F3"}
|
|
|
+ ]
|
|
|
+ }'
|
|
|
+
|
|
|
+# 2. 创建多边形标注项目
|
|
|
+curl -X POST "http://localhost:8003/api/external/projects/init" \
|
|
|
+ -H "Authorization: Bearer your_admin_token" \
|
|
|
+ -H "Content-Type: application/json" \
|
|
|
+ -d '{
|
|
|
+ "name": "多边形标注项目",
|
|
|
+ "task_type": "polygon",
|
|
|
+ "data": [
|
|
|
+ {"id": "1", "content": "https://example.com/img1.jpg"}
|
|
|
+ ],
|
|
|
+ "tags": [
|
|
|
+ {"tag": "区域A", "color": "#FF5722"},
|
|
|
+ {"tag": "区域B"}
|
|
|
+ ]
|
|
|
}'
|
|
|
|
|
|
-# 2. 查询进度
|
|
|
+# 3. 查询进度
|
|
|
curl -X GET "http://localhost:8003/api/external/projects/proj_xxx/progress" \
|
|
|
-H "Authorization: Bearer your_admin_token"
|
|
|
|
|
|
-# 3. 导出数据(YOLO格式)
|
|
|
+# 4. 导出数据(YOLO格式)
|
|
|
curl -X POST "http://localhost:8003/api/external/projects/proj_xxx/export" \
|
|
|
-H "Authorization: Bearer your_admin_token" \
|
|
|
-H "Content-Type: application/json" \
|
|
|
-d '{"format": "yolo", "completed_only": true}'
|
|
|
|
|
|
-# 4. 下载导出文件
|
|
|
+# 5. 下载导出文件
|
|
|
curl -X GET "http://localhost:8003/api/exports/export_xxx/download" \
|
|
|
-H "Authorization: Bearer your_admin_token" \
|
|
|
-o exported_data.zip
|
|
|
@@ -512,17 +589,26 @@ curl -X GET "http://localhost:8003/api/exports/export_xxx/download" \
|
|
|
|
|
|
1. **项目状态**:外部系统创建的项目初始状态为 `draft`,需要标注平台管理员完成配置(设置标签等)和任务分发后才会进入 `in_progress` 状态。
|
|
|
|
|
|
-2. **标签配置**:标签由标注平台管理员在项目配置阶段设置,样本中心只需提供任务数据,无需关心标签定义。
|
|
|
+2. **标签配置**:
|
|
|
+ - 如果在创建项目时传入 `tags` 参数,系统会自动生成包含这些标签的XML配置
|
|
|
+ - 如果不传 `tags` 参数,标签由标注平台管理员在项目配置阶段设置
|
|
|
+ - 管理员可以在配置阶段修改已传入的标签名称和颜色
|
|
|
|
|
|
-3. **数据格式**:
|
|
|
+3. **颜色格式**:
|
|
|
+ - 颜色使用 `#RRGGBB` 格式(如 `#FF5733`)
|
|
|
+ - 如果不指定颜色,系统会自动生成随机颜色
|
|
|
+
|
|
|
+4. **数据格式**:
|
|
|
- 文本类任务(text_classification, ner):`content` 字段为文本内容
|
|
|
- - 图像类任务(image_classification, object_detection):`content` 字段为图像URL
|
|
|
+ - 图像类任务(image_classification, object_detection, polygon):`content` 字段为图像URL
|
|
|
+
|
|
|
+5. **外部ID关联**:建议在创建项目时提供 `external_id`,方便后续在样本中心系统中关联查询。
|
|
|
|
|
|
-4. **外部ID关联**:建议在创建项目时提供 `external_id`,方便后续在样本中心系统中关联查询。
|
|
|
+6. **导出时机**:建议在项目状态为 `completed` 或 `completion_percentage` 达到预期值时再进行数据导出。
|
|
|
|
|
|
-5. **导出时机**:建议在项目状态为 `completed` 或 `completion_percentage` 达到预期值时再进行数据导出。
|
|
|
+7. **Token安全**:请妥善保管管理员Token,不要在客户端代码中暴露。
|
|
|
|
|
|
-6. **Token安全**:请妥善保管管理员Token,不要在客户端代码中暴露。
|
|
|
+8. **多边形标注**:polygon 类型支持标注不规则形状区域,导出时支持 COCO 和 YOLO 格式。
|
|
|
|
|
|
---
|
|
|
|
|
|
@@ -530,4 +616,6 @@ curl -X GET "http://localhost:8003/api/exports/export_xxx/download" \
|
|
|
|
|
|
| 版本 | 日期 | 说明 |
|
|
|
|------|------|------|
|
|
|
+| 1.2.0 | 2026-02-06 | 添加PascalVOC导出格式支持 |
|
|
|
+| 1.1.0 | 2026-02-05 | 添加tags参数支持、新增polygon任务类型 |
|
|
|
| 1.0.0 | 2026-02-03 | 初始版本 |
|