import streamlit as st from PIL import Image import easyocr import numpy as np # Initialize EasyOCR Reader for specific languages reader = easyocr.Reader(['en', 'ur']) # Include 'ur' for Urdu # Title st.title("OCR App with EasyOCR") # File uploader uploaded_file = st.file_uploader("Upload an image", type=["jpg", "jpeg", "png"]) if uploaded_file is not None: # Open and display the image image = Image.open(uploaded_file) st.image(image, caption="Uploaded Image", use_column_width=True) # Convert to numpy array for OCR img_array = np.array(image) # Perform OCR with st.spinner("Processing..."): results = reader.readtext(img_array) # Display results detected_text = "" for (bbox, text, prob) in results: detected_text += f"{text} " st.write("Detected Text:", detected_text)