EasyOCR 在测试时,预测.weight的大小不匹配,

omhiaaxx  于 3个月前  发布在  其他
关注(0)|答案(9)|浏览(40)

我使用自己的数据集训练了模型,得到了一个.pth文件,但在测试过程中遇到了这个错误。有人能帮我解决这个问题吗?非常感谢。

avwztpqn

avwztpqn1#

RuntimeError: Error(s) in loading state_dict for Model: size mismatch for Prediction.weight: copying a param with shape torch.Size([174, 512]) from checkpoint, the shape in current model is torch.Size([185, 512]). size mismatch for Prediction.bias: copying a param with shape torch.Size([174]) from checkpoint, the shape in current model is torch.Size([185]).

gmol1639

gmol16392#

我遵循了你的建议,但仍然得到了相同的错误 #487
@falhafizh

wlp8pajw

wlp8pajw3#

@kimlia545
How can I use my custom model? please help me

mf98qq94

mf98qq945#

我通过了这一部分并应用了更改,但我又遇到了这个错误。我认为这个错误的原因是我的字符与默认字符之间的差异。我需要在代码中做些什么吗?

dba5bblo

dba5bblo6#

这取决于你是否要尝试手动注入字符。
[在Python中加载yaml,Windows操作系统]:
在我的情况下,预期大小为97,但实际上为99。当我尝试在easyocr.py中打印字符时,看起来符号€变成了€,它应该仍然是€。
问题在于使用yaml加载时字符发生了变化。因此,为了调试,我在easyocr.py文件中直接通过分配我的字符来更改了手动输入。
self.character = "my character same in my custom_example.yaml"
在你的情况下,预期大小应该是174,但实际上是185。

h9a6wy2h

h9a6wy2h7#

尝试在Google Colab中加载。

cmssoen2

cmssoen28#

非常感谢您的帮助,手动注入字符是否足够在easyocr.py中输入这行代码(self.character = "my character same in my custom_example.yaml")?

cyej8jka

cyej8jka9#

对于我的情况,是的。

我的备选方案是尝试在Google Colab中运行easyocr并加载我的模型。它正常运行(不需要更改任何内容)。

相关问题