aeon12 commited on
Commit
beebd0e
·
verified ·
1 Parent(s): a39f434

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -4
app.py CHANGED
@@ -96,14 +96,19 @@ def generate_tryon(cloth_input, user_input, background):
96
 
97
  time.sleep(2)
98
  def tryon_interface(cloth_selected, cloth_upload, user_selected, user_upload, scene_selection, custom_scene):
99
- cloth = cloth_selected if cloth_selected else cloth_upload
100
- user = user_selected if user_selected else user_upload
 
 
 
 
 
101
  background = custom_scene if custom_scene else scene_selection
102
 
103
  if cloth is None:
104
- return None, "Please select a clothing image from the gallery or upload one."
105
  if user is None:
106
- return None, "Please select a user image from the gallery or upload one."
107
  if not background:
108
  return None, "Please select or enter a background scene."
109
 
@@ -113,6 +118,7 @@ def tryon_interface(cloth_selected, cloth_upload, user_selected, user_upload, sc
113
  except Exception as e:
114
  return None, f"Error: {str(e)}"
115
 
 
116
  with gr.Blocks() as demo:
117
  gr.Markdown("# TryItOut.AI")
118
 
@@ -174,10 +180,12 @@ with gr.Blocks() as demo:
174
  outputs=[user_upload]
175
  )
176
 
 
177
  generate_button.click(
178
  tryon_interface,
179
  inputs=[cloth_selected, cloth_upload, user_selected, user_upload, scene_selection, custom_scene],
180
  outputs=[output_image, output_text]
181
  )
182
 
 
183
  demo.launch()
 
96
 
97
  time.sleep(2)
98
  def tryon_interface(cloth_selected, cloth_upload, user_selected, user_upload, scene_selection, custom_scene):
99
+ # Use selected cloth if available, otherwise use uploaded cloth
100
+ cloth = cloth_selected if cloth_selected is not None else cloth_upload
101
+
102
+ # Use selected user image if available, otherwise use uploaded user image
103
+ user = user_selected if user_selected is not None else user_upload
104
+
105
+ # Use custom scene if provided, otherwise use selected scene
106
  background = custom_scene if custom_scene else scene_selection
107
 
108
  if cloth is None:
109
+ return None, "Please select or upload a clothing image."
110
  if user is None:
111
+ return None, "Please select or upload a user image."
112
  if not background:
113
  return None, "Please select or enter a background scene."
114
 
 
118
  except Exception as e:
119
  return None, f"Error: {str(e)}"
120
 
121
+
122
  with gr.Blocks() as demo:
123
  gr.Markdown("# TryItOut.AI")
124
 
 
180
  outputs=[user_upload]
181
  )
182
 
183
+
184
  generate_button.click(
185
  tryon_interface,
186
  inputs=[cloth_selected, cloth_upload, user_selected, user_upload, scene_selection, custom_scene],
187
  outputs=[output_image, output_text]
188
  )
189
 
190
+
191
  demo.launch()