Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -13,7 +13,7 @@ st.set_page_config(
|
|
13 |
initial_sidebar_state="expanded"
|
14 |
)
|
15 |
|
16 |
-
# Custom CSS for better styling
|
17 |
st.markdown("""
|
18 |
<style>
|
19 |
.stApp {
|
@@ -34,9 +34,31 @@ st.markdown("""
|
|
34 |
margin: 20px 0;
|
35 |
background-color: #f8f9fa;
|
36 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
37 |
</style>
|
38 |
""", unsafe_allow_html=True)
|
39 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
# Title and description
|
41 |
st.title("✨ Virtual Try-On Application")
|
42 |
st.markdown("""Upload a garment image and a person's photo to see how the garment would look on them!""")
|
@@ -47,58 +69,32 @@ col1, col2 = st.columns(2)
|
|
47 |
# Garment image upload
|
48 |
with col1:
|
49 |
st.subheader("Garment Image")
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
garment_img = Image.open(garment_file)
|
62 |
-
garment_buffer = BytesIO()
|
63 |
-
garment_img.save(garment_buffer, format="PNG")
|
64 |
-
garment_url = "temp_garment.png"
|
65 |
-
with open(garment_url, "wb") as f:
|
66 |
-
f.write(garment_buffer.getvalue())
|
67 |
-
else:
|
68 |
-
garment_url = st.text_input("Enter garment image URL", key="garment_url")
|
69 |
-
if garment_url:
|
70 |
-
try:
|
71 |
-
st.image(garment_url, caption="Garment from URL", use_container_width=True)
|
72 |
-
except:
|
73 |
-
st.error("Unable to load image from URL")
|
74 |
|
75 |
# Person image upload
|
76 |
with col2:
|
77 |
st.subheader("Person Image")
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
person_img = Image.open(person_file)
|
90 |
-
person_buffer = BytesIO()
|
91 |
-
person_img.save(person_buffer, format="PNG")
|
92 |
-
person_url = "temp_person.png"
|
93 |
-
with open(person_url, "wb") as f:
|
94 |
-
f.write(person_buffer.getvalue())
|
95 |
-
else:
|
96 |
-
person_url = st.text_input("Enter person image URL", key="person_url")
|
97 |
-
if person_url:
|
98 |
-
try:
|
99 |
-
st.image(person_url, caption="Person from URL", use_container_width=True)
|
100 |
-
except:
|
101 |
-
st.error("Unable to load image from URL")
|
102 |
|
103 |
# Garment description input
|
104 |
st.subheader("Garment Description")
|
@@ -139,10 +135,10 @@ if st.button("Generate Try-On", type="primary"):
|
|
139 |
except Exception as e:
|
140 |
st.error(f"Error occurred: {str(e)}")
|
141 |
|
142 |
-
# Footer
|
143 |
-
st.markdown("---")
|
144 |
st.markdown("""
|
145 |
-
<div
|
146 |
-
<p
|
|
|
147 |
</div>
|
148 |
""", unsafe_allow_html=True)
|
|
|
13 |
initial_sidebar_state="expanded"
|
14 |
)
|
15 |
|
16 |
+
# Custom CSS for better styling with Renesistech branding
|
17 |
st.markdown("""
|
18 |
<style>
|
19 |
.stApp {
|
|
|
34 |
margin: 20px 0;
|
35 |
background-color: #f8f9fa;
|
36 |
}
|
37 |
+
.renesistech-header {
|
38 |
+
background-color: #ffffff;
|
39 |
+
padding: 20px;
|
40 |
+
margin-bottom: 30px;
|
41 |
+
box-shadow: 0 2px 4px rgba(0,0,0,0.1);
|
42 |
+
text-align: center;
|
43 |
+
}
|
44 |
+
.renesistech-footer {
|
45 |
+
background-color: #f8f9fa;
|
46 |
+
padding: 20px;
|
47 |
+
text-align: center;
|
48 |
+
border-top: 1px solid #e0e0e0;
|
49 |
+
margin-top: 40px;
|
50 |
+
}
|
51 |
</style>
|
52 |
""", unsafe_allow_html=True)
|
53 |
|
54 |
+
# Add Renesistech header
|
55 |
+
st.markdown("""
|
56 |
+
<div class='renesistech-header'>
|
57 |
+
<h1 style='color: #333; margin: 0;'>Renesistech</h1>
|
58 |
+
<p style='color: #666; margin: 10px 0 0 0;'>Virtual Try-On Solution</p>
|
59 |
+
</div>
|
60 |
+
""", unsafe_allow_html=True)
|
61 |
+
|
62 |
# Title and description
|
63 |
st.title("✨ Virtual Try-On Application")
|
64 |
st.markdown("""Upload a garment image and a person's photo to see how the garment would look on them!""")
|
|
|
69 |
# Garment image upload
|
70 |
with col1:
|
71 |
st.subheader("Garment Image")
|
72 |
+
garment_file = st.file_uploader("Upload garment image", type=["jpg", "jpeg", "png", "webp"], key="garment_upload")
|
73 |
+
garment_url = None
|
74 |
+
if garment_file:
|
75 |
+
st.image(garment_file, caption="Uploaded Garment", use_container_width=True)
|
76 |
+
# Save uploaded file to temporary file
|
77 |
+
garment_img = Image.open(garment_file)
|
78 |
+
garment_buffer = BytesIO()
|
79 |
+
garment_img.save(garment_buffer, format="PNG")
|
80 |
+
garment_url = "temp_garment.png"
|
81 |
+
with open(garment_url, "wb") as f:
|
82 |
+
f.write(garment_buffer.getvalue())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
83 |
|
84 |
# Person image upload
|
85 |
with col2:
|
86 |
st.subheader("Person Image")
|
87 |
+
person_file = st.file_uploader("Upload person image", type=["jpg", "jpeg", "png", "webp"], key="person_upload")
|
88 |
+
person_url = None
|
89 |
+
if person_file:
|
90 |
+
st.image(person_file, caption="Uploaded Person", use_container_width=True)
|
91 |
+
# Save uploaded file to temporary file
|
92 |
+
person_img = Image.open(person_file)
|
93 |
+
person_buffer = BytesIO()
|
94 |
+
person_img.save(person_buffer, format="PNG")
|
95 |
+
person_url = "temp_person.png"
|
96 |
+
with open(person_url, "wb") as f:
|
97 |
+
f.write(person_buffer.getvalue())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
|
99 |
# Garment description input
|
100 |
st.subheader("Garment Description")
|
|
|
135 |
except Exception as e:
|
136 |
st.error(f"Error occurred: {str(e)}")
|
137 |
|
138 |
+
# Renesistech Footer
|
|
|
139 |
st.markdown("""
|
140 |
+
<div class='renesistech-footer'>
|
141 |
+
<p style='color: #333; font-weight: bold; margin: 0;'>© 2024 Renesistech</p>
|
142 |
+
<p style='color: #666; margin: 5px 0 0 0;'>Innovating Fashion Technology</p>
|
143 |
</div>
|
144 |
""", unsafe_allow_html=True)
|