解决pytorch版PseNet源码报错 :UnboundLocalError: local variable 'score_text' referenced before assignment

最近在折腾Psenet模型,实现的过程有些艰辛。

原作者的代码基于python2.7,我自己只有python3环境,一路解决python不同版本的问题,碰到一个大BUG!

eckpoint path: checkpoints/ic15_resnet50_bs_2_ep_600

init lr: 0.00100000

('schedule: ', [200, 400])

Training from scratch.

Epoch: [1 | 600] LR: 0.001000

Traceback (most recent call last):

File "train_ic15.py", line 289, in 

main(args)

File "train_ic15.py", line 257, in main

train_loss, train_te_acc, train_ke_acc, train_te_iou, train_ke_iou = train(train_loader, model, dice_loss, optimizer, epoch)

File "train_ic15.py", line 175, in train

return (losses.avg, score_text['Mean Acc'], score_kernel['Mean Acc'], IC15Loaderscore_text['Mean IoU'], score_kernel['Mean IoU'])

UnboundLocalError: local variable 'score_text' referenced before assignment

附图:


说是局部变量 score_text被重复引用,一路调试发现还是python3和python2的坑,整除操作运算符不同!!!

icdar2015_loader.py 的198行,这样修改:

bboxes = np.reshape(bboxes * ([img.shape[1], img.shape[0]] * 4), (bboxes.shape[0], bboxes.shape[1] // 2, 2)).astype('int32') # py3

# bboxes = np.reshape(bboxes * ([img.shape[1], img.shape[0]] * 4), (bboxes.shape[0], bboxes.shape[1] / 2, 2)).astype('int32') # py2


这样就可以正常运行啦!


你可能感兴趣的:(解决pytorch版PseNet源码报错 :UnboundLocalError: local variable 'score_text' referenced before assignment)