File size: 705 Bytes
5a49c3d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import streamlit as st
from PIL import Image
import pytesseract

st.set_page_config(page_title="Image to Text OCR", layout="centered")
st.title("🖼️ Image to Text Converter")
st.write("Upload an image and extract text using Optical Character Recognition (OCR).")

uploaded_file = st.file_uploader("Choose an image", type=["jpg", "jpeg", "png"])

if uploaded_file:
    image = Image.open(uploaded_file)
    st.image(image, caption="Uploaded Image", use_column_width=True)

    if st.button("Extract Text"):
        with st.spinner("Running OCR..."):
            text = pytesseract.image_to_string(image)
        st.subheader("Extracted Text")
        st.text_area("OCR Result", value=text, height=300)