import streamlit as st from utilitis import Draw,Change_Image,check_if_changed,Update from PIL import Image import time st.set_page_config(layout='wide') st.title("Bienvenue à Textra Web App") st.markdown("### Drag and Drop votre facture ici:") st.write("(PNG, JPG, JPEG)") uploaded_file = st.file_uploader("Ou selectioner une image:", type=["png", "jpg", "jpeg"], accept_multiple_files=False) if uploaded_file is not None: image_initiale = Image.open(uploaded_file) image_initiale = image_initiale.convert("RGB") @st.cache_data def process_image(uploaded_file): image = Image.open(uploaded_file) image = image.convert("RGB") return Draw(image) # Process the image and retrieve results image, Results,execution_time = process_image(uploaded_file) # Execution Time st.write(f"Execution Time: {execution_time:.2f} seconds") # Change Image Change_Image(image,image_initiale) # Some Initializations sauvgarder_button = st.sidebar.empty() success_message = st.sidebar.empty() st.sidebar.title('Results') # Get Track of User Modeifications : New_results = Update(Results) # Check if any input has been changed if check_if_changed(Results,New_results): st.write(check_if_changed(Results,New_results)) if sauvgarder_button.button("Sauvegarder"): success_message.success("Les résultats ont été sauvegardés avec succès !") time.sleep(1) success_message.empty() st.write(New_results)