usmanyousaf commited on
Commit
acbf029
·
verified ·
1 Parent(s): 62b1a32

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -32
app.py CHANGED
@@ -82,52 +82,54 @@ def tryon(person_img, garment_img, seed, randomize_seed):
82
  MAX_SEED = 999999
83
 
84
  # Set up the Streamlit app
85
- st.set_page_config(page_title="Virtual-DressUp", page_icon=":guardsman:", layout="wide")
86
 
87
  st.title("Virtual-DressUp")
88
  st.markdown("""
89
- **Step 1:** Upload a person image ⬇️
90
- **Step 2:** Upload a garment image ⬇️
91
- **Step 3:** Press “Run” to get try-on results
 
 
92
  """)
93
 
 
 
 
 
94
  col1, col2 = st.columns(2)
95
 
96
  with col1:
97
- person_img = st.file_uploader("Person Image", type=["jpg", "jpeg", "png"])
98
-
99
  with col2:
100
- garment_img = st.file_uploader("Garment Image", type=["jpg", "jpeg", "png"])
101
 
102
- if person_img and garment_img:
103
- person_img = np.array(bytearray(person_img.read()), dtype=np.uint8)
104
- garment_img = np.array(bytearray(garment_img.read()), dtype=np.uint8)
105
- person_img = cv2.imdecode(person_img, cv2.IMREAD_COLOR)
106
- garment_img = cv2.imdecode(garment_img, cv2.IMREAD_COLOR)
107
-
108
- st.sidebar.header("Options")
109
- st.sidebar.subheader("Instructions")
110
- st.sidebar.markdown("""
111
- 1. Upload your **person image** 📸
112
- 2. Upload your **garment image** 👗
113
- 3. Press **“Run”** to get the try-on results 🔍
114
- """)
115
-
116
- seed = st.sidebar.slider("Seed", 0, MAX_SEED, 0)
117
- randomize_seed = st.sidebar.checkbox("Random seed", value=True)
118
 
119
- if st.sidebar.button("Run"):
 
 
 
 
 
 
 
 
 
 
 
 
 
 
120
  result_img, seed_used, result_info = tryon(person_img, garment_img, seed, randomize_seed)
121
  if result_info == "Success":
122
  st.image(result_img, caption="Result", channels="BGR")
123
  st.sidebar.text(f"Seed used: {seed_used}")
124
  else:
125
  st.sidebar.error(result_info)
126
- else:
127
- st.sidebar.warning("Please upload both images to proceed.")
128
-
129
- st.markdown("""
130
- ### About This Project
131
-
132
- This project features a virtual try-on model created by **Kwai-Kolors**. We provide a user-friendly GUI to showcase this model. For more amazing features and cool stuff, visit [Kwai-Kolors](https://klingai.com/).
133
- """)
 
82
  MAX_SEED = 999999
83
 
84
  # Set up the Streamlit app
85
+ st.set_page_config(page_title="Virtual-DressUp", page_icon=":dress:", layout="wide")
86
 
87
  st.title("Virtual-DressUp")
88
  st.markdown("""
89
+ **Project Overview:**
90
+ This project leverages the advanced virtual try-on model by Kwai-Kolors. We've created a simple and interactive GUI for users to experience virtual try-ons. For more innovative features and models, check out Kwai-Kolors on their official website!
91
+
92
+ [Explore Kwai-Kolors' website](https://klingai.com/)
93
+
94
  """)
95
 
96
+ # Display the demo image
97
+ st.image("demo img.png", caption="Demo Image", use_column_width=True)
98
+
99
+ # Image upload columns
100
  col1, col2 = st.columns(2)
101
 
102
  with col1:
103
+ person_img = st.file_uploader("Upload Person Image", type=["jpg", "jpeg", "png"])
104
+
105
  with col2:
106
+ garment_img = st.file_uploader("Upload Garment Image", type=["jpg", "jpeg", "png"])
107
 
108
+ # Always show slider options
109
+ st.sidebar.header("Options")
110
+ seed = st.sidebar.slider("Seed", 0, MAX_SEED, 0)
111
+ randomize_seed = st.sidebar.checkbox("Random seed", value=True)
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
+ # Show steps in sidebar
114
+ st.sidebar.markdown("""
115
+ **Steps to Follow:**
116
+ 1. Upload a person image ⬇️
117
+ 2. Upload a garment image ⬇️
118
+ 3. Press "Run" to get try-on results 🎉
119
+ """)
120
+
121
+ if st.sidebar.button("Run"):
122
+ if person_img and garment_img:
123
+ person_img = np.array(bytearray(person_img.read()), dtype=np.uint8)
124
+ garment_img = np.array(bytearray(garment_img.read()), dtype=np.uint8)
125
+ person_img = cv2.imdecode(person_img, cv2.IMREAD_COLOR)
126
+ garment_img = cv2.imdecode(garment_img, cv2.IMREAD_COLOR)
127
+
128
  result_img, seed_used, result_info = tryon(person_img, garment_img, seed, randomize_seed)
129
  if result_info == "Success":
130
  st.image(result_img, caption="Result", channels="BGR")
131
  st.sidebar.text(f"Seed used: {seed_used}")
132
  else:
133
  st.sidebar.error(result_info)
134
+ else:
135
+ st.sidebar.warning("Please upload both images to proceed.")