EasyOCR icon indicating copy to clipboard operation
EasyOCR copied to clipboard

TypeError: Model.__init__() got an unexpected keyword argument 'num_class'

Open ShehneelAhmedKhan opened this issue 2 years ago • 5 comments

I have trained my custom model following this repo and now when I am trying to run this, I get the following error.

image

ShehneelAhmedKhan avatar Jan 16 '24 07:01 ShehneelAhmedKhan

I'm having the same problem - @ShehneelAhmedKhan were you ever able to fix it?

donjuanpond avatar Jul 18 '24 20:07 donjuanpond

Same problem, anyone ???

I think my major issue is knowing which model to define in the ~/.EasyOCR/user_network/ if I simply retrained the ['en'] model.

Sandman2127 avatar Jul 23 '24 15:07 Sandman2127

I was able to solve it by using the python file mentioned in this tutorial for saving / loading the model: https://alimustoofaa.medium.com/easyocr-training-custom-dataset-8fc31cfec1fe. Essentially, the problem was occurring because I was using code I copied from the model.py file for saving / loading, and that takes num_classes through the opt AttrDict. When loading the model, you need the format to have num_classes directly as a parameter.

donjuanpond avatar Jul 23 '24 19:07 donjuanpond

Excellent, thank you for your help @donjuanpond we are all up and running now !

Sandman2127 avatar Jul 23 '24 21:07 Sandman2127

Hey guys, may I know exactly how you guys be able to solve it ?

MengFoong avatar Feb 18 '25 08:02 MengFoong