通用数据标注处理工具。当用户提到需要数据标注、有标注任务、数据处理、数据集生成、 标注查看/编辑时使用此 skill。支持图像、视频、文本等多种数据类型,调用模型进行内容理解 和标注,生成结构化标注数据,提供 Web 查看编辑界面。 触发短语:「标注」「annotation」「数据集」「label」「tag data」「数据处理」。
完整的数据标注工作流:需求确认 → 制定计划 → 逐条处理 → 结果存储 → Web 查看/编辑 → 部署访问。
绝对不要一次性批量处理所有数据! 超时(通常 10 分钟)会导致任务中断、数据丢失。
正确做法:
如果感觉快超时了,立即保存当前进度并汇报,下次从计划中未完成的位置继续。
收到标注任务后,必须先确认以下信息:
如果用户已提供以上信息,跳过确认直接进入下一步。
读取并理解需求文档,提取关键信息。
docx 文件读取:
pip install python-docx
python3 -c "
from docx import Document
doc = Document('<需求文档路径>')
for p in doc.paragraphs: print(p.text)
for table in doc.tables:
for row in table.rows:
print(' | '.join(cell.text for cell in row.cells))
"
# 备选方案(python-docx 失败时):
pandoc <需求文档路径> -t plain # 需 apt install -y pandoc
提取并确认:
向用户复述需求,特别是字段、输出结构、标签列表,确认无误后继续。
扫描数据目录,统计文件数量和类型:
find <数据目录> -type f \( -name "*.jpg" -o -name "*.jpeg" -o -name "*.png" \
-o -name "*.mp4" -o -name "*.avi" -o -name "*.txt" \) | wc -l
制定标注计划,保存为 <数据目录>/results/plan.json:
{
"task_name": "任务描述",
"created_at": "2026-03-19T14:00:00Z",
"total_items": 10,
"processed": 0,
"failed": 0,
"items": [
{ "id": 1, "source": "video1.mp4", "type": "video", "status": "pending", "result_file": null },
{ "id": 2, "source": "image_001.jpg", "type": "image", "status": "pending", "result_file": null }
]
}
对于视频数据,此阶段也执行抽帧(抽帧不计入逐条标注耗时)。
视频抽帧要求:
ffmpeg -vf fps=2)<数据目录>/results/frames/<文件名不含扩展名>/制定计划后向主 Agent 汇报:
每次只处理 1 条数据! 处理流程:
读取 plan.json → 取下一条 status=pending → 调用模型标注 → 保存结果 → 更新 plan.json → 汇报进度 → 取下一条
| 数据类型 | 处理方式 | 推荐模型 |
|---|---|---|
| 图像 | VL 模型分析图片内容 | qwen3.5-plus、kimi-k2.5、doubao-seed-2.0-pro |
| 视频 | 抽帧后逐帧用 VL 模型 | 同上 |
| 文本 | LLM 文本分析 | 任意文本模型 |
| 音频 | whisper 转写 + LLM | whisper + LLM |
| 混合 | 按类型分别处理 | 组合上述方法 |
查看 TOOLS.md 获取已配置的模型 API 信息。
# 使用阿里百炼 qwen3.5-plus 分析图片
curl -s https://coding.dashscope.aliyuncs.com/v1/chat/completions \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen3.5-plus",
"messages": [{
"role": "user",
"content": [
{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,<BASE64>"}},
{"type": "text", "text": "请按照标注要求分析这张图片..."}
]
}]
}'
已处理 X/Y(Z%),本条耗时 N 秒每处理完几条数据后,输出进度:
📊 进度:已处理 3/10(30%)
- ✅ video1.mp4 — 完成(耗时 12s)
- ✅ video2.mp4 — 完成(耗时 15s)
- ✅ image_001.jpg — 完成(耗时 3s)
- ⏳ image_002.jpg — 处理中...
标注结果保存到 <数据目录>/results/ 目录:
<数据目录>/
├── data/ # 原始数据
├── results/
│ ├── plan.json # 标注计划(进度追踪)
│ ├── dataset.jsonl # 标注结果(逐条追加)
│ ├── summary.json # 统计摘要(全部完成后生成)
│ ├── viewer.html # Web 查看编辑页面
│ ├── frames/ # 视频抽帧图片
│ │ ├── video1/
│ │ └── video2/
│ └── videos/ # 视频副本(供 Web 引用)
└── ...
输出格式要求:
source_file 和 annotation_time参考 templates/annotation-viewer.html 模板,根据实际数据生成定制页面。
页面关键要求(实战经验):
/annotation-api/),不要硬编码 127.0.0.1:8888POST /annotation-api/ 保存beforeunload 事件)视频文件处理:Web 页面引用视频时使用相对路径(../video.mp4),通过 nginx 静态服务直接访问,不要走 API。
^~ 前缀匹配 — 避免 nginx 正则 location(如静态文件缓存)优先匹配导致 404/root 目录权限必须 755 — 否则 nginx worker 无法访问(root 下默认 700)在已有的 nginx 站点配置中添加(如 /etc/nginx/sites-enabled/default):
# 标注数据查看(^~ 优先级高于正则,确保 mp4/jpg 不被其他规则劫持)
location ^~ /annotation/ {
alias /root/annotation-data/;
autoindex on;
index viewer.html index.html;
charset utf-8;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods "GET, POST, OPTIONS";
add_header Access-Control-Allow-Headers "Content-Type";
}
# 标注 API 反代
location ^~ /annotation-api/ {
proxy_pass http://127.0.0.1:8888/;
}
不要删除已有的其他 location 块,只追加。
mkdir -p /root/annotation-data/
ln -sf <实际数据目录> /root/annotation-data/<项目名>
chmod 755 /root # 关键!否则 nginx 无法访问
fuser -k 8888/tcp 2>/dev/null
nohup python3 <skill路径>/scripts/annotation-api.py --port 8888 --data-dir <数据目录> > <数据目录>/results/api.log 2>&1 &
# 必须完全 restart 而不是 reload
systemctl restart nginx
# 验证 HTML、图片、视频、API 都能正常访问
curl -s -o /dev/null -w "%{http_code}" http://localhost/annotation/<项目名>/results/viewer.html # 期望 200
curl -s -o /dev/null -w "%{http_code}" http://localhost/annotation/<项目名>/<视频文件>.mp4 # 期望 200
curl -s "http://localhost/annotation-api/" | python3 -c "import sys,json;print(len(json.load(sys.stdin).get('files',[])))" # 文件数>0
每次完成或暂停时,向主 Agent/用户汇报:
templates/annotation-viewer.htmlscripts/annotation-api.pyreferences/output-formats.md