clementchadebec
commited on
Commit
•
1ef3995
1
Parent(s):
7ea18b4
Update app.py
Browse files
app.py
CHANGED
@@ -8,17 +8,11 @@ from diffusers import StableDiffusion3Pipeline, SD3Transformer2DModel, FlashFlow
|
|
8 |
from peft import PeftModel
|
9 |
import os
|
10 |
from huggingface_hub import snapshot_download
|
|
|
11 |
|
12 |
huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
|
13 |
|
14 |
-
model_path =
|
15 |
-
repo_id="stabilityai/stable-diffusion-3-medium",
|
16 |
-
revision="refs/pr/26",
|
17 |
-
repo_type="model",
|
18 |
-
ignore_patterns=["*.md", "*..gitattributes"],
|
19 |
-
local_dir="stable-diffusion-3-medium",
|
20 |
-
token=huggingface_token, # type a new token-id.
|
21 |
-
)
|
22 |
|
23 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
24 |
IS_SPACE = os.environ.get("SPACE_ID", None) is not None
|
@@ -27,6 +21,7 @@ transformer = SD3Transformer2DModel.from_pretrained(
|
|
27 |
model_path,
|
28 |
subfolder="transformer",
|
29 |
torch_dtype=torch.float16,
|
|
|
30 |
)
|
31 |
transformer = PeftModel.from_pretrained(transformer, "jasperai/flash-sd3")
|
32 |
|
@@ -38,7 +33,8 @@ if torch.cuda.is_available():
|
|
38 |
transformer=transformer,
|
39 |
torch_dtype=torch.float16,
|
40 |
text_encoder_3=None,
|
41 |
-
tokenizer_3=None
|
|
|
42 |
)
|
43 |
|
44 |
pipe = pipe.to(device)
|
@@ -48,7 +44,8 @@ else:
|
|
48 |
transformer=transformer,
|
49 |
torch_dtype=torch.float16,
|
50 |
text_encoder_3=None,
|
51 |
-
tokenizer_3=None
|
|
|
52 |
)
|
53 |
pipe = pipe.to(device)
|
54 |
|
|
|
8 |
from peft import PeftModel
|
9 |
import os
|
10 |
from huggingface_hub import snapshot_download
|
11 |
+
auth_token = os.environ.get("TOKEN_FROM_SECRET") or True
|
12 |
|
13 |
huggingface_token = os.getenv("HUGGINGFACE_TOKEN")
|
14 |
|
15 |
+
model_path = "stabilityai/stable-diffusion-3-medium-diffusers"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
18 |
IS_SPACE = os.environ.get("SPACE_ID", None) is not None
|
|
|
21 |
model_path,
|
22 |
subfolder="transformer",
|
23 |
torch_dtype=torch.float16,
|
24 |
+
use_auth_token=auth_token
|
25 |
)
|
26 |
transformer = PeftModel.from_pretrained(transformer, "jasperai/flash-sd3")
|
27 |
|
|
|
33 |
transformer=transformer,
|
34 |
torch_dtype=torch.float16,
|
35 |
text_encoder_3=None,
|
36 |
+
tokenizer_3=None,
|
37 |
+
use_auth_token=auth_token
|
38 |
)
|
39 |
|
40 |
pipe = pipe.to(device)
|
|
|
44 |
transformer=transformer,
|
45 |
torch_dtype=torch.float16,
|
46 |
text_encoder_3=None,
|
47 |
+
tokenizer_3=None,
|
48 |
+
use_auth_token=auth_token
|
49 |
)
|
50 |
pipe = pipe.to(device)
|
51 |
|