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.
Files changed (17) hide show
  1. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/PKG-INFO +1 -1
  2. diffusion_model_framework-0.1.2rc2/diffusion_models/__init__.py +1 -0
  3. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/gaussian_diffusion/beta_schedulers.py +20 -7
  4. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/utils/schemas.py +1 -1
  5. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/pyproject.toml +1 -1
  6. diffusion_model_framework-0.1.1rc4/diffusion_models/__init__.py +0 -1
  7. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/README.md +0 -0
  8. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/diffusion_inference.py +0 -0
  9. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/diffusion_trainer.py +0 -0
  10. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/gaussian_diffusion/__init__.py +0 -0
  11. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/gaussian_diffusion/base_diffuser.py +0 -0
  12. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/gaussian_diffusion/gaussian_diffuser.py +0 -0
  13. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/models/SimpleUnet.py +0 -0
  14. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/models/__init__.py +0 -0
  15. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/models/base_diffusion_model.py +0 -0
  16. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/utils/__init__.py +0 -0
  17. {diffusion_model_framework-0.1.1rc4 → diffusion_model_framework-0.1.2rc2}/diffusion_models/utils/tensorboard.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: diffusion-model-framework
3
- Version: 0.1.1rc4
3
+ Version: 0.1.2rc2
4
4
  Summary:
5
5
  Home-page: https://github.com/sachahu1/Diffusion-Model-Framework
6
6
  Author: Sacha Hu
@@ -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, steps: int, enforce_zero_terminal_snr: bool = False):
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 = self.sample_betas()
38
+ self.betas = None
32
39
  """The :math:`\\beta` computed according to :meth:`~.BaseBetaScheduler.sample_betas`."""
33
- self.alpha_bars = self.compute_alpha_bar()
40
+ self.alpha_bars = None
34
41
  """The :math:`\\bar{\\alpha}` computed according to :meth:`~.BaseBetaScheduler.compute_alpha_bar`."""
35
42
 
36
- if enforce_zero_terminal_snr:
37
- self.enforce_zero_terminal_snr()
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(0)
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,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "diffusion-model-framework"
3
- version = "0.1.1-rc.4"
3
+ version = "0.1.2-rc.2"
4
4
  description = ""
5
5
  authors = ["Sacha Hu <sachahu@mindsparkai.com>"]
6
6
  readme = "README.md"
@@ -1 +0,0 @@
1
- __version__ = "0.1.1-rc.4"