Spaces:
Runtime error
Runtime error
File size: 771 Bytes
3668b1a 36723e9 304666d 3668b1a a6fe218 304666d a6fe218 9516285 3668b1a a6fe218 3668b1a 9516285 3668b1a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | 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()
|