Update app.py
Browse files
app.py
CHANGED
|
@@ -159,23 +159,69 @@ def generate_presigned_url(object_url):
|
|
| 159 |
|
| 160 |
|
| 161 |
with gr.Blocks() as demo:
|
| 162 |
-
|
| 163 |
-
|
| 164 |
-
|
| 165 |
-
|
| 166 |
-
|
| 167 |
-
|
| 168 |
-
|
| 169 |
-
|
| 170 |
-
|
| 171 |
-
|
| 172 |
-
|
| 173 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 174 |
submit_btn.click(
|
| 175 |
display_image,
|
| 176 |
inputs=[uploaded_image, image_url_input],
|
| 177 |
outputs=output_display
|
| 178 |
)
|
| 179 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 180 |
|
| 181 |
demo.launch(share=True)
|
|
|
|
| 159 |
|
| 160 |
|
| 161 |
with gr.Blocks() as demo:
|
| 162 |
+
gr.Markdown("## Virtual Try-On")
|
| 163 |
+
|
| 164 |
+
# Responsive container for different screen sizes
|
| 165 |
+
with gr.Row(elem_id="responsive-container"):
|
| 166 |
+
with gr.Column(scale=1):
|
| 167 |
+
image_url_input = gr.Textbox(
|
| 168 |
+
label="Image URL",
|
| 169 |
+
placeholder="Enter image URL here",
|
| 170 |
+
interactive=True,
|
| 171 |
+
elem_id="url-input"
|
| 172 |
+
)
|
| 173 |
+
input_garment_image = gr.Image(
|
| 174 |
+
label="Garment Image",
|
| 175 |
+
type="pil",
|
| 176 |
+
interactive=True,
|
| 177 |
+
elem_id="garment-image"
|
| 178 |
+
)
|
| 179 |
+
with gr.Column(scale=1):
|
| 180 |
+
uploaded_image = gr.Image(
|
| 181 |
+
label="Upload or Capture Image",
|
| 182 |
+
type="pil",
|
| 183 |
+
interactive=True,
|
| 184 |
+
elem_id="uploaded-image"
|
| 185 |
+
)
|
| 186 |
+
output_display = gr.Image(
|
| 187 |
+
label="Displayed Image or URL Result",
|
| 188 |
+
elem_id="output-image"
|
| 189 |
+
)
|
| 190 |
+
|
| 191 |
+
submit_btn = gr.Button("Submit", elem_id="submit-btn")
|
| 192 |
submit_btn.click(
|
| 193 |
display_image,
|
| 194 |
inputs=[uploaded_image, image_url_input],
|
| 195 |
outputs=output_display
|
| 196 |
)
|
| 197 |
|
| 198 |
+
# Update the garment image when the URL changes
|
| 199 |
+
image_url_input.change(
|
| 200 |
+
load_image_from_url,
|
| 201 |
+
inputs=image_url_input,
|
| 202 |
+
outputs=input_garment_image
|
| 203 |
+
)
|
| 204 |
+
|
| 205 |
+
# Custom CSS for responsiveness
|
| 206 |
+
custom_css = """
|
| 207 |
+
#responsive-container {
|
| 208 |
+
flex-wrap: wrap !important; /* Allow wrapping on small screens */
|
| 209 |
+
justify-content: center;
|
| 210 |
+
}
|
| 211 |
+
#responsive-container .gr-column {
|
| 212 |
+
flex: 1 1 100%; /* Full width on small screens */
|
| 213 |
+
max-width: 100%; /* Prevent exceeding screen width */
|
| 214 |
+
}
|
| 215 |
+
@media (min-width: 768px) {
|
| 216 |
+
#responsive-container .gr-column {
|
| 217 |
+
flex: 1 1 50%; /* Half width on larger screens */
|
| 218 |
+
max-width: 50%;
|
| 219 |
+
}
|
| 220 |
+
}
|
| 221 |
+
"""
|
| 222 |
+
|
| 223 |
+
# Attach the custom CSS
|
| 224 |
+
demo.css = custom_css
|
| 225 |
+
|
| 226 |
|
| 227 |
demo.launch(share=True)
|