rafaaa2105 commited on
Commit
e247cb3
1 Parent(s): ec7bfbd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -1
app.py CHANGED
@@ -14,7 +14,10 @@ models = {}
14
  for model_name in model_list:
15
  try:
16
  print(f"\n \nLoading {model_name}...")
17
- models[model_name] = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch.float16).to("cuda")
 
 
 
18
  except Exception as e:
19
  print(f"Error loading model {model_name}: {e}")
20
 
@@ -39,6 +42,7 @@ def generate_images(
39
  outputs = []
40
 
41
  for _ in range(num_images):
 
42
  output = pipe(
43
  prompt,
44
  negative_prompt=negative_prompt,
@@ -48,6 +52,8 @@ def generate_images(
48
  width=width
49
  )["images"][0]
50
  outputs.append(output)
 
 
51
 
52
 
53
 
 
14
  for model_name in model_list:
15
  try:
16
  print(f"\n \nLoading {model_name}...")
17
+ pipe = DiffusionPipeline.from_pretrained(model_name, torch_dtype=torch.float16).to("cuda")
18
+ pipe.enable_xformers_memory_efficient_attention()
19
+ pipe.enable_model_cpu_offload()
20
+ models[model_name] = pipe
21
  except Exception as e:
22
  print(f"Error loading model {model_name}: {e}")
23
 
 
42
  outputs = []
43
 
44
  for _ in range(num_images):
45
+ pipe.enable_model_cpu_offload()
46
  output = pipe(
47
  prompt,
48
  negative_prompt=negative_prompt,
 
52
  width=width
53
  )["images"][0]
54
  outputs.append(output)
55
+
56
+
57
 
58
 
59