|
11 | 11 | AutoencoderKL,
|
12 | 12 | ControlNetModel,
|
13 | 13 | DDIMScheduler,
|
| 14 | + DPMSolverMultistepScheduler, |
| 15 | + LCMScheduler, |
14 | 16 | MotionAdapter,
|
15 | 17 | StableDiffusionPipeline,
|
16 | 18 | UNet2DConditionModel,
|
@@ -361,6 +363,52 @@ def test_free_init(self):
|
361 | 363 | "Disabling of FreeInit should lead to results similar to the default pipeline results",
|
362 | 364 | )
|
363 | 365 |
|
| 366 | + def test_free_init_with_schedulers(self): |
| 367 | + components = self.get_dummy_components() |
| 368 | + pipe: AnimateDiffControlNetPipeline = self.pipeline_class(**components) |
| 369 | + pipe.set_progress_bar_config(disable=None) |
| 370 | + pipe.to(torch_device) |
| 371 | + |
| 372 | + inputs_normal = self.get_dummy_inputs(torch_device) |
| 373 | + frames_normal = pipe(**inputs_normal).frames[0] |
| 374 | + |
| 375 | + schedulers_to_test = [ |
| 376 | + DPMSolverMultistepScheduler.from_config( |
| 377 | + components["scheduler"].config, |
| 378 | + timestep_spacing="linspace", |
| 379 | + beta_schedule="linear", |
| 380 | + algorithm_type="dpmsolver++", |
| 381 | + steps_offset=1, |
| 382 | + clip_sample=False, |
| 383 | + ), |
| 384 | + LCMScheduler.from_config( |
| 385 | + components["scheduler"].config, |
| 386 | + timestep_spacing="linspace", |
| 387 | + beta_schedule="linear", |
| 388 | + steps_offset=1, |
| 389 | + clip_sample=False, |
| 390 | + ), |
| 391 | + ] |
| 392 | + components.pop("scheduler") |
| 393 | + |
| 394 | + for scheduler in schedulers_to_test: |
| 395 | + components["scheduler"] = scheduler |
| 396 | + pipe: AnimateDiffControlNetPipeline = self.pipeline_class(**components) |
| 397 | + pipe.set_progress_bar_config(disable=None) |
| 398 | + pipe.to(torch_device) |
| 399 | + |
| 400 | + pipe.enable_free_init(num_iters=2, use_fast_sampling=False) |
| 401 | + |
| 402 | + inputs = self.get_dummy_inputs(torch_device) |
| 403 | + frames_enable_free_init = pipe(**inputs).frames[0] |
| 404 | + sum_enabled = np.abs(to_np(frames_normal) - to_np(frames_enable_free_init)).sum() |
| 405 | + |
| 406 | + self.assertGreater( |
| 407 | + sum_enabled, |
| 408 | + 1e1, |
| 409 | + "Enabling of FreeInit should lead to results different from the default pipeline results", |
| 410 | + ) |
| 411 | + |
364 | 412 | def test_vae_slicing(self, video_count=2):
|
365 | 413 | device = "cpu" # ensure determinism for the device-dependent torch.Generator
|
366 | 414 | components = self.get_dummy_components()
|
|
0 commit comments