Spaces:
Running
on
Zero
Running
on
Zero
AlekseyCalvin
commited on
Commit
•
c4064b3
1
Parent(s):
595ba94
Update app.py
Browse files
app.py
CHANGED
@@ -4,18 +4,36 @@ import logging
|
|
4 |
import torch
|
5 |
from PIL import Image
|
6 |
import spaces
|
7 |
-
from diffusers import DiffusionPipeline
|
8 |
from diffusers import StableDiffusion3Pipeline # pip install diffusers>=0.31.0
|
9 |
import copy
|
10 |
import random
|
11 |
import time
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
# Load LoRAs from JSON file
|
14 |
with open('loras.json', 'r') as f:
|
15 |
loras = json.load(f)
|
16 |
-
|
17 |
# Initialize the base model
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
MAX_SEED = 2**32-1
|
21 |
|
@@ -71,7 +89,7 @@ def infer(prompt, negative_prompt, trigger_word, steps, seed, cfg_scale, width,
|
|
71 |
width=width,
|
72 |
height=height,
|
73 |
generator=generator,
|
74 |
-
|
75 |
).images[0]
|
76 |
return image
|
77 |
|
|
|
4 |
import torch
|
5 |
from PIL import Image
|
6 |
import spaces
|
7 |
+
from diffusers import DiffusionPipeline, AutoPipelineForText2Image
|
8 |
from diffusers import StableDiffusion3Pipeline # pip install diffusers>=0.31.0
|
9 |
import copy
|
10 |
import random
|
11 |
import time
|
12 |
+
from huggingface_hub import login
|
13 |
+
hf_token = os.environ.get("HF_TOKEN")
|
14 |
+
login(token=hf_token)
|
15 |
+
|
16 |
+
torch.set_float32_matmul_precision("high")
|
17 |
+
|
18 |
+
torch._inductor.config.conv_1x1_as_mm = True
|
19 |
+
torch._inductor.config.coordinate_descent_tuning = True
|
20 |
+
torch._inductor.config.epilogue_fusion = False
|
21 |
+
torch._inductor.config.coordinate_descent_check_all_directions = True
|
22 |
+
|
23 |
|
24 |
# Load LoRAs from JSON file
|
25 |
with open('loras.json', 'r') as f:
|
26 |
loras = json.load(f)
|
27 |
+
|
28 |
# Initialize the base model
|
29 |
+
base_model = "stabilityai/stable-diffusion-3.5-large"
|
30 |
+
pipe = AutoPipelineForText2Image.from_pretrained("stabilityai/stable-diffusion-3.5-large", torch_dtype=torch.bfloat16)
|
31 |
+
|
32 |
+
pipe.transformer.to(memory_format=torch.channels_last)
|
33 |
+
pipe.vae.to(memory_format=torch.channels_last)
|
34 |
+
|
35 |
+
pipe.transformer = torch.compile(pipe.transformer, mode="max-autotune", fullgraph=True)
|
36 |
+
pipe.vae.decode = torch.compile(pipe.vae.decode, mode="max-autotune", fullgraph=True)
|
37 |
|
38 |
MAX_SEED = 2**32-1
|
39 |
|
|
|
89 |
width=width,
|
90 |
height=height,
|
91 |
generator=generator,
|
92 |
+
joint_attention_kwargs={"scale": lora_scale},
|
93 |
).images[0]
|
94 |
return image
|
95 |
|