import streamlit as st from PIL import Image import pytesseract # Set Tesseract path (if required) # pytesseract.pytesseract.tesseract_cmd = r'' 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()