Ravi21 commited on
Commit
6791068
1 Parent(s): 7b17801

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import os
2
+ import streamlit as st
3
+ from PIL import Image
4
+
5
+ from inference import get_result_images
6
+
7
+ human_image_names = sorted([fn[:-4] for fn in os.listdir('dataset/test_img')])
8
+
9
+ if st.sidebar.checkbox('Upload'):
10
+ human_file = st.sidebar.file_uploader("Upload a Human Image", type=["png", "jpg", "jpeg"])
11
+ if human_file is None:
12
+ human_file = 'dataset/test_img/default.png'
13
+ else:
14
+ human_image_name = st.sidebar.selectbox("Choose a Human Image", human_image_names)
15
+ human_file = f'dataset/test_img/{human_image_name}.png'
16
+ if not os.path.exists(human_file):
17
+ human_file = human_file.replace('.png', '.jpg')
18
+ st.warning("Upload a Human Image in the sidebar for Virtual-Try-On")
19
+
20
+ human = Image.open(human_file)
21
+ human.save('dataset/test_img/input.png')
22
+ st.sidebar.image(human, width=300)
23
+
24
+ result_images = get_result_images()
25
+ st.image(result_images, width=600)