keras-ocr icon indicating copy to clipboard operation
keras-ocr copied to clipboard

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

Open GMXela opened this issue 2 years ago • 5 comments

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'

GMXela avatar Mar 21 '22 21:03 GMXela

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

vittoema96 avatar Mar 22 '22 15:03 vittoema96

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

GMXela avatar Mar 23 '22 12:03 GMXela

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

vittoema96 avatar Mar 24 '22 09:03 vittoema96

@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!!!

GMXela avatar Mar 24 '22 13:03 GMXela

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

nagvekarshankar avatar May 27 '22 12:05 nagvekarshankar