Alaiy commited on
Commit
c0c7e30
·
verified ·
1 Parent(s): 8a5aecb

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +58 -12
app.py CHANGED
@@ -159,23 +159,69 @@ def generate_presigned_url(object_url):
159
 
160
 
161
  with gr.Blocks() as demo:
162
- with gr.Row():
163
- image_url_input = gr.Textbox(label="Image URL", placeholder="Enter image URL here")
164
- input_garment_image = gr.Image(label="Garment Image", type="pil", width="384px", height = "512px")
165
- uploaded_image = gr.Image(label="Upload or Capture Image", type="pil", width="384px", height="512px")
166
- output_display = gr.Image(label="Displayed Image or URL Result", width="384px", height="512px")
167
-
168
- image_url_input.change(
169
- load_image_from_url,
170
- inputs=image_url_input,
171
- outputs=input_garment_image
172
- )
173
- submit_btn = gr.Button("Submit")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)