2

I am a beginner in Machine Learning and I wanted to try text extraction code. Here is my code:

import pytesseract from PIL import Image 
pytesseract.pytesseract.tesseract_cmd = r"C:\Program Files (x86)\Tesseract OCR.exe" 
img = Image.open('image.png') 
img.load()
imgString = pytesseract.image_to_string(img)

However, this results in this error:

TypeError: int() argument must be a string, a bytes-like object or a number, not 'tuple`'

I am using Jupyter Notebook (python 3) to run this program. Is there anything I can do or is there an easier way to extract text from an image?

Bob Lee
  • 21
  • 4

2 Answers2

1

Image.load() method

Allocates storage for the image and loads the pixel data. In normal cases, you don’t need to call this method, since the Image class automatically loads an opened image when it is accessed for the first time.

img.load()

to

#img.load()
Asif Mohammed
  • 1,323
  • 1
  • 15
  • 29
0

Executable file name is wrong, Use below code you will get the answer

pytesseract.pytesseract.tesseract_cmd = "C:/Program Files (x86)/Tesseract-OCR/tesseract.exe"

Other lines of code is file. Thank you