faustomorales / keras-ocr

A packaged and flexible version of the CRAFT text detector and Keras CRNN recognition model.
https://keras-ocr.readthedocs.io/
MIT License
1.37k stars 349 forks source link

TypeError: annotate() missing 1 required positional argument: 's' #199

Open GMXela opened 2 years ago

GMXela commented 2 years ago

Hello, I have this error and I don't understand...

Looking for /root/.keras-ocr/craft_mlt_25k.h5 Looking for /root/.keras-ocr/crnn_kurapan.h5

TypeError Traceback (most recent call last) in () 19 fig, axs = plt.subplots(nrows=len(images), figsize=(20, 20)) 20 for ax, image, predictions in zip(axs, images, prediction_groups): ---> 21 keras_ocr.tools.drawAnnotations(image=image, predictions=predictions, ax=ax) 22 23 print(prediction_groups)

/usr/local/lib/python3.7/dist-packages/keras_ocr/tools.py in drawAnnotations(image, predictions, ax) 182 color="r", 183 fontsize=14, --> 184 horizontalalignment="right" if side == "left" else "left", 185 186 )

TypeError: annotate() missing 1 required positional argument: 's'

vittoema96 commented 2 years ago

Try updating matplotlib, the last version should not lead to this error

GMXela commented 2 years ago

I'm working on Colab so i'm not supposed to make any down/update... I think...

But, I tried a LOT of modifications and nothing works... I'm trying to understand the error and analyzing the source code but i never found where and what is the 's' argument...

TypeError: annotate() missing 1 required positional argument: 's'

@docstring.dedent_interpd
def annotate(self, text, xy, *args, **kwargs):
    a = mtext.Annotation(text, xy, *args, **kwargs)
    a.set_transform(mtransforms.IdentityTransform())
    if 'clip_on' in kwargs:
        a.set_clip_path(self.patch)
    self._add_text(a)
    return a
annotate.__doc__ = mtext.Annotation.__init__.__doc__
#### Lines and spans
vittoema96 commented 2 years ago

I guess there's a better solution to this, but i had the same problem on colab too and a !pip install --upgrade matplotlib solved it for me

GMXela commented 2 years ago

@vittoema96 @faustomorales Thank you so much!! It solved it to me too.... But I have this other issue :

https://github.com/faustomorales/keras-ocr/issues/201

I'm working on it this morning and I hope to be able to fix it.

THX guys!!! So much!!!

nagvekarshankar commented 2 years ago

I am getting same issue on colabs. How to use this function in colabs

def annotate(self, text, xy, *args, *kwargs): a = mtext.Annotation(text, xy, args, **kwargs) a.set_transform(mtransforms.IdentityTransform()) if 'clip_on' in kwargs: a.set_clip_path(self.patch) self._add_text(a) return a annotate.doc = mtext.Annotation.init.doc

Lines and spans