飛槳PaddleOCR的Kie訓(xùn)練-RE訓(xùn)練報錯: KeyError: 'NONE'或KeyError: 'B-NONE'

問題描述

在執(zhí)行re訓(xùn)練的時候報錯:

...
, error happened with msg: Traceback (most recent call last):
  File "/paddle/PaddleOCR/ppocr/data/simple_dataset.py", line 137, in __getitem__
    outs = transform(data, self.ops)
  File "/paddle/PaddleOCR/ppocr/data/imaug/__init__.py", line 56, in transform
    data = op(data)
  File "/paddle/PaddleOCR/ppocr/data/imaug/label_ops.py", line 1093, in __call__
    gt_label = self._parse_label(label, encode_res)
  File "/paddle/PaddleOCR/ppocr/data/imaug/label_ops.py", line 1177, in _parse_label
    gt_label.append(self.label2id_map[("b-" + label).upper()])
KeyError: 'B-NONE'

image.png

問題分析

查了很多資料,也沒有找到具體的解決方案,安裝官方示例對比,發(fā)現(xiàn)可能是我使用PPOCRLabel進行打標(biāo),而PPOCR打標(biāo)工具生成的Label.txt文件缺少了訓(xùn)練必須的屬性。

解決方案

編輯我們的Label.txt文件,在"points"字段前添加一個"label","id","linking"等字段。

每個文本行字段中,需要添加id與linking字段信息,id記錄該文本行的唯一標(biāo)識,同一張圖片中的不同文本內(nèi)容不能重復(fù),linking是一個列表,記錄了不同文本之間的連接信息。

標(biāo)準(zhǔn)格式

" 圖像文件名                 圖像標(biāo)注信息 "
zh_train_0.jpg   [{"transcription": "匯豐晉信", "label": "other", "points": [[104, 114], [530, 114], [530, 175], [104, 175]], "id": 1, "linking": []}, {"transcription": "受理時間:", "label": "question", "points": [[126, 267], [266, 267], [266, 305], [126, 305]], "id": 7, "linking": [[7, 13]]}, {"transcription": "2020.6.15", "label": "answer", "points": [[321, 239], [537, 239], [537, 285], [321, 285]], "id": 13, "linking": [[7, 13]]}]
]
...

總結(jié)

使用PPOCRLabel標(biāo)注不能直接生成RE訓(xùn)練的文件,需要對標(biāo)注文件進行修改,添加一些必要的屬性,如id:,label,linking等屬性,還需要注意id不能重復(fù)。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容