Getting handwritten model to work in Python
Just some things I have observed trying to get the handwritten model to work in Python (after pip install). I am happy to make a pull request if these are desired changes
-
The model in the GitHub repo isn't installed as part of the pypi package. I git cloned and copied and pasted the
handwritten_modeldirectory across, maybe just a note in the Readme to do this? -
I had to change the path references to the model, to make them work not matter where you were running the code from i.e.
cd = os.path.dirname(os.path.abspath(__file__))
with open(os.path.join(cd, os.path.join("handwritten_model", "translation.pkl")), "rb") as file:
translation = pickle.load(file)
- I was getting the error
TypeError: argument 1 must be read-only bytes-like object, not memoryviewwhen trying to generate text. I changed some of the code in thegeneratemethod, see below. I have no idea why this seems to work for me and not the existing code base?? But I've had the same error (with the same fix) across both Linux and Mac
s, (width, height) = canvas.print_to_buffer()
image = Image.frombytes(
"RGBA", (width, height), s
)
1 & 2: This is not an often used feature and I can't test it in Travis. Clearly I broke it when I created the PyPi package.
3: Could you run pip3 freeze and post the results? I am not able to reproduce it on my side.
I'll try to address these issues shortly, thank you for opening an issue.
Apologies, I'm just working in my all purpose environment, so I've dumped the whole thing in a text file below.
I imagine the important ones are:
matplotlib==3.1.1
tensorflow==1.14.0
Pillow==6.1.0
Thanks @ecatkins for your findings. I made a pull request for this: https://github.com/Belval/TextRecognitionDataGenerator/pull/117. I also added compatibility for TF 1.15 and fix for getting the handwritten text output (no image mask was found). Regards