multimodalart HF staff commited on
Commit
86d5e88
1 Parent(s): ad4d288

Improve input check

Browse files
Files changed (1) hide show
  1. app.py +7 -5
app.py CHANGED
@@ -90,7 +90,9 @@ def upscale(samples, upscale_method, scale_by):
90
  s = common_upscale(samples["images"], width, height, upscale_method, "disabled")
91
  return (s)
92
 
93
- def check_prompt(prompt: str):
 
 
94
  if prompt is None or prompt == "":
95
  raise gr.Error("Prompt is required")
96
 
@@ -197,8 +199,8 @@ with gr.Blocks(css=css) as app:
197
 
198
  history = show_gallery_history()
199
  prompt.submit(
200
- check_prompt,
201
- inputs=[prompt],
202
  queue=False
203
  ).success(
204
  inference,
@@ -208,8 +210,8 @@ with gr.Blocks(css=css) as app:
208
  fn=fetch_gallery_history, inputs=[prompt, result_image], outputs=history, queue=False
209
  )
210
  run_btn.click(
211
- check_prompt,
212
- inputs=[prompt],
213
  queue=False
214
  ).success(
215
  inference,
 
90
  s = common_upscale(samples["images"], width, height, upscale_method, "disabled")
91
  return (s)
92
 
93
+ def check_inputs(prompt: str, control_image: Image.Image):
94
+ if control_image is None:
95
+ raise gr.Error("Please select or upload an Input Illusion")
96
  if prompt is None or prompt == "":
97
  raise gr.Error("Prompt is required")
98
 
 
199
 
200
  history = show_gallery_history()
201
  prompt.submit(
202
+ check_inputs,
203
+ inputs=[prompt, control_image],
204
  queue=False
205
  ).success(
206
  inference,
 
210
  fn=fetch_gallery_history, inputs=[prompt, result_image], outputs=history, queue=False
211
  )
212
  run_btn.click(
213
+ check_inputs,
214
+ inputs=[prompt, control_image],
215
  queue=False
216
  ).success(
217
  inference,