AlexKoff88 commited on
Commit
84f01b7
·
1 Parent(s): e9ba573
Files changed (1) hide show
  1. app.py +6 -3
app.py CHANGED
@@ -32,7 +32,10 @@ def generate(prompt, option, seed):
32
  pipe = pipes[option]
33
  set_seed(int(seed))
34
  start_time = time.time()
35
- output = pipe(prompt, num_inference_steps=50, output_type="pil", height=512, width=512)
 
 
 
36
  elapsed_time = time.time() - start_time
37
  return (output.images[0], "{:10.4f}".format(elapsed_time))
38
 
@@ -44,9 +47,9 @@ model_options = [option for option in pipes.keys()]
44
 
45
  gr.Interface(
46
  fn=generate,
47
- inputs=[gr.inputs.Textbox(placeholder="cartoon bird", label="Prompt", lines=1),
48
  gr.inputs.Dropdown(choices=model_options, default=model_options[-1], label="Model version"),
49
- gr.inputs.Textbox(placeholder="42", label="Seed", lines=1)
50
  ],
51
  outputs=[gr.outputs.Image(type="pil", label="Generated Image"), gr.outputs.Textbox(label="Inference time")],
52
  title="OpenVINO-optimized Stable Diffusion",
 
32
  pipe = pipes[option]
33
  set_seed(int(seed))
34
  start_time = time.time()
35
+ if "Torch" in option:
36
+ output = pipe(prompt, num_inference_steps=50, output_type="pil", height=512, width=512)
37
+ else:
38
+ output = pipe(prompt, num_inference_steps=50, output_type="pil")
39
  elapsed_time = time.time() - start_time
40
  return (output.images[0], "{:10.4f}".format(elapsed_time))
41
 
 
47
 
48
  gr.Interface(
49
  fn=generate,
50
+ inputs=[gr.inputs.Textbox(default="cartoon bird", label="Prompt", lines=1),
51
  gr.inputs.Dropdown(choices=model_options, default=model_options[-1], label="Model version"),
52
+ gr.inputs.Textbox(default="42", label="Seed", lines=1)
53
  ],
54
  outputs=[gr.outputs.Image(type="pil", label="Generated Image"), gr.outputs.Textbox(label="Inference time")],
55
  title="OpenVINO-optimized Stable Diffusion",