File size: 1,053 Bytes
3087ac2
21d9b3a
3087ac2
ef0458a
3087ac2
 
 
 
21d9b3a
 
 
 
3087ac2
 
 
 
 
 
 
 
 
 
 
21d9b3a
 
3087ac2
 
 
21d9b3a
3087ac2
 
21d9b3a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import streamlit as st
import easyocr
from PIL import Image

# Set the page title and icon
st.set_page_config(page_title="Image to Text Converter", page_icon="🖼️", layout="centered")

st.title("🖼️ Image to Text Converter")
st.markdown("Extract text from images using AI-powered OCR!")

# Initialize OCR Reader
reader = easyocr.Reader(["en"])  # You can add more languages like ["en", "fr"]

# Upload Image
uploaded_file = st.file_uploader("Upload an Image", type=["png", "jpg", "jpeg"])

if uploaded_file is not None:
    # Load Image
    image = Image.open(uploaded_file)
    st.image(image, caption="Uploaded Image", use_column_width=True)
    
    # Convert Image to Text
    with st.spinner("Extracting text..."):
        text_results = reader.readtext(image)
        extracted_text = "\n".join([text[1] for text in text_results])
    
    # Display Extracted Text
    st.subheader("Extracted Text")
    st.text_area("", extracted_text, height=200)

st.markdown("---")
st.markdown("💡 Developed with ❤️ using Streamlit and EasyOCR")