guardiancc commited on
Commit
e0fa1e4
·
verified ·
1 Parent(s): 639cf35

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import gradio as gr
2
- import spaces
3
  import torch
4
  from diffusers import AutoencoderKL, TCDScheduler
5
  from diffusers.models.model_loading_utils import load_state_dict
@@ -31,11 +30,11 @@ state_dict = load_state_dict(model_file)
31
  model, _, _, _, _ = ControlNetModel_Union._load_pretrained_model(
32
  controlnet_model, state_dict, model_file, "xinsir/controlnet-union-sdxl-1.0"
33
  )
34
- model.to(device="cuda", dtype=torch.float16)
35
 
36
  vae = AutoencoderKL.from_pretrained(
37
  "madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16
38
- ).to("cuda")
39
 
40
  pipe = StableDiffusionXLFillPipeline.from_pretrained(
41
  "SG161222/RealVisXL_V5.0_Lightning",
@@ -43,7 +42,7 @@ pipe = StableDiffusionXLFillPipeline.from_pretrained(
43
  vae=vae,
44
  controlnet=model,
45
  variant="fp16",
46
- ).to("cuda")
47
 
48
  pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
49
 
@@ -53,7 +52,7 @@ prompt = "high quality"
53
  negative_prompt_embeds,
54
  pooled_prompt_embeds,
55
  negative_pooled_prompt_embeds,
56
- ) = pipe.encode_prompt(prompt, "cuda", True)
57
 
58
 
59
 
 
1
  import gradio as gr
 
2
  import torch
3
  from diffusers import AutoencoderKL, TCDScheduler
4
  from diffusers.models.model_loading_utils import load_state_dict
 
30
  model, _, _, _, _ = ControlNetModel_Union._load_pretrained_model(
31
  controlnet_model, state_dict, model_file, "xinsir/controlnet-union-sdxl-1.0"
32
  )
33
+ model.to(device="cpu", dtype=torch.float16)
34
 
35
  vae = AutoencoderKL.from_pretrained(
36
  "madebyollin/sdxl-vae-fp16-fix", torch_dtype=torch.float16
37
+ ).to("cpu")
38
 
39
  pipe = StableDiffusionXLFillPipeline.from_pretrained(
40
  "SG161222/RealVisXL_V5.0_Lightning",
 
42
  vae=vae,
43
  controlnet=model,
44
  variant="fp16",
45
+ ).to("cpu")
46
 
47
  pipe.scheduler = TCDScheduler.from_config(pipe.scheduler.config)
48
 
 
52
  negative_prompt_embeds,
53
  pooled_prompt_embeds,
54
  negative_pooled_prompt_embeds,
55
+ ) = pipe.encode_prompt(prompt, "cpu", True)
56
 
57
 
58