File size: 794 Bytes
67c0b77
 
 
48de7d6
67c0b77
48de7d6
 
 
 
 
 
67c0b77
48de7d6
 
 
67c0b77
48de7d6
67c0b77
48de7d6
 
 
 
 
 
 
 
 
 
 
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
import streamlit as st
from PIL import Image
import pytesseract
import io

def perform_ocr(image):
    try:
        text = pytesseract.image_to_string(image)
        return text
    except Exception as e:
        return f"An error occurred: {str(e)}"

def main():
    st.title("Image to Text Converter")
    st.write("Upload an image and get the extracted text!")

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

    if uploaded_file is not None:
        image = Image.open(uploaded_file)
        st.image(image, caption='Uploaded Image', use_column_width=True)
        st.write("")
        st.write("Extracting text...")
        text = perform_ocr(image)
        st.write("Extracted Text:")
        st.write(text)

if __name__ == "__main__":
    main()