depth_fm.flow.noise¶
noise ¶
DepthFM noise utilities — shared between training and inference.
Copied verbatim from depth-fm/depthfm/dfm.py so that both codepaths are provably identical to the reference implementation.
cosine_alpha_bar ¶
q_sample ¶
q_sample(x_start: Tensor, t: int, noise: Tensor = None, n_diffusion_timesteps: int = 1000) -> torch.Tensor
Diffuse x_start for t steps: sample from q(x_t | x_0).
Matches dfm.py exactly: alpha_bar_t = cosine_alpha_bar(t / n_diffusion_timesteps) return sqrt(alpha_bar_t)x_start + sqrt(1-alpha_bar_t)noise
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x_start
|
Tensor
|
latent to noise, shape (B, C, H, W). |
required |
t
|
int
|
integer diffusion step (e.g. model.noising_step = 400). |
required |
noise
|
Tensor
|
optional pre-drawn noise; drawn fresh if None. |
None
|
n_diffusion_timesteps
|
int
|
total diffusion steps (default 1000). |
1000
|
Returns:
| Type | Description |
|---|---|
Tensor
|
Noised latent, same shape as x_start. |
Source code in src/depth_fm/flow/noise.py
per_sample_min_max_normalization ¶
Normalize each sample in a batch independently to [0, 1].
Matches dfm.py exactly.