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