multimodalart HF staff commited on
Commit
09f0b4e
1 Parent(s): e2a7cad

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -21
app.py CHANGED
@@ -57,19 +57,13 @@ pipe_hyper.to("cuda")
57
  del unet
58
 
59
  @spaces.GPU
60
- def run_comparison_turbo(prompt, progress=gr.Progress(track_tqdm=True)):
61
  image_turbo=pipe_turbo(prompt=prompt, num_inference_steps=1, guidance_scale=0).images[0]
62
- return image_turbo
63
-
64
- @spaces.GPU
65
- def run_comparison_lightning(prompt, progress=gr.Progress(track_tqdm=True)):
66
  image_lightning=pipe_lightning(prompt=prompt, num_inference_steps=1, guidance_scale=0).images[0]
67
- return image_lightning
68
-
69
- @spaces.GPU
70
- def run_comparison_hyper(prompt, progress=gr.Progress(track_tqdm=True)):
71
  image_hyper=pipe_hyper(prompt=prompt, num_inference_steps=1, guidance_scale=0, timesteps=[800]).images[0]
72
- return image_hyper
73
 
74
  examples = ["A dignified beaver wearing glasses, a vest, and colorful neck tie.",
75
  "The spirit of a tamagotchi wandering in the city of Barcelona",
@@ -98,22 +92,16 @@ with gr.Blocks() as demo:
98
  image_outputs = [image_turbo, image_lightning, image_hyper]
99
  gr.on(
100
  triggers=[prompt.submit, run.click],
101
- fn=run_comparison_turbo,
102
- inputs=prompt,
103
- outputs=image_turbo
104
- ).then(
105
- fn=run_comparison_lightning,
106
- inputs=prompt,
107
- outputs=image_lightning
108
- ).then(
109
- fn=run_comparison_hyper,
110
  inputs=prompt,
111
- outputs=image_hyper
112
  )
113
  gr.Examples(
114
  examples=examples,
 
115
  inputs=prompt,
116
  outputs=image_outputs,
117
- cache_examples=False
 
118
  )
119
  demo.launch()
 
57
  del unet
58
 
59
  @spaces.GPU
60
+ def run_comparison(prompt, progress=gr.Progress(track_tqdm=True)):
61
  image_turbo=pipe_turbo(prompt=prompt, num_inference_steps=1, guidance_scale=0).images[0]
62
+ yield image_turbo, None, None
 
 
 
63
  image_lightning=pipe_lightning(prompt=prompt, num_inference_steps=1, guidance_scale=0).images[0]
64
+ yield image_turbo, image_lightning, None
 
 
 
65
  image_hyper=pipe_hyper(prompt=prompt, num_inference_steps=1, guidance_scale=0, timesteps=[800]).images[0]
66
+ return image_turbo, image_lightning, image_hyper
67
 
68
  examples = ["A dignified beaver wearing glasses, a vest, and colorful neck tie.",
69
  "The spirit of a tamagotchi wandering in the city of Barcelona",
 
92
  image_outputs = [image_turbo, image_lightning, image_hyper]
93
  gr.on(
94
  triggers=[prompt.submit, run.click],
95
+ fn=run_comparison,
 
 
 
 
 
 
 
 
96
  inputs=prompt,
97
+ outputs=image_outputs
98
  )
99
  gr.Examples(
100
  examples=examples,
101
+ fn=run_comparison,
102
  inputs=prompt,
103
  outputs=image_outputs,
104
+ cache_examples=False,
105
+ run_on_click=True
106
  )
107
  demo.launch()