Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
|
@@ -82,28 +82,27 @@ 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
|
| 86 |
|
| 87 |
-
|
| 88 |
-
st.title("Virtual Try-On")
|
| 89 |
st.markdown("""
|
| 90 |
-
**
|
| 91 |
-
|
| 92 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 93 |
""")
|
| 94 |
|
| 95 |
-
# Columns for uploading images
|
| 96 |
col1, col2 = st.columns(2)
|
| 97 |
|
| 98 |
with col1:
|
| 99 |
-
st.image("assets/upload_person.png", caption="Upload your person image here.", use_column_width=True)
|
| 100 |
person_img = st.file_uploader("Person Image", type=["jpg", "jpeg", "png"], label_visibility="collapsed")
|
| 101 |
|
| 102 |
with col2:
|
| 103 |
-
st.image("assets/upload_garment.png", caption="Upload your garment image here.", use_column_width=True)
|
| 104 |
garment_img = st.file_uploader("Garment Image", type=["jpg", "jpeg", "png"], label_visibility="collapsed")
|
| 105 |
|
| 106 |
-
# Show options and button if images are uploaded
|
| 107 |
if person_img and garment_img:
|
| 108 |
person_img = np.array(bytearray(person_img.read()), dtype=np.uint8)
|
| 109 |
garment_img = np.array(bytearray(garment_img.read()), dtype=np.uint8)
|
|
@@ -113,11 +112,6 @@ if person_img and garment_img:
|
|
| 113 |
st.sidebar.header("Options")
|
| 114 |
seed = st.sidebar.slider("Seed", 0, MAX_SEED, 0)
|
| 115 |
randomize_seed = st.sidebar.checkbox("Random seed", value=True)
|
| 116 |
-
|
| 117 |
-
st.sidebar.markdown("---")
|
| 118 |
-
|
| 119 |
-
# Display example images
|
| 120 |
-
st.sidebar.image("Screenshot 2024-09-18 at 1.59.41 PM.png", caption="Example of seed usage", use_column_width=True)
|
| 121 |
|
| 122 |
if st.sidebar.button("Run"):
|
| 123 |
result_img, seed_used, result_info = tryon(person_img, garment_img, seed, randomize_seed)
|
|
@@ -128,16 +122,3 @@ if person_img and garment_img:
|
|
| 128 |
st.sidebar.error(result_info)
|
| 129 |
else:
|
| 130 |
st.sidebar.warning("Please upload both images to proceed.")
|
| 131 |
-
|
| 132 |
-
# Footer or additional information
|
| 133 |
-
st.markdown("---")
|
| 134 |
-
st.markdown("Built with Streamlit & Python. [GitHub repository](#)")
|
| 135 |
-
|
| 136 |
-
# Add some styling and visual improvements
|
| 137 |
-
st.markdown("""
|
| 138 |
-
<style>
|
| 139 |
-
.css-18e3th9 {padding: 0.5rem 1rem;} /* Increase padding for the sidebar */
|
| 140 |
-
.css-1d391kg {padding: 1rem;} /* Increase padding for main content area */
|
| 141 |
-
.css-1v0mbdj {font-size: 20px;} /* Adjust font size for titles and labels */
|
| 142 |
-
</style>
|
| 143 |
-
""", unsafe_allow_html=True)
|
|
|
|
| 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 Model by Kwai-Kolors**
|
| 90 |
+
We provide a sleek GUI to showcase their powerful virtual try-on technology. Explore more cool stuff at [Kwai-Kolors](https://klingai.com/)
|
| 91 |
+
|
| 92 |
+
**Steps:**
|
| 93 |
+
1. **Upload your person image** ⬇️
|
| 94 |
+
2. **Upload your garment image** ⬇️
|
| 95 |
+
3. **Press “Run” to get the try-on results** ✅
|
| 96 |
""")
|
| 97 |
|
|
|
|
| 98 |
col1, col2 = st.columns(2)
|
| 99 |
|
| 100 |
with col1:
|
|
|
|
| 101 |
person_img = st.file_uploader("Person Image", type=["jpg", "jpeg", "png"], label_visibility="collapsed")
|
| 102 |
|
| 103 |
with col2:
|
|
|
|
| 104 |
garment_img = st.file_uploader("Garment Image", type=["jpg", "jpeg", "png"], label_visibility="collapsed")
|
| 105 |
|
|
|
|
| 106 |
if person_img and garment_img:
|
| 107 |
person_img = np.array(bytearray(person_img.read()), dtype=np.uint8)
|
| 108 |
garment_img = np.array(bytearray(garment_img.read()), dtype=np.uint8)
|
|
|
|
| 112 |
st.sidebar.header("Options")
|
| 113 |
seed = st.sidebar.slider("Seed", 0, MAX_SEED, 0)
|
| 114 |
randomize_seed = st.sidebar.checkbox("Random seed", value=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 115 |
|
| 116 |
if st.sidebar.button("Run"):
|
| 117 |
result_img, seed_used, result_info = tryon(person_img, garment_img, seed, randomize_seed)
|
|
|
|
| 122 |
st.sidebar.error(result_info)
|
| 123 |
else:
|
| 124 |
st.sidebar.warning("Please upload both images to proceed.")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|