Spaces:
Runtime error
Runtime error
Commit
·
bb38282
1
Parent(s):
7786a61
Update app.py
Browse files
app.py
CHANGED
@@ -1,9 +1,13 @@
|
|
|
|
1 |
import gradio as gr
|
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():
|
|
|
|
|
|
|
7 |
|
8 |
|
9 |
import torch, logging
|
@@ -20,7 +24,7 @@ model_id = "CompVis/stable-diffusion-v1-4"
|
|
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):
|
|
|
1 |
+
import os
|
2 |
import gradio as gr
|
3 |
from pathlib import Path
|
4 |
from diffusers import StableDiffusionPipeline
|
5 |
from PIL import Image
|
6 |
from huggingface_hub import notebook_login
|
7 |
+
#if not (Path.home()/'.huggingface'/'token').exists():
|
8 |
+
|
9 |
+
|
10 |
+
token = os.environ.get("HUGGING_FACE_HUB_TOKEN")
|
11 |
|
12 |
|
13 |
import torch, logging
|
|
|
24 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
25 |
context = autocast if device == "cuda" else nullcontext
|
26 |
|
27 |
+
pipe = StableDiffusionPipeline.from_pretrained(model_id, revision="fp16",torch_dtype=torch.float16,use_auth_toke=token).to(device)
|
28 |
|
29 |
|
30 |
def infer(prompt,samples):
|