eienmojiki commited on
Commit
cda58a2
·
verified ·
1 Parent(s): 2142d2a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +11 -10
app.py CHANGED
@@ -62,16 +62,17 @@ def get_scheduler(scheduler_config: Dict, name: str) -> Optional[Callable]:
62
  return scheduler_factory_map.get(name, lambda: None)()
63
 
64
  def load_pipeline(model_name):
65
- pipe = StableDiffusionXLPipeline.from_pretrained(
66
- model_name,
67
- torch_dtype=torch.float16,
68
- custom_pipeline="lpw_stable_diffusion_xl",
69
- safety_checker = None,
70
- use_safetensors=True,
71
- add_watermarker=False,
72
- use_auth_token=HF_TOKEN,
73
- )
74
- pipe.to(device)
 
75
  return pipe
76
 
77
  @spaces.GPU
 
62
  return scheduler_factory_map.get(name, lambda: None)()
63
 
64
  def load_pipeline(model_name):
65
+ if torch.cuda.is_available():
66
+ pipe = StableDiffusionXLPipeline.from_pretrained(
67
+ model_name,
68
+ torch_dtype=torch.float16,
69
+ custom_pipeline="lpw_stable_diffusion_xl",
70
+ safety_checker = None,
71
+ use_safetensors=True,
72
+ add_watermarker=False,
73
+ use_auth_token=HF_TOKEN
74
+ )
75
+ pipe.to("cuda:0")
76
  return pipe
77
 
78
  @spaces.GPU