multimodalart HF staff commited on
Commit
003a39a
1 Parent(s): fad334a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -13
app.py CHANGED
@@ -61,20 +61,23 @@ def run_schnell(prompt):
61
  print("Ran!")
62
  return image
63
 
 
64
  def run_parallel_models(prompt):
65
- with ProcessPoolExecutor(max_workers=3) as executor:
66
- future_dev_hyper = executor.submit(run_dev_hyper, prompt)
67
- future_dev_turbo = executor.submit(run_dev_turbo, prompt)
68
- future_schnell = executor.submit(run_schnell, prompt)
69
-
70
- res_dev_hyper = future_dev_hyper.result()
71
- yield res_dev_hyper, gr.update(), gr.update()
72
- res_dev_turbo = future_dev_turbo.result()
73
- yield gr.update(), res_dev_turbo, gr.update()
74
- res_schnell = future_schnell.result()
75
- yield gr.update(), gr.update(), res_dev_turbo
76
-
77
- run_parallel_models.zerogpu = True
 
 
78
 
79
  with gr.Blocks() as demo:
80
  gr.Markdown("# Low Step Flux Comparison")
 
61
  print("Ran!")
62
  return image
63
 
64
+ @spaces.GPU
65
  def run_parallel_models(prompt):
66
+ pipe_dev.to("cuda")
67
+ pipe_dev.load_lora_weights(hyper_lora)
68
+ image = pipe_dev(prompt, num_inference_steps=8, joint_attention_kwargs={"scale": 0.125}).images[0]
69
+ pipe_dev.unload_lora_weights()
70
+ yield image, gr.update(), gr.update()
71
+ pipe_dev.load_lora_weights(turbo_lora)
72
+ image = pipe_dev(prompt, num_inference_steps=8).images[0]
73
+ yield gr.update(), image, gr.update()
74
+ pipe_dev.unload_lora_weights()
75
+ pipe_dev.to("cpu")
76
+ pipe_schnell.to("cuda")
77
+ image = pipe_schnell(prompt, num_inference_steps=4).images[0]
78
+ yield gr.update(), gr.update(), image
79
+
80
+ #run_parallel_models.zerogpu = True
81
 
82
  with gr.Blocks() as demo:
83
  gr.Markdown("# Low Step Flux Comparison")