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