Skip to content

Commit 0c8e83f

Browse files
committed
use math instead of numpy
1 parent 1b5fbc0 commit 0c8e83f

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

src/diffusers/schedulers/scheduling_sde_ve.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@
1414

1515
# DISCLAIMER: This file is strongly influenced by https://github.com/yang-song/score_sde_pytorch
1616

17+
import math
1718
import warnings
1819
from dataclasses import dataclass
1920
from typing import Optional, Tuple, Union
2021

21-
import numpy as np
2222
import torch
2323

2424
from ..configuration_utils import ConfigMixin, register_to_config
@@ -120,7 +120,7 @@ def set_sigmas(
120120
self.set_timesteps(num_inference_steps, sampling_eps)
121121

122122
self.sigmas = sigma_min * (sigma_max / sigma_min) ** (self.timesteps / sampling_eps)
123-
self.discrete_sigmas = torch.exp(torch.linspace(np.log(sigma_min), np.log(sigma_max), num_inference_steps))
123+
self.discrete_sigmas = torch.exp(torch.linspace(math.log(sigma_min), math.log(sigma_max), num_inference_steps))
124124
self.sigmas = torch.tensor([sigma_min * (sigma_max / sigma_min) ** t for t in self.timesteps])
125125

126126
def get_adjacent_sigma(self, timesteps, t):

src/diffusers/schedulers/scheduling_sde_vp.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@
1616

1717
# TODO(Patrick, Anton, Suraj) - make scheduler framework independent and clean-up a bit
1818

19-
import numpy as np
19+
import math
20+
2021
import torch
2122

2223
from ..configuration_utils import ConfigMixin, register_to_config
@@ -79,7 +80,7 @@ def step_pred(self, score, x, t, generator=None):
7980

8081
# add noise
8182
noise = torch.randn(x.shape, layout=x.layout, generator=generator).to(x.device)
82-
x = x_mean + diffusion * np.sqrt(-dt) * noise
83+
x = x_mean + diffusion * math.sqrt(-dt) * noise
8384

8485
return x, x_mean
8586

0 commit comments

Comments
 (0)