Awesome multilingual OCR toolkits based on PaddlePaddle (practical ultra lightweight OCR system, support 80+ languages recognition, provide data annotation and synthesis tools, support training and deployment among server, mobile, embedded and IoT devices)
IndexError: (OutOfRange) The starting index 1 of slice is out of bounds in tensor 0-th axis, it shound be in the range of [-1, 1). (at /paddle/paddle/fluid/pybind/slice_utils.h:197)
首先开启AMP:
kie_unet_sdmgr.yml
:推理和评估模型正常,但是在训练时报错:
出错位置为
kie_unet_sdmgr.py#Kie_backbone.forward
开启AMP状态下, print出
forward
的参数inputs.shape
, 值为[1, 3, 1024, 1024]
。关闭AMP时该参数为KeepKeys
处理后的list,打开AMP后该参数变为了list的第一项,即image。尝试修改KeepKeys,将输出从
return data_list
改为return [data_list]
, 开启AMP后kie_unet_sdmgr.py#Kie_backbone.forward
成功获取到正确的参数。而且
kie_sdmgr_loss.py#SDMGRLoss.forward
中的参数batch
形状则会同时发生改变,需要将
KeepKeys
的更改还原。此时AMP正常工作,可以观察到训练内存占用下降,训练速度增加。综上所述,SDMG-R在开启AMP后,
Kie_backbone
训练时主干网络前向计算input输入从list改变为list的第一项,网络其他结构没有发生变化。