import streamlit as st import os import shutil from PIL import Image from nude import _process def main(): st.title("UndressInator") output_directory = "upload" if not os.path.exists(output_directory): os.makedirs(output_directory) uploaded_file = st.file_uploader("Choose an image...", type="jpg") if uploaded_file is not None: for file_name in os.listdir(output_directory): file_path = os.path.join(output_directory, file_name) try: if os.path.isfile(file_path): os.unlink(file_path) elif os.path.isdir(file_path): shutil.rmtree(file_path) except Exception as e: st.error(f"Error deleting file: {e}") image_path = os.path.join(output_directory, "input.jpg") with open(image_path, "wb") as f: f.write(uploaded_file.getvalue()) _process("upload/input.jpg", "upload/output.jpg", False) st.image(image_path, caption="Uploaded Image", use_column_width=True) st.image(Image.open("upload/output.jpg"), caption="Nude", use_column_width=True) if __name__ == "__main__": main()