Spaces:
Runtime error
Runtime error
Commit
·
7786a61
1
Parent(s):
39e9e02
Update app.py
Browse files
app.py
CHANGED
@@ -2,6 +2,8 @@ import gradio as gr
|
|
2 |
from pathlib import Path
|
3 |
from diffusers import StableDiffusionPipeline
|
4 |
from PIL import Image
|
|
|
|
|
5 |
|
6 |
|
7 |
import torch, logging
|
@@ -18,7 +20,7 @@ model_id = "CompVis/stable-diffusion-v1-4"
|
|
18 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
19 |
context = autocast if device == "cuda" else nullcontext
|
20 |
|
21 |
-
pipe = StableDiffusionPipeline.from_pretrained(model_id, revision="fp16",torch_dtype=torch.float16
|
22 |
|
23 |
|
24 |
def infer(prompt,samples):
|
|
|
2 |
from pathlib import Path
|
3 |
from diffusers import StableDiffusionPipeline
|
4 |
from PIL import Image
|
5 |
+
from huggingface_hub import notebook_login
|
6 |
+
if not (Path.home()/'.huggingface'/'token').exists(): notebook_login()
|
7 |
|
8 |
|
9 |
import torch, logging
|
|
|
20 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
21 |
context = autocast if device == "cuda" else nullcontext
|
22 |
|
23 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, revision="fp16",torch_dtype=torch.float16).to(device)
|
24 |
|
25 |
|
26 |
def infer(prompt,samples):
|