diffusion-model-framework 0.1.1rc4__tar.gz → 0.1.2rc2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/PKG-INFO +1 -1
- diffusion_model_framework-0.1.2rc2/diffusion_models/__init__.py +1 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/gaussian_diffusion/beta_schedulers.py +20 -7
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/utils/schemas.py +1 -1
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/pyproject.toml +1 -1
- diffusion_model_framework-0.1.1rc4/diffusion_models/__init__.py +0 -1
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/README.md +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/diffusion_inference.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/diffusion_trainer.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/gaussian_diffusion/__init__.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/gaussian_diffusion/base_diffuser.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/gaussian_diffusion/gaussian_diffuser.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/models/SimpleUnet.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/models/__init__.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/models/base_diffusion_model.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/utils/__init__.py +0 -0
- {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/utils/tensorboard.py +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
__version__ = "0.1.2-rc.2"
|
|
@@ -6,7 +6,11 @@ import torch
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
class BaseBetaScheduler:
|
|
9
|
-
def __init__(self,
|
|
9
|
+
def __init__(self,
|
|
10
|
+
steps: int,
|
|
11
|
+
enforce_zero_terminal_snr: bool = False,
|
|
12
|
+
initialize: bool = True,
|
|
13
|
+
):
|
|
10
14
|
"""Initializes a beta scheduler.
|
|
11
15
|
|
|
12
16
|
BaseBetaScheduler is an abstract base class for different beta scheduler
|
|
@@ -19,22 +23,31 @@ class BaseBetaScheduler:
|
|
|
19
23
|
with `"Common Diffusion Noise Schedules and Sample Steps are Flawed"
|
|
20
24
|
<https://arxiv.org/abs/2305.08891>`_.\n
|
|
21
25
|
Defaults to ``False``.
|
|
26
|
+
initialize: Whether to initialize the beta scheduler. If this is
|
|
27
|
+
set to ``False``, you will need to manually set ``self.betas`` and
|
|
28
|
+
``self.alpha_bars``. Otherwise, they are initialized using your
|
|
29
|
+
``sample_betas`` and ``compute_alpha_bar`` methods.
|
|
22
30
|
|
|
23
31
|
Warnings:
|
|
24
32
|
Do not instantiate this class directly. Instead, build your own Beta
|
|
25
33
|
scheduler by inheriting from BaseBetaScheduler.
|
|
26
34
|
(see :class:`~.LinearBetaScheduler`)
|
|
27
35
|
"""
|
|
28
|
-
super().__init__()
|
|
29
36
|
self.steps: int = steps
|
|
30
37
|
"""The number of steps for the beta scheduler."""
|
|
31
|
-
self.betas =
|
|
38
|
+
self.betas = None
|
|
32
39
|
"""The :math:`\\beta` computed according to :meth:`~.BaseBetaScheduler.sample_betas`."""
|
|
33
|
-
self.alpha_bars =
|
|
40
|
+
self.alpha_bars = None
|
|
34
41
|
"""The :math:`\\bar{\\alpha}` computed according to :meth:`~.BaseBetaScheduler.compute_alpha_bar`."""
|
|
35
42
|
|
|
36
|
-
if
|
|
37
|
-
self.
|
|
43
|
+
if initialize:
|
|
44
|
+
self._initialize()
|
|
45
|
+
if enforce_zero_terminal_snr:
|
|
46
|
+
self.enforce_zero_terminal_snr()
|
|
47
|
+
|
|
48
|
+
def _initialize(self):
|
|
49
|
+
self.betas = self.sample_betas()
|
|
50
|
+
self.alpha_bars = self.compute_alpha_bar()
|
|
38
51
|
|
|
39
52
|
def enforce_zero_terminal_snr(self):
|
|
40
53
|
"""Enforce terminal SNR by adjusting :math:`\\beta` and :math:`\\bar{\\alpha}`.
|
|
@@ -120,7 +133,7 @@ class BaseBetaScheduler:
|
|
|
120
133
|
Returns:
|
|
121
134
|
|
|
122
135
|
"""
|
|
123
|
-
generic_beta_scheduler = cls(
|
|
136
|
+
generic_beta_scheduler = cls(steps, initialize=False)
|
|
124
137
|
generic_beta_scheduler.steps = steps
|
|
125
138
|
generic_beta_scheduler.betas = betas
|
|
126
139
|
generic_beta_scheduler.alpha_bars = alpha_bars
|
|
@@ -92,7 +92,7 @@ class Checkpoint:
|
|
|
92
92
|
Returns:
|
|
93
93
|
A checkpoint instance.
|
|
94
94
|
"""
|
|
95
|
-
checkpoint = torch.load(f=file_path)
|
|
95
|
+
checkpoint = torch.load(f=file_path, weights_only=True)
|
|
96
96
|
checkpoint = cls(**checkpoint)
|
|
97
97
|
beta_scheduler_config = BetaSchedulerConfiguration(
|
|
98
98
|
**checkpoint.beta_scheduler_config
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
__version__ = "0.1.1-rc.4"
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|