| import streamlit as st |
| import easyocr |
| from PIL import Image |
| import numpy as np |
|
|
| |
| reader = easyocr.Reader(['en', 'th'], gpu=True) |
|
|
| |
| st.set_page_config(page_title="EasyOCR (GPU) - Fast OCR") |
| st.title("EasyOCR (GPU) - Fast OCR") |
| st.write("Upload an image to extract text using GPU acceleration") |
|
|
| |
| uploaded_file = st.file_uploader("Choose an image...", type=["png", "jpg", "jpeg"]) |
|
|
| if uploaded_file is not None: |
| |
| image = Image.open(uploaded_file) |
| st.image(image, caption='Uploaded Image', use_column_width=True) |
|
|
| if st.button("Run OCR"): |
| with st.spinner("Processing..."): |
| |
| img_array = np.array(image) |
| |
| result = reader.readtext(img_array, detail=0, paragraph=True) |
| |
| if result: |
| st.success("OCR Completed!") |
| st.text_area("Detected Text", "\n".join(result), height=300) |
| else: |
| st.warning("No text detected in the image.") |
|
|