typesdigital commited on
Commit
ae6525a
·
1 Parent(s): 4adb0d9

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -2
app.py CHANGED
@@ -2,11 +2,16 @@
2
  import gradio as gr
3
  from PIL import Image
4
  import pytesseract
 
5
 
6
  def extract_text_from_image(image):
7
  try:
8
- pil_image = Image.fromarray(image)
9
- text = pytesseract.image_to_string(pil_image)
 
 
 
 
10
  return text
11
  except Exception as e:
12
  return str(e)
 
2
  import gradio as gr
3
  from PIL import Image
4
  import pytesseract
5
+ import numpy as np
6
 
7
  def extract_text_from_image(image):
8
  try:
9
+ # Convert the PIL image to a NumPy array
10
+ image_array = np.array(image)
11
+
12
+ # Use Tesseract to extract text
13
+ text = pytesseract.image_to_string(Image.fromarray(image_array))
14
+
15
  return text
16
  except Exception as e:
17
  return str(e)