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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -3,17 +3,17 @@ import gradio as gr
3
  from PIL import Image
4
  import pytesseract
5
 
6
- def extract_text_from_image(image_path):
7
  try:
8
- img = Image.open(image_path)
9
- text = pytesseract.image_to_string(img)
10
  return text
11
  except Exception as e:
12
  return str(e)
13
 
14
  iface = gr.Interface(
15
  fn=extract_text_from_image,
16
- inputs=gr.Image(type="file", label="Upload an image"),
17
  outputs="text",
18
  live=True,
19
  )
 
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)
13
 
14
  iface = gr.Interface(
15
  fn=extract_text_from_image,
16
+ inputs=gr.Image(type="pil", label="Upload an image"),
17
  outputs="text",
18
  live=True,
19
  )