Eaglebelt commited on
Commit
eb45514
·
verified ·
1 Parent(s): 23a2028

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -6
app.py CHANGED
@@ -19,7 +19,7 @@ client = Client(
19
  def virtual_tryon(
20
  person_path,
21
  garment_path,
22
- vt_garment_type="upper_body",
23
  ):
24
  # 2) Wrap file inputs so Gradio client uploads them correctly
25
  person_file = handle_file(
@@ -27,6 +27,7 @@ def virtual_tryon(
27
  ) # handle_file uploads the image :contentReference[oaicite:6]{index=6}
28
  garment_file = handle_file(garment_path)
29
 
 
30
  # 3) Build inputs in the exact order shown on the “Use via API” page :contentReference[oaicite:7]{index=7}
31
 
32
  # 4) Call the named endpoint with handle_file inputs
@@ -38,9 +39,9 @@ def virtual_tryon(
38
  scale=2.5,
39
  seed=42,
40
  vt_model_type="viton_hd",
41
- vt_garment_type="upper_body",
42
  vt_repaint=False,
43
- api_name="/leffa_predict_vt")
44
  # result[0] is the generated image filepath on the server
45
  return result[0] # Gradio will download & display this file
46
 
@@ -54,11 +55,11 @@ with gr.Blocks() as demo:
54
  ref = gr.Image(sources="upload",
55
  type="filepath",
56
  label="Garment Image")
57
- vt_garment_type = gr.Radio(
58
- label="Garment Type",
59
  choices=[("Upper", "upper_body"), ("Lower", "lower_body"),
60
  ("Dress", "dresses")],
61
  value="upper_body",
 
62
  )
63
 
64
  with gr.Column():
@@ -67,7 +68,7 @@ with gr.Blocks() as demo:
67
  label="Result",
68
  )
69
  btn = gr.Button("Generate")
70
- btn.click(virtual_tryon, [src, ref, vt_garment_type], out)
71
 
72
  demo.launch(
73
  share=True,
 
19
  def virtual_tryon(
20
  person_path,
21
  garment_path,
22
+ garment_type,
23
  ):
24
  # 2) Wrap file inputs so Gradio client uploads them correctly
25
  person_file = handle_file(
 
27
  ) # handle_file uploads the image :contentReference[oaicite:6]{index=6}
28
  garment_file = handle_file(garment_path)
29
 
30
+
31
  # 3) Build inputs in the exact order shown on the “Use via API” page :contentReference[oaicite:7]{index=7}
32
 
33
  # 4) Call the named endpoint with handle_file inputs
 
39
  scale=2.5,
40
  seed=42,
41
  vt_model_type="viton_hd",
42
+ vt_garment_type=garment_type,
43
  vt_repaint=False,
44
+ api_name="/leffa_predict_vt",)
45
  # result[0] is the generated image filepath on the server
46
  return result[0] # Gradio will download & display this file
47
 
 
55
  ref = gr.Image(sources="upload",
56
  type="filepath",
57
  label="Garment Image")
58
+ garment_type = gr.Radio(
 
59
  choices=[("Upper", "upper_body"), ("Lower", "lower_body"),
60
  ("Dress", "dresses")],
61
  value="upper_body",
62
+ label="Garment Type",
63
  )
64
 
65
  with gr.Column():
 
68
  label="Result",
69
  )
70
  btn = gr.Button("Generate")
71
+ btn.click(virtual_tryon, [src, ref, garment_type], out)
72
 
73
  demo.launch(
74
  share=True,