問題描述
在執(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ù)。