sirius-ai / LPRNet_Pytorch

Pytorch Implementation For LPRNet, A High Performance And Lightweight License Plate Recognition Framework.
Apache License 2.0
908 stars 227 forks source link

loss降到0.2左右,不再降了,Test Accuracy 还是基本为0 #2

Closed kunyao2015 closed 4 years ago

kunyao2015 commented 5 years ago

国外车牌数据,7位到8位,训练完成识别始终不正确,仅将load_data.py的中文部分去掉了,训练数据18000张,不知道哪里的问题

sirius-ai commented 5 years ago

test数据和训练数据是同等分布的吗,样式是否也一致?

kunyao2015 commented 5 years ago

test数据和训练数据是同等分布的吗,样式是否也一致?

同一个数据集,随机取1/10 做验证集的

sirius-ai commented 5 years ago

需要根据国外车牌的字符总量修改如下CHARS字符列表: CHARS = ['京', '沪', '津', '渝', '冀', '晋', '蒙', '辽', '吉', '黑', '苏', '浙', '皖', '闽', '赣', '鲁', '豫', '鄂', '湘', '粤', '桂', '琼', '川', '贵', '云', '藏', '陕', '甘', '青', '宁', '新', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'L', 'M', 'N', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'I', 'O', '-' ]

BaofengZan commented 5 years ago

你好,你训练过程中中有什么方法么?我这边训练loss一直在2.5 以上,降不下去。

sirius-ai commented 5 years ago

这要看你的数据集情况的,通常按照我设定的超参,训练到最后,loss会非常低,能达到0.005左右。所以,需要看一下你的数据集情况,总共多少数据量,车牌的截取形式是否一致,车牌字符是否均衡,图像与label是否准确对应,超参是否正确设定,等等。

xuexingyu24 commented 5 years ago

hi . 请问你的训练数据量是多少呢?

sirius-ai commented 5 years ago

@xuexingyu24 也就27万左右。

deep-practice commented 5 years ago

为什么要添加'I', 'O', '-'这三个字符呢

huangyiping-ai commented 4 years ago

@sirius-ai ,你好,我用自己的13万张中国车牌图像做训练,没有数据增强,最后loss降到0.0096,能够很好的识别英文和数字,但是汉字却一个都识别不了,可以指导一下吗?非常感谢!

huangyiping-ai commented 4 years ago

我找出错误点了,是因为后处理时第一个时间的值没计入最终label

liushuan commented 4 years ago

huangyiping-ai 我找出错误点了,是因为后处理时第一个时间的值没计入最终label 这个是如何解决的呢?我也遇到了同样的问题。

huangyiping-ai commented 4 years ago

@liushuan,你好,我稍微更改了网络结构,拿数据集重新训练的,推理结果没错,我的错误点在于后处理时,18个时刻的第一个时刻没有计入label中,所以没有第一个汉字,把第一个时刻的字符计入label就能解决问题了。你可以先看看推理结果对不,如果不对的话那就是模型训练有问题了

liushuan commented 4 years ago

嗯,非常感谢,我的也是decode函数第一个汉子没有加入进去,应该是作者代码的问题,再次感谢提醒!

------------------ 原始邮件 ------------------ 发件人: "huangyiping-ai"<notifications@github.com>; 发送时间: 2019年10月22日(星期二) 上午10:24 收件人: "sirius-ai/LPRNet_Pytorch"<LPRNet_Pytorch@noreply.github.com>; 抄送: "."<547691062@qq.com>; "Mention"<mention@noreply.github.com>; 主题: Re: [sirius-ai/LPRNet_Pytorch] loss降到0.2左右,不再降了,Test Accuracy 还是基本为0 (#2)

@liushuan,你好,我稍微更改了网络结构,拿数据集重新训练的,推理结果没错,我的错误点在于后处理时,18个时刻的第一个时刻没有计入label中,所以没有第一个汉字,把第一个时刻的字符计入label就能解决问题了。你可以先看看推理结果对不,如果不对的话那就是模型训练有问题了

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ShydowLi commented 4 years ago

@liushuan 你好,我的也出现类似问题,需要在哪调整呢?

liushuan commented 4 years ago

decode 函数修改成下面的形式

作者给的decode方法会容易丢失第一个预测的结果

def decode_ctc(preds, CHARS):     pred_labels = list()     labels = list()     for i in range(preds.shape[0]):         pred = preds[i, :, :]         pred_label = list()         for j in range(pred.shape[1]):             pred_label.append(np.argmax(pred[:, j], axis=0))         no_repeat_blank_label = list()         pre_c = pred_label[0]         if pre_c != (len(CHARS) - 1):             no_repeat_blank_label.append(pre_c)         for c in pred_label:  # dropout repeate label and blank label             if (pre_c == c) or (c == len(CHARS) - 1):                 if c == len(CHARS) - 1:                     pre_c = c                 continue             no_repeat_blank_label.append(c)             pre_c = c         pred_labels.append(no_repeat_blank_label)

    for i, label in enumerate(pred_labels):         lb = ""         for i in label:             lb += CHARS[i]         labels.append(lb)

    return labels, pred_labels

------------------ 原始邮件 ------------------ 发件人: "ShydowLi"<notifications@github.com>; 发送时间: 2019年11月6日(星期三) 下午4:35 收件人: "sirius-ai/LPRNet_Pytorch"<LPRNet_Pytorch@noreply.github.com>; 抄送: "."<547691062@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [sirius-ai/LPRNet_Pytorch] loss降到0.2左右,不再降了,Test Accuracy 还是基本为0 (#2)

@liushuan 你好,我的也出现类似问题,需要在哪调整呢?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

ShydowLi commented 4 years ago

@liushuan 非常感谢,研究半天没找到问题所在,谢谢呀

ShydowLi commented 4 years ago

@liushuan @huangyiping-ai 你好,有个问题想请教一下,我用作者训练好的模型作为我的初始训练模型,但当我迭代20000次以上时,我用生成的权重文件去测试其他的图片,发现模型正确率没有提高,反而变得糟糕了,请问这是什么原因呢?

MrCuiHao commented 4 years ago

@deep-practice 我也想知道,不过我看很多车牌识别的方法都留了一个占位符‘_’,我觉得没必要加I,O

2017TJM commented 4 years ago

decode 函数修改成下面的形式 作者给的decode方法会容易丢失第一个预测的结果 def decode_ctc(preds, CHARS):     pred_labels = list()     labels = list()     for i in range(preds.shape[0]):         pred = preds[i, :, :]         pred_label = list()         for j in range(pred.shape[1]):             pred_label.append(np.argmax(pred[:, j], axis=0))         no_repeat_blank_label = list()         pre_c = pred_label[0]         if pre_c != (len(CHARS) - 1):             no_repeat_blank_label.append(pre_c)         for c in pred_label:  # dropout repeate label and blank label             if (pre_c == c) or (c == len(CHARS) - 1):                 if c == len(CHARS) - 1:                     pre_c = c                 continue             no_repeat_blank_label.append(c)             pre_c = c         pred_labels.append(no_repeat_blank_label)     for i, label in enumerate(pred_labels):         lb = ""         for i in label:             lb += CHARS[i]         labels.append(lb)     return labels, pred_labels ------------------ 原始邮件 ------------------ 发件人: "ShydowLi"<notifications@github.com>; 发送时间: 2019年11月6日(星期三) 下午4:35 收件人: "sirius-ai/LPRNet_Pytorch"<LPRNet_Pytorch@noreply.github.com>; 抄送: "."<547691062@qq.com>;"Mention"<mention@noreply.github.com>; 主题: Re: [sirius-ai/LPRNet_Pytorch] loss降到0.2左右,不再降了,Test Accuracy 还是基本为0 (#2) @liushuan 你好,我的也出现类似问题,需要在哪调整呢? — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or unsubscribe.

感谢,真的是第一个字符没有加入导致最后训练准确率一直为0,谢谢

2017TJM commented 4 years ago

def decode(preds, CHARS):

greedy decode

pred_labels = list()
labels = list()
for i in range(preds.shape[0]):
    pred = preds[i, :, :]
    pred_label = list()
    for j in range(pred.shape[1]):
        pred_label.append(np.argmax(pred[:, j], axis=0))
    no_repeat_blank_label = list()
    pre_c = pred_label[0]
    if pre_c!=(len(CHARS)-1):#改进的点
        no_repeat_blank_label.append(pre_c)
    for c in pred_label: # dropout repeate label and blank label
        if (pre_c == c) or (c == len(CHARS) - 1):
            if c == len(CHARS) - 1:
                pre_c = c
            continue
        no_repeat_blank_label.append(c)
        pre_c = c
    pred_labels.append(no_repeat_blank_label)

for i, label in enumerate(pred_labels):
    lb = ""
    for i in label:
        lb += CHARS[i]
    labels.append(lb)

return labels, pred_labels

@liushuan 谢谢大佬!

sirius-ai commented 4 years ago

had fix

ChiShao commented 4 years ago

@BaofengZan 你好,我也遇到了同样的问题,损失一直在2.5附近徘徊,请问你是怎么解决的?谢谢

littleloverlalala commented 2 years ago

您好,请问还需要改其他地方吗?不太明白要一直改到哪里?改完了之后,tn tn_1,tn_2,acc还需要留着吗?

huangyiping-ai commented 1 year ago

您是不是发错了?

---- 回复的原邮件 ---- | 发件人 | @.> | | 日期 | 2022年09月18日 11:12 | | 收件人 | @.> | | 抄送至 | @.**@.> | | 主题 | Re: [sirius-ai/LPRNet_Pytorch] loss降到0.2左右,不再降了,Test Accuracy 还是基本为0 (#2) |

您好,请问还需要改其他地方吗?不太明白要一直改到哪里?改完了之后,tn tn_1,tn_2,acc还需要留着吗?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you were mentioned.Message ID: @.***>