eolecvk commited on
Commit
636067d
·
1 Parent(s): 6cd0a45

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -3
app.py CHANGED
@@ -2,17 +2,24 @@ from contextlib import nullcontext
2
  import gradio as gr
3
  import torch
4
  from torch import autocast
5
- from diffusers import StableDiffusionPipeline
6
 
7
 
8
  device = "cuda" if torch.cuda.is_available() else "cpu"
9
  context = autocast if device == "cuda" else nullcontext
10
  dtype = torch.float16 if device == "cuda" else torch.float32
11
 
12
- pipe = StableDiffusionPipeline.from_pretrained("lambdalabs/sd-naruto-diffusers", torch_dtype=dtype)
 
 
 
 
 
 
 
 
13
  pipe = pipe.to(device)
14
 
15
-
16
  # Sometimes the nsfw checker is confused by the Naruto images, you can disable
17
  # it at your own risk here
18
  disable_safety = True
 
2
  import gradio as gr
3
  import torch
4
  from torch import autocast
5
+ from diffusers import StableDiffusionPipeline, StableDiffusionOnnxPipeline
6
 
7
 
8
  device = "cuda" if torch.cuda.is_available() else "cpu"
9
  context = autocast if device == "cuda" else nullcontext
10
  dtype = torch.float16 if device == "cuda" else torch.float32
11
 
12
+ if device == "cuda":
13
+ pipe = StableDiffusionPipeline.from_pretrained("lambdalabs/sd-naruto-diffusers", torch_dtype=dtype)
14
+
15
+ else:
16
+ pipe = StableDiffusionOnnxPipeline.from_pretrained(
17
+ "lambdalabs/sd-naruto-diffusers",
18
+ revision="onnx",
19
+ provider="CPUExecutionProvider"
20
+ )
21
  pipe = pipe.to(device)
22
 
 
23
  # Sometimes the nsfw checker is confused by the Naruto images, you can disable
24
  # it at your own risk here
25
  disable_safety = True