

# weights for the detector and recognizer.

# keras-ocr will automatically download pretrained # Using PIL to convert one mode to anotherĬ = Image.open('/content/gD7vA.png').convert('RGBA')įull code import matplotlib.pyplot as plt In short, to make your input work on keras-ocr, you can convert your files to RGB (or RGBA) first and save them on disk. The transparent layer already included in your original file and I didn't remove it, but it seems useless to keep otherwise if needed. And b is the file I converted to RGB or RGBA. In the above, the a is the file you mention in your question as It showed, it has to channel, e.g. See below: from PIL import ImageĪ = Image.open('/content/gD7vA.png') # return none by keras-ocr,Ī.mode, a.split() # mode 1 channel + transparent layer / alpha layer (LA)ī = Image.open('/content/CYegU.png') # return result by keras-ocrī.mode, b.split() # mode RGB + transparent layer / alpha layer (RGBA) The reason for keras-ocr not working or returning nothing is because of the grayscale image (as I found it worked otherwise). Still not able to read the captcha textĮdit 2 (): Keras OCR is also not returning anything for these images Below are a few sample image:-Įdit 1 (): I'm able to convert svg to png using cairosvg.
#Image text extractor python how to
I wasn't sure how to work with svg image so I converted them to png. Below is my code for pytesseract, although I'm open to Keras OCR also:- from PIL import ImageĬaptchaText = pytesseract.image_to_string(img, lang='eng', config='-psm 6') Currently I'm getting empty string as output.
