Doccano數據標注工具 - 自動標注(Auto-Labeling)功能


圖片如果看不到的可以點擊這里:【FlowUs 息流】Doccano數據標注工具 - 自動標注(Auto-Labeling)功能

最近在使用Doccano標注數據時一直不明白Auto Labeling功能怎么使用,后來在Doccano的issue里看到了使用方式,記錄一下

  1. 編寫 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)
    
  2. 在項目選單中選擇 Settings->Auto Labeling->Create 新建一項:

    image-20220307172957727

  3. 在彈出的窗口中選擇一個配置模板,選擇Custom REST Request

    image-20220307173142599

  4. 點擊 Next ,按照上面的 api 填寫 url 等參數

    image-20220307174759993

  5. 注意body參數的key為api中request獲取的參數名,value為 {{ text }}

    image-20220307174550518

  6. 輸入測試文本點擊Test按鈕進行測試:

    image-20220307174855672

  7. 點擊 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" }, ...]
    

    image-20220307175916054

  8. 點擊 Next ,配置標簽映射(Configure label mappings),From填寫上面result解析出來的結果,To選擇對應Doccano項目里設置的標簽:

    image-20220307180324823

  9. 再次點擊測試,正確后點擊Finish:

    image-20220307180431395

  10. 標注時打開Auto Labeling即可

    image-20220307180538323


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM