ImageTextRecognition icon indicating copy to clipboard operation
ImageTextRecognition copied to clipboard

AttributeError: 'LinearSVC' object has no attribute 'classes_'

Open oleg-savko opened this issue 10 years ago • 13 comments

Hi! I have a problem to run your project. Do you know, what is the problem?

Traceback (most recent call last): File "/Users/aleh/Development/samples/python/ImageTextRecognition/main.py", line 22, in maybe_text = user.select_text_among_candidates('/Users/aleh/Development/samples/python/ImageTextRecognition/linearsvc-hog-fulltrain2-90.pickle') File "/Users/aleh/Development/samples/python/ImageTextRecognition/userimageski.py", line 105, in select_text_among_candidates is_text = model.predict(self.candidates['flattened']) File "/Library/Python/2.7/site-packages/sklearn/utils/metaestimators.py", line 37, in out = lambda _args, *_kwargs: self.fn(obj, args, *kwargs) File "/Library/Python/2.7/site-packages/sklearn/pipeline.py", line 204, in predict return self.steps[-1][-1].predict(Xt) File "/Library/Python/2.7/site-packages/sklearn/linear_model/base.py", line 273, in predict return self.classes[indices] AttributeError: 'LinearSVC' object has no attribute 'classes'

oleg-savko avatar Nov 28 '15 15:11 oleg-savko

Traceback (most recent call last): File "/Users/ThomasInnovation/PycharmProjects/TextRecognition/main.py", line 14, in maybe_text = user.select_text_among_candidates('/Users/ThomasInnovation/PycharmProjects/TextRecognition/linearsvc-hog-fulltrain2-90.pickle') File "/Users/ThomasInnovation/PycharmProjects/TextRecognition/userimageski.py", line 103, in select_text_among_candidates is_text = model.predict(self.candidates['flattened']) File "/Library/Python/2.7/site-packages/sklearn/utils/metaestimators.py", line 37, in out = lambda _args, *_kwargs: self.fn(obj, args, *kwargs) File "/Library/Python/2.7/site-packages/sklearn/pipeline.py", line 204, in predict return self.steps[-1][-1].predict(Xt) File "/Library/Python/2.7/site-packages/sklearn/linear_model/base.py", line 273, in predict return self.classes[indices] AttributeError: 'LinearSVC' object has no attribute 'classes'

vinothkumar91 avatar Jan 30 '16 07:01 vinothkumar91

I have the same issue as well

zhuyuecai avatar Nov 28 '16 03:11 zhuyuecai

me too :-(

thierrydecae avatar Feb 13 '17 12:02 thierrydecae

pip install scikit-learn==0.15.2 ...it will work

SarfraazMsa avatar May 09 '17 05:05 SarfraazMsa

same problem

samar5yadav avatar May 21 '17 19:05 samar5yadav

@SarfraazMsa - Thanks a lot! That worked for me!

ronair01 avatar Nov 28 '17 08:11 ronair01

great then @ronair01

SarfraazMsa avatar Nov 28 '17 08:11 SarfraazMsa

I had issues unpickling the pickle files so I set encoding to latin1 when loading. However, this provided the following error:

Traceback (most recent call last): File "C:\Users\Elitebook\Desktop\ImageTextRecognition-master\ImageTextRecognition-master\main.py", line 29, in classified = user.classify_text(os.path.join(dir_file, 'linearsvc-hog-fulltrain36-90.pickle')) File "C:\Users\Elitebook\Desktop\ImageTextRecognition-master\ImageTextRecognition-master\userimageski.py", line 129, in classify_text which_text = model.predict(self.to_be_classified['flattened']) File "C:\Users\Elitebook\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\pipeline.py", line 150, in predict return self.steps[-1][-1].predict(Xt) File "C:\Users\Elitebook\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\linear_model\base.py", line 215, in predict scores = self.decision_function(X) File "C:\Users\Elitebook\AppData\Local\Programs\Python\Python36-32\lib\site-packages\sklearn\linear_model\base.py", line 196, in decision_function % (X.shape[1], n_features)) ValueError: X has 0 features per sample; expecting 3920

I assume this is because the code is unable to detect the objects as text since the "Objects Containing Text Detected" page is empty. Can anyone help me out here?

Farhan248 avatar Jan 21 '18 20:01 Farhan248

Traceback (most recent call last):

File "", line 1, in runfile('/home/king/Downloads/pooja project/ImageTextRecognition-master/main.py', wdir='/home/king/Downloads/pooja project/ImageTextRecognition-master')

File "/home/anaconda3/envs/py27/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 705, in runfile execfile(filename, namespace)

File "/home/anaconda3/envs/py27/lib/python2.7/site-packages/spyder/utils/site/sitecustomize.py", line 94, in execfile builtins.execfile(filename, *where)

File "/home/king/Downloads/pooja project/ImageTextRecognition-master/main.py", line 22, in maybe_text = user.select_text_among_candidates('linearsvc-hog-fulltrain2-90.pickle')

File "userimageski.py", line 103, in select_text_among_candidates is_text = model.predict(self.candidates['flattened'])

File "/home/anaconda3/envs/py27/lib/python2.7/site-packages/sklearn/utils/metaestimators.py", line 35, in get

AttributeError: '_IffHasAttrDescriptor' object has no attribute 'get_attribute'

suhasdatascientist avatar Sep 28 '18 10:09 suhasdatascientist

Hi guys, sorry but I have not been working on this project for years. The code base is really old and completely outdated. Not really sure how to help here.

FraPochetti avatar Sep 28 '18 11:09 FraPochetti

now that issue has been resolved by downgrading scikit learn to 0.15.1 version, but still the characters that recognized from the same image for the same code is different, where exaclty the problem will be t1

suhasdatascientist avatar Sep 28 '18 11:09 suhasdatascientist

pip install scikit-learn==0.15.2 ...it will work

Since downgrading is the solution, I assume we need to change a certain syntax for the newest version of scikit-learn correct?

rchavezj avatar May 28 '19 16:05 rchavezj

yes

pip install scikit-learn==0.15.2 ...it will work

Since downgrading is the solution, I assume we need to change a certain syntax for the newest version of scikit-learn correct?

yes @rchavezj

SarfraazMsa avatar May 28 '19 17:05 SarfraazMsa