解决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

 

这样就可以正常运行啦!

 

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值