Spaces:
Runtime error
Runtime error
Download app.py from pchuri/image2text: direct link, hf CLI and curl.
- Browser
- Download file 771 Bytes
-
https://huggingface.co/spaces/pchuri/image2text/resolve/main/app.py
- Command line
-
hf download hf://spaces/pchuri/image2text/app.py
-
curl -L -o app.py https://huggingface.co/spaces/pchuri/image2text/resolve/main/app.py
771 Bytes
| import cv2 | |
| import numpy as np | |
| import easyocr | |
| import gradio as gr | |
| from PIL import Image | |
| def ocr_image_to_text(image: Image.Image): | |
| image_np = np.array(image) | |
| reader = easyocr.Reader(['en', 'ko']) | |
| text = ' '.join([item[1] for item in reader.readtext(image_np)]) | |
| return text | |
| # Gradio μΈν°νμ΄μ€λ₯Ό μ μν©λλ€. | |
| image_input = gr.inputs.Image(label="Upload an image") | |
| text_output = gr.outputs.Textbox(label="Extracted Text") | |
| # μ λ ₯ μμ λ₯Ό μ μν©λλ€. | |
| example_image = 'example.jpg' | |
| examples = [ | |
| [example_image] | |
| ] | |
| iface = gr.Interface(fn=ocr_image_to_text, inputs=image_input, outputs=text_output, title="OCR Image to Text", examples=examples) | |
| # μΈν°νμ΄μ€λ₯Ό μ€ννκ³ Hugging Face Spacesμ λ°°ν¬ν©λλ€. | |
| iface.launch() | |