forked from Eco-Sphere/cache-dit
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_sd_3.5.py
More file actions
46 lines (35 loc) · 921 Bytes
/
run_sd_3.5.py
File metadata and controls
46 lines (35 loc) · 921 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import os
import sys
sys.path.append("..")
import time
import torch
from diffusers import StableDiffusion3Pipeline
from utils import get_args, strify, cachify
import cache_dit
args = get_args()
print(args)
model_id = os.environ.get(
"SD_3_5_DIR",
"stabilityai/stable-diffusion-3.5-large",
)
pipe = StableDiffusion3Pipeline.from_pretrained(
model_id,
torch_dtype=torch.bfloat16,
device_map="balanced",
)
if args.cache:
cachify(args, pipe)
start = time.time()
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
image = pipe(
prompt,
num_inference_steps=50,
generator=torch.Generator(device="cpu").manual_seed(42),
).images[0]
end = time.time()
stats = cache_dit.summary(pipe)
time_cost = end - start
save_path = f"sd_3_5.{strify(args, stats)}.png"
print(f"Time cost: {time_cost:.2f}s")
print(f"Saving image to {save_path}")
image.save(save_path)