File size: 788 Bytes
142f9e3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from PIL import Image
import pytesseract

# Set Tesseract path (if required)
# pytesseract.pytesseract.tesseract_cmd = r'<path to tesseract executable>'

def main():
    st.title("Image Text Extractor")

    st.write("Upload an image to extract text from it.")
    uploaded_image = st.file_uploader("Choose an image...", type=["jpg", "png", "jpeg"])

    if uploaded_image is not None:
        image = Image.open(uploaded_image)
        st.image(image, caption='Uploaded Image', use_column_width=True)

        st.write("")
        st.write("Click below to extract text from the image:")
        if st.button('Extract Text'):
            extracted_text = pytesseract.image_to_string(image)
            st.write(extracted_text)

if __name__ == '__main__':
    main()