wizzseen commited on
Commit
0017bb6
·
verified ·
1 Parent(s): 27bb813

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import shutil
3
+ import gradio as gr
4
+ from google.colab import files
5
+ from PIL import Image
6
+
7
+ def process_images(cloth_image, origin_image):
8
+ # Convert numpy arrays to PIL images
9
+ cloth_image = Image.fromarray(cloth_image)
10
+ origin_image = Image.fromarray(origin_image)
11
+ print(cloth_image)
12
+ print(origin_image)
13
+ # Define the input directory
14
+ input_dir = 'static'
15
+ print(input_dir)
16
+ # Ensure the directory exists
17
+ if not os.path.exists(input_dir):
18
+ os.makedirs(input_dir)
19
+
20
+ # Save the uploaded images to the input directory
21
+ cloth_image.save(os.path.join(input_dir, 'cloth_web.jpg'))
22
+ origin_image.save(os.path.join(input_dir, 'origin_web.jpg'))
23
+ print("saved")
24
+ # Run your main.py script (assuming it's in the same directory)
25
+ # Note: You might need to adjust the command based on your actual script's requirements
26
+ !python main.py
27
+ print("might run")
28
+ # Return the final image
29
+ final_image_path = os.path.join(input_dir, 'finalimg.png')
30
+ return final_image_path
31
+
32
+ garment_top = gr.Image(sources='upload', type="numpy")
33
+ garment_down = gr.Image(sources='upload', type="numpy")
34
+
35
+ demo = gr.Interface(process_images,inputs=[
36
+ garment_top,
37
+ garment_down,
38
+ ], outputs=["image"])
39
+
40
+ demo.launch(share=True, debug=True)