File size: 846 Bytes
5a49c3d
 
 
 
8dcc7ce
4c46b65
5a49c3d
8dcc7ce
5a49c3d
89993cb
8dcc7ce
 
89993cb
8dcc7ce
 
 
89993cb
8dcc7ce
 
 
 
89993cb
 
8dcc7ce
 
89993cb
 
5a49c3d
4c46b65
95abc88
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
import streamlit as st
from PIL import Image
import pytesseract

st.set_page_config(page_title="OCR - Image to Text", layout="centered")
st.title("๐Ÿ–ผ๏ธ OCR - Image to Text")

st.write("Upload an image to extract text:")

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

# Show uploaded image and extraction options
if uploaded_file is not None:
    try:
        image = Image.open(uploaded_file)
        st.image(image, caption="Uploaded Image", use_column_width=True)

        if st.button("Extract Text"):
            with st.spinner("Extracting text..."):
                text = pytesseract.image_to_string(image)
            st.success("โœ… Text extracted!")
            st.text_area("Extracted Text", value=text, height=300)

    except Exception as e:
        st.error(f"โŒ Error: {e}")