Unverified Commit 1bc0d37f authored by Jinay Jain's avatar Jinay Jain Committed by GitHub
Browse files

[bug] Fix float/int guidance scale not working in `StableVideoDiffusionPipeline` (#7143)



* [bug] Fix float/int guidance scale not working in `StableVideoDiffusionPipeline`

* Add test to disable CFG on SVD

---------
Co-authored-by: default avatarSayak Paul <spsayakpaul@gmail.com>
parent eb942b86
...@@ -322,7 +322,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline): ...@@ -322,7 +322,7 @@ class StableVideoDiffusionPipeline(DiffusionPipeline):
@property @property
def do_classifier_free_guidance(self): def do_classifier_free_guidance(self):
if isinstance(self.guidance_scale, (int, float)): if isinstance(self.guidance_scale, (int, float)):
return self.guidance_scale return self.guidance_scale > 1
return self.guidance_scale.max() > 1 return self.guidance_scale.max() > 1
@property @property
......
...@@ -496,6 +496,22 @@ class StableVideoDiffusionPipelineFastTests(PipelineTesterMixin, unittest.TestCa ...@@ -496,6 +496,22 @@ class StableVideoDiffusionPipelineFastTests(PipelineTesterMixin, unittest.TestCa
max_diff = np.abs(to_np(output_with_offload) - to_np(output_without_offload)).max() max_diff = np.abs(to_np(output_with_offload) - to_np(output_without_offload)).max()
self.assertLess(max_diff, expected_max_diff, "XFormers attention should not affect the inference results") self.assertLess(max_diff, expected_max_diff, "XFormers attention should not affect the inference results")
def test_disable_cfg(self):
components = self.get_dummy_components()
pipe = self.pipeline_class(**components)
for component in pipe.components.values():
if hasattr(component, "set_default_attn_processor"):
component.set_default_attn_processor()
pipe.to(torch_device)
pipe.set_progress_bar_config(disable=None)
generator_device = "cpu"
inputs = self.get_dummy_inputs(generator_device)
inputs["max_guidance_scale"] = 1.0
output = pipe(**inputs).frames
self.assertEqual(len(output.shape), 5)
@slow @slow
@require_torch_gpu @require_torch_gpu
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment