Commit
·
f83832c
1
Parent(s):
fbcadae
up
Browse files- run_xl_ediffi.py +23 -4
run_xl_ediffi.py
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
-
from diffusers import DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionPipeline, KDPM2DiscreteScheduler, StableDiffusionImg2ImgPipeline, HeunDiscreteScheduler, KDPM2AncestralDiscreteScheduler, DDIMScheduler, HeunDiscreteScheduler, DEISMultistepScheduler
|
| 3 |
from diffusers import DiffusionPipeline
|
| 4 |
import time
|
| 5 |
from pytorch_lightning import seed_everything
|
|
@@ -18,16 +18,35 @@ from torch.nn.functional import fractional_max_pool2d_with_indices
|
|
| 18 |
api = HfApi()
|
| 19 |
start_time = time.time()
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
model_id = "stabilityai/stable-diffusion-xl-base-0.9"
|
| 22 |
pipe_high_noise = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, variant="fp16", use_safetensors=True, local_files_only=True)
|
| 23 |
-
pipe_high_noise.scheduler =
|
|
|
|
| 24 |
pipe_high_noise.to("cuda")
|
| 25 |
|
| 26 |
pipe_low_noise = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
|
| 27 |
-
pipe_low_noise.scheduler =
|
|
|
|
| 28 |
pipe_low_noise.to("cuda")
|
| 29 |
|
| 30 |
-
prompt = "
|
| 31 |
|
| 32 |
num_inference_steps = 40
|
| 33 |
high_noise_frac = 0.8
|
|
|
|
| 1 |
#!/usr/bin/env python3
|
| 2 |
+
from diffusers import DPMSolverMultistepScheduler, DiffusionPipeline, EulerDiscreteScheduler, StableDiffusionPipeline, KDPM2DiscreteScheduler, StableDiffusionImg2ImgPipeline, HeunDiscreteScheduler, KDPM2AncestralDiscreteScheduler, DDIMScheduler, HeunDiscreteScheduler, DEISMultistepScheduler
|
| 3 |
from diffusers import DiffusionPipeline
|
| 4 |
import time
|
| 5 |
from pytorch_lightning import seed_everything
|
|
|
|
| 18 |
api = HfApi()
|
| 19 |
start_time = time.time()
|
| 20 |
|
| 21 |
+
random_generator = torch.Generator()
|
| 22 |
+
random_generator.manual_seed(12345)
|
| 23 |
+
|
| 24 |
+
scheduler = DPMSolverMultistepScheduler(
|
| 25 |
+
beta_start=0.00085,
|
| 26 |
+
beta_end=0.012,
|
| 27 |
+
beta_schedule="scaled_linear",
|
| 28 |
+
prediction_type="epsilon",
|
| 29 |
+
num_train_timesteps=1000,
|
| 30 |
+
trained_betas=None,
|
| 31 |
+
thresholding=False,
|
| 32 |
+
algorithm_type="dpmsolver++",
|
| 33 |
+
solver_type="midpoint",
|
| 34 |
+
lower_order_final=True,
|
| 35 |
+
use_karras_sigmas=True,
|
| 36 |
+
)
|
| 37 |
+
|
| 38 |
model_id = "stabilityai/stable-diffusion-xl-base-0.9"
|
| 39 |
pipe_high_noise = DiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16, variant="fp16", use_safetensors=True, local_files_only=True)
|
| 40 |
+
# pipe_high_noise.scheduler = EulerDiscreteScheduler.from_config(pipe_high_noise.scheduler.config)
|
| 41 |
+
pipe_high_noise.scheduler = scheduler
|
| 42 |
pipe_high_noise.to("cuda")
|
| 43 |
|
| 44 |
pipe_low_noise = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-0.9", torch_dtype=torch.float16, use_safetensors=True, variant="fp16")
|
| 45 |
+
# pipe_low_noise.scheduler = EulerDiscreteScheduler.from_config(pipe_low_noise.scheduler.config)
|
| 46 |
+
pipe_low_noise.scheduler = scheduler
|
| 47 |
pipe_low_noise.to("cuda")
|
| 48 |
|
| 49 |
+
prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k"
|
| 50 |
|
| 51 |
num_inference_steps = 40
|
| 52 |
high_noise_frac = 0.8
|