'Error during runing basic keras_ocr model in colab TypeError: annotate() missing 1 required positional argument: 's'
I try to make a model to predict ocr text on documents. For this I use Keras_ocr. When I run code from documentation in google collab I get this error:
TypeError Traceback (most recent call last)
<ipython-input-7-1df519f9081c> in <module>()
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)
/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 return ax
TypeError: annotate() missing 1 required positional argument: 's'
What is the problem ?
This is the link to documentation https://keras-ocr.readthedocs.io/en/latest/examples/using_pretrained_models.html
Solution 1:[1]
As per the recommendation from Github keras-ocr Issues 183. If you're getting annotate() missing 1 required positional argument: 's' , it means you are using old version of matplotlib. The input parameter changed from s to text in matplotlib v3.3.0.
To fix this, you have two options:
- Upgrade
matplotlib to >= 3.3.0, which supports the new text parameter. - Downgrade
keras-ocr to <= v0.8.7, which uses the older s parameter.
In my case, following command in Google Colab worked for me
!pip install matplotlib==3.3.0
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | sam |
