import easyocr as ocr # OCR import streamlit as st # Web App from PIL import Image # Image Processing import numpy as np # Image Processing # Title st.title("Easy OCR - Extract Text from Images") # Subtitle st.markdown("## Optical Character Recognition - Using easyocr - hosted on 🦄 Spaces") st.markdown("") # Image uploader image = st.file_uploader(label="Upload your image here", type=['png', 'jpg', 'jpeg']) @st.cache def load_model(): reader = ocr.Reader(['en'], model_storage_directory='.') return reader reader = load_model() # Load model if image is not None: input_image = Image.open(image) # Read image st.image(input_image) # Display image with st.spinner("🤖 AI is at Work! "): result = reader.readtext(np.array(input_image)) result_text = [] # Empty list for results for text in result: result_text.append(text[1]) st.write(result_text) st.success("Here you go!") st.balloons() else: st.write("Upload an Image") st.caption("Made with ❤ by @littlecoder")