圖片如果看不到的可以點擊這里:【FlowUs 息流】Doccano數據標注工具 - 自動標注(Auto-Labeling)功能
最近在使用Doccano標注數據時一直不明白Auto Labeling功能怎么使用,后來在Doccano的issue里看到了使用方式,記錄一下
-
編寫 api 接口並運行
from flask import Flask, request, jsonify @app.route("/predict", methods=["POST"]) def predict(): # 獲取text參數 text = request.form.get("text") or request.json.get("text") or request.values.get("text") # 模型推理得到結果 pred = "medical" # or "non-medical" # 返回結果 results= [{"result": pred}] return jsonify(results) if __name__ == "__main__": app.run("0.0.0.0", port=5001)
-
在項目選單中選擇
Settings
->Auto Labeling
->Create
新建一項: -
在彈出的窗口中選擇一個配置模板,選擇
Custom REST Request
: -
點擊 Next ,按照上面的 api 填寫 url 等參數
-
注意body參數的key為api中request獲取的參數名,value為
{{ text }}
: -
輸入測試文本點擊Test按鈕進行測試:
-
點擊 Next ,進入到設置映射模板(Set mapping template)選項卡,在Mapping Template的文本框中輸入模板:
[ {% for item in input %} { "label": "{{ item.result }}" }{% if not loop.last %},{% endif %} {% endfor %} ]
注意 key 要與 doccano format 里面的保持一致:
Text Classification [{ "label": "Cat" }, ...] Sequence Labeling [{ "label": "Cat", "start_offset": 0, "end_offset": 5 }, ...] Sequence to sequence [{ "text": "Cat" }, ...]
-
點擊 Next ,配置標簽映射(Configure label mappings),
From
填寫上面result解析出來的結果,To
選擇對應Doccano項目里設置的標簽: -
再次點擊測試,正確后點擊Finish:
-
標注時打開Auto Labeling即可