alon-astria commited on
Commit
50650ee
·
verified ·
1 Parent(s): bd63d41

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +63 -1
app.py CHANGED
@@ -197,4 +197,66 @@ print(response.json())
197
  # See this Space's app.py for a full polling example.
198
  """
199
 
200
- with gr.Blocks(
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
197
  # See this Space's app.py for a full polling example.
198
  """
199
 
200
+ with gr.Blocks(css=css, theme=gr.themes.Soft()) as demo:
201
+ # --- Banner and Main Title ---
202
+ gr.HTML(
203
+ """
204
+ <div style="text-align: center; padding: 20px; background-color: #f0f8ff; border-radius: 10px; margin-bottom: 20px;">
205
+ <h2 style="color: #333;">Powered by the Astria.ai API</h2>
206
+ <p style="color: #555; font-size: 1.1em;">This Virtual Try-On demo uses a powerful, single-call API endpoint.
207
+ <br>
208
+ You can integrate this functionality directly into your own applications.
209
+ </p>
210
+ <a href="https://docs.astria.ai/docs/use-cases/virtual-try-on/" target="_blank" style="text-decoration: none;">
211
+ <button style="padding: 10px 20px; font-size: 1em; color: white; background-color: #007bff; border: none; border-radius: 5px; cursor: pointer;">
212
+ Read the Full API Documentation
213
+ </button>
214
+ </a>
215
+ </div>
216
+ """
217
+ )
218
+ gr.Markdown("# Virtual Fashion Try-On")
219
+ gr.Markdown(
220
+ """
221
+ **Instructions:** Upload a photo of a person and a photo of a piece of clothing to see them wear it.
222
+
223
+ This space is made available through the Astria API, which allows you to create virtual try-on experiences with just a few lines of code.
224
+ Astria fine-tuning API allows you to create custom AI models from your own images, and then use Virtual Try-On to make those models wear different clothing items.
225
+ This can be used for fashion e-commerce, virtual fitting rooms, music festivals and concerts and sport events activation campaigns. See more in [Astria Virtual Try-On documentation](https://docs.astria.ai/docs/use-cases/virtual-try-on/).
226
+ """
227
+ )
228
+
229
+ # --- Main Application UI ---
230
+ with gr.Row():
231
+ with gr.Column(scale=1):
232
+ human_image = gr.Image(type="filepath", label="Human Image", height=300)
233
+ garment_image = gr.Image(type="filepath", label="Garment Image", height=300)
234
+ garment_type = gr.Dropdown(
235
+ ["shirt", "pants", "dress"],
236
+ label="Garment Type",
237
+ info="Select the type of clothing item you uploaded.",
238
+ value="shirt"
239
+ )
240
+ submit_btn = gr.Button("Generate", variant="primary")
241
+ with gr.Column(scale=1):
242
+ status_text = gr.Textbox(label="Status", interactive=False, lines=2, placeholder="Upload images and click Generate...")
243
+ result_image = gr.Image(label="Result", height=615, interactive=False)
244
+
245
+ # --- API Usage Code Snippet ---
246
+ with gr.Accordion("Show API Usage Code (Python)", open=False):
247
+ gr.Code(
248
+ value=code_snippet,
249
+ language="python",
250
+ label="Python Request Example",
251
+ interactive=False
252
+ )
253
+
254
+ # --- Event Listener ---
255
+ submit_btn.click(
256
+ fn=virtual_tryon,
257
+ inputs=[human_image, garment_image, garment_type],
258
+ outputs=[result_image, status_text]
259
+ )
260
+
261
+ if __name__ == "__main__":
262
+ demo.launch()