echarlaix HF staff commited on
Commit
b2ba25d
1 Parent(s): 9691ef5

Reduce generated image height width

Browse files
Files changed (1) hide show
  1. app.py +3 -6
app.py CHANGED
@@ -13,7 +13,7 @@ def create_pipeline(name):
13
  pipe.safety_checker = lambda images, clip_input: (images, False)
14
  else:
15
  pipe = OVStableDiffusionPipeline.from_pretrained(name, compile=False)
16
- pipe.reshape(batch_size=1, height=512, width=512, num_images_per_prompt=1)
17
  pipe.compile()
18
  return pipe
19
 
@@ -33,10 +33,7 @@ def generate(prompt, option, seed):
33
  pipe = create_pipeline(pipes[option])
34
  set_seed(int(seed))
35
  start_time = time.time()
36
- if "Torch" in option:
37
- output = pipe(prompt, num_inference_steps=50, output_type="pil", height=512, width=512)
38
- else:
39
- output = pipe(prompt, num_inference_steps=50, output_type="pil")
40
  elapsed_time = time.time() - start_time
41
  return (output.images[0], "{:10.4f}".format(elapsed_time))
42
 
@@ -57,4 +54,4 @@ gr.Interface(
57
  description="This is the Optimum-based demo for NNCF-optimized Stable Diffusion pipeline trained on 'lambdalabs/pokemon-blip-captions' dataset and running with OpenVINO.\n"
58
  "The pipeline is run using 8 vCPUs (4 cores) only.",
59
  theme="huggingface",
60
- ).launch()
 
13
  pipe.safety_checker = lambda images, clip_input: (images, False)
14
  else:
15
  pipe = OVStableDiffusionPipeline.from_pretrained(name, compile=False)
16
+ pipe.reshape(batch_size=1, height=256, width=256, num_images_per_prompt=1)
17
  pipe.compile()
18
  return pipe
19
 
 
33
  pipe = create_pipeline(pipes[option])
34
  set_seed(int(seed))
35
  start_time = time.time()
36
+ output = pipe(prompt, num_inference_steps=50, output_type="pil", height=256, width=256)
 
 
 
37
  elapsed_time = time.time() - start_time
38
  return (output.images[0], "{:10.4f}".format(elapsed_time))
39
 
 
54
  description="This is the Optimum-based demo for NNCF-optimized Stable Diffusion pipeline trained on 'lambdalabs/pokemon-blip-captions' dataset and running with OpenVINO.\n"
55
  "The pipeline is run using 8 vCPUs (4 cores) only.",
56
  theme="huggingface",
57
+ ).launch()