Spaces:
Runtime error
Runtime error
# app.py | |
import gradio as gr | |
from PIL import Image | |
import pytesseract | |
def extract_text_from_image(image): | |
try: | |
pil_image = Image.fromarray(image) | |
text = pytesseract.image_to_string(pil_image) | |
return text | |
except Exception as e: | |
return str(e) | |
iface = gr.Interface( | |
fn=extract_text_from_image, | |
inputs=gr.Image(type="pil", label="Upload an image"), | |
outputs="text", | |
live=True, | |
) | |
if __name__ == "__main__": | |
iface.launch() | |