|
import streamlit as st |
|
import easyocr |
|
import io |
|
from PIL import Image |
|
|
|
|
|
reader = easyocr.Reader(['en']) |
|
|
|
|
|
def extract_text_from_image(image): |
|
result = reader.readtext(image) |
|
extracted_text = "\n".join([text[1] for text in result]) |
|
return extracted_text |
|
|
|
|
|
st.title("OCR Text Extraction with EasyOCR") |
|
uploaded_file = st.file_uploader("Upload an image (JPG, PNG, etc.)", type=["jpg", "png"]) |
|
|
|
if uploaded_file: |
|
|
|
image = Image.open(uploaded_file) |
|
|
|
extracted_text = extract_text_from_image(image) |
|
|
|
st.subheader("Extracted Text:") |
|
st.write(extracted_text) |
|
|