Skip to content

Commit 35e9209

Browse files
authored
Fix formula for noise levels in Karras scheduler and tests (#627)
fix formula for noise levels in karras scheduler and tests
1 parent d0aa899 commit 35e9209

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/diffusers/schedulers/scheduling_karras_ve.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ def set_timesteps(self, num_inference_steps: int):
110110
self.timesteps = np.arange(0, self.num_inference_steps)[::-1].copy()
111111
self.schedule = [
112112
(
113-
self.config.sigma_max
113+
self.config.sigma_max**2
114114
* (self.config.sigma_min**2 / self.config.sigma_max**2) ** (i / (num_inference_steps - 1))
115115
)
116116
for i in self.timesteps

src/diffusers/schedulers/scheduling_karras_ve_flax.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ def set_timesteps(self, state: KarrasVeSchedulerState, num_inference_steps: int)
113113
timesteps = jnp.arange(0, num_inference_steps)[::-1].copy()
114114
schedule = [
115115
(
116-
self.config.sigma_max
116+
self.config.sigma_max**2
117117
* (self.config.sigma_min**2 / self.config.sigma_max**2) ** (i / (num_inference_steps - 1))
118118
)
119119
for i in timesteps

tests/test_pipelines.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1104,7 +1104,7 @@ def test_karras_ve_pipeline(self):
11041104

11051105
image_slice = image[0, -3:, -3:, -1]
11061106
assert image.shape == (1, 256, 256, 3)
1107-
expected_slice = np.array([0.26815, 0.1581, 0.2658, 0.23248, 0.1550, 0.2539, 0.1131, 0.1024, 0.0837])
1107+
expected_slice = np.array([0.578, 0.5811, 0.5924, 0.5809, 0.587, 0.5886, 0.5861, 0.5802, 0.586])
11081108
assert np.abs(image_slice.flatten() - expected_slice).max() < 1e-2
11091109

11101110
@slow

0 commit comments

Comments
 (0)