HelloSun commited on
Commit
c3545bc
·
verified ·
1 Parent(s): 6ca0b0e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -15
app.py CHANGED
@@ -5,20 +5,16 @@ from diffusers import DiffusionPipeline
5
  from optimum.intel.openvino import OVStableDiffusionPipeline
6
  import torch
7
 
8
- device = "cuda" if torch.cuda.is_available() else "cpu"
 
 
 
 
 
9
 
10
- if torch.cuda.is_available():
11
- torch.cuda.max_memory_allocated(device=device)
12
- pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", torch_dtype=torch.float16, variant="fp16", use_safetensors=True)
13
- pipe.enable_xformers_memory_efficient_attention()
14
- pipe = pipe.to(device)
15
- else:
16
- #pipe = DiffusionPipeline.from_pretrained("stabilityai/sdxl-turbo", use_safetensors=True)
17
- pipe = OVStableDiffusionPipeline.from_pretrained("helenai/Linaqruf-anything-v3.0-ov")
18
- pipe = pipe.to(device)
19
 
20
  MAX_SEED = np.iinfo(np.int32).max
21
- MAX_IMAGE_SIZE = 1024
22
 
23
  def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
24
 
@@ -52,10 +48,8 @@ css="""
52
  }
53
  """
54
 
55
- if torch.cuda.is_available():
56
- power_device = "GPU"
57
- else:
58
- power_device = "CPU"
59
 
60
  with gr.Blocks(css=css) as demo:
61
 
 
5
  from optimum.intel.openvino import OVStableDiffusionPipeline
6
  import torch
7
 
8
+ model_id = "helenai/Linaqruf-anything-v3.0-ov"
9
+
10
+ pipe = OVStableDiffusionPipeline.from_pretrained(model_id, compile=False)
11
+ pipe.reshape( batch_size=batch_size, height=height, width=width, num_images_per_prompt=num_images_per_prompt)
12
+ pipe.compile()
13
+
14
 
 
 
 
 
 
 
 
 
 
15
 
16
  MAX_SEED = np.iinfo(np.int32).max
17
+ MAX_IMAGE_SIZE = 256
18
 
19
  def infer(prompt, negative_prompt, seed, randomize_seed, width, height, guidance_scale, num_inference_steps):
20
 
 
48
  }
49
  """
50
 
51
+
52
+ power_device = "CPU"
 
 
53
 
54
  with gr.Blocks(css=css) as demo:
55