File size: 1,190 Bytes
857d2e0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
30
31
32
33
34
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()