ai-simple-engine-runtime-diffusers 0.0.5__py3-none-any.whl → 0.0.6__py3-none-any.whl

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.
@@ -133,7 +133,11 @@ class DiffusersLatentDiffusionModelExecutor (
133
133
  so we need to transform to [0, 1]. This is
134
134
  specific from the Stable Diffusion.
135
135
  """
136
- image = (image / 2 + 0.5).clamp(0, 1)
136
+ image = self._normalize_image(
137
+ image = image,
138
+ model = model
139
+ )
140
+ # image = (image / 2 + 0.5).clamp(0, 1)
137
141
 
138
142
  return image
139
143
 
@@ -144,4 +148,30 @@ class DiffusersLatentDiffusionModelExecutor (
144
148
  image = image.cpu().permute(0, 2, 3, 1).float().detach().numpy()
145
149
  image = Image(image)
146
150
 
147
- return image
151
+ return image
152
+
153
+ # TODO: Maybe rename to '_normalize_tensor' (?)
154
+ def _normalize_image(
155
+ self,
156
+ image: torch.Tensor,
157
+ model: LoadedModel
158
+ ) -> torch.Tensor:
159
+ """
160
+ *For internal use only*
161
+
162
+ Normalize the `image` provided according to
163
+ the specifications in the information of the
164
+ `model` given.
165
+ """
166
+ minimum, maximum = model.info.tensor_output_spec.value_range
167
+
168
+ if (minimum, maximum) == (-1.0, 1.0):
169
+ image = (image + 1.0) / 2.0
170
+ # Previously:
171
+ # image = (image / 2 + 0.5)
172
+ elif (minimum, maximum) == (0.0, 1.0):
173
+ pass
174
+ else:
175
+ image = (image - minimum) / (maximum - minimum)
176
+
177
+ return image.clamp(0.0, 1.0)
@@ -6,6 +6,9 @@ import torch
6
6
  class TorchNoiseGenerator(
7
7
  NoiseGenerator
8
8
  ):
9
+ """
10
+ Class to generate random noise using `torch`.
11
+ """
9
12
 
10
13
  async def generate(
11
14
  self,
@@ -1,6 +1,7 @@
1
1
  from ai_simple_engine_runtime_diffusers.models.runtime.diffusers_latent_diffusion_model import DiffusersLatentDiffusionModel
2
2
  from ai_simple_engine_runtime_diffusers.models.runtime.utils import get_torch_dtype_for
3
3
  from ai_simple_engine_diffusion.model.info.diffusion_model_info import DiffusionModelInfo
4
+ from ai_simple_engine_diffusion.model.info.tensor_output_spec import TensorOutputSpec
4
5
  from ai_simple_engine_diffusion.scheduler.spec.base import SchedulerSpec
5
6
  from ai_simple_engine.device.base import Device
6
7
  from ai_simple_engine.models.loaders.abstract import ModelLoader
@@ -84,7 +85,11 @@ class LatentDiffusionModelLoader(
84
85
  latent_channels = unet.config.in_channels,
85
86
  vae_scale_factor = 2 ** (len(vae.config.block_out_channels) - 1),
86
87
  # TODO: Make dynamic depending on the 'installed_model'
87
- scheduler = self._default_scheduler(installed_model)
88
+ scheduler = self._default_scheduler(installed_model),
89
+ # TODO: Is this ok (?)
90
+ tensor_output_spec = TensorOutputSpec(
91
+ value_range = (-1.0, 1.0)
92
+ )
88
93
  )
89
94
 
90
95
  return LoadedModel(
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: ai-simple-engine-runtime-diffusers
3
- Version: 0.0.5
3
+ Version: 0.0.6
4
4
  Summary: AI Simple Engine Runtime Diffusers Module
5
5
  License-File: LICENSE
6
6
  Author: danialcala94
@@ -11,7 +11,7 @@ Classifier: Programming Language :: Python :: 3.10
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Requires-Dist: ai-simple-engine (>=0.2.9,<1.0.0)
13
13
  Requires-Dist: ai-simple-engine-common (>=0.0.3,<1.0.0)
14
- Requires-Dist: ai-simple-engine-diffusion (>=0.0.6,<1.0.0)
14
+ Requires-Dist: ai-simple-engine-diffusion (>=0.0.8,<1.0.0)
15
15
  Requires-Dist: diffusers (>=0.38.0,<9999.0.0)
16
16
  Requires-Dist: transformers (>=5.13.0,<9999.0.0)
17
17
  Description-Content-Type: text/markdown
@@ -1,16 +1,16 @@
1
1
  ai_simple_engine_runtime_diffusers/__init__.py,sha256=oeCwDniRRNaeu1i8oSoIGl24B_le57R-tjJfbQIcaTA,101
2
2
  ai_simple_engine_runtime_diffusers/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
3
3
  ai_simple_engine_runtime_diffusers/models/executor/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
4
- ai_simple_engine_runtime_diffusers/models/executor/diffusers_latent_diffusion_model_executor.py,sha256=uVLV25sRbEyZsKnxgrv4V2jhOQQ9scBRebGX72P0WN8,4565
4
+ ai_simple_engine_runtime_diffusers/models/executor/diffusers_latent_diffusion_model_executor.py,sha256=ublq2CEj20YLjHZVIAhrPcCNOwGNJl26Tv2Y9lgse_Y,5458
5
5
  ai_simple_engine_runtime_diffusers/models/executor/noise/__init__.py,sha256=gtBak1TwMesgIsuc56HdYmCwrTjdysO68FO6XzAs-ME,69
6
- ai_simple_engine_runtime_diffusers/models/executor/noise/pytorch_noise_generator.py,sha256=_STOBSFRFydmU8Jat_dtnHI99ImUz7Fxio1R0_5UXmM,514
6
+ ai_simple_engine_runtime_diffusers/models/executor/noise/pytorch_noise_generator.py,sha256=hwEdnPua6jMWnFiNlrnodsMJhAOihN3A-_62RGWUdhM,583
7
7
  ai_simple_engine_runtime_diffusers/models/executor/prompt_embeddings/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  ai_simple_engine_runtime_diffusers/models/executor/prompt_embeddings/prompt_embeddings.py,sha256=Y-Krd8UkaaZofSTZoY3Iq1lYetNBBfa_x8ivkplrpBA,321
9
9
  ai_simple_engine_runtime_diffusers/models/executor/text_encoder_model_executor_abstract.py,sha256=DdGE73KVvPZOjD1ulk3ffBC3RjAx4MIf9vcsyatgUyE,805
10
10
  ai_simple_engine_runtime_diffusers/models/executor/unet_model_executor_abstract.py,sha256=xj5Fw8J1jAwJZRoE5dEnH4Ewf92jIyEh6BJEOHOY1n0,1004
11
11
  ai_simple_engine_runtime_diffusers/models/executor/vae_model_executor_abstract.py,sha256=t3j4jYHKbo7bSjMhLLOJYsY2IZm7uQGXXK-c7QDCTv8,1045
12
12
  ai_simple_engine_runtime_diffusers/models/loader/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
13
- ai_simple_engine_runtime_diffusers/models/loader/latent_diffusion_model_loader.py,sha256=C-vENcRTMk9__Es_TdP38j3avsqK2olIFtXXmC_Tcao,3645
13
+ ai_simple_engine_runtime_diffusers/models/loader/latent_diffusion_model_loader.py,sha256=euhlOFfivrkPFkLmjX8uwHvZ2v6L5S2TAayrCykWRoY,3879
14
14
  ai_simple_engine_runtime_diffusers/models/runtime/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
15
15
  ai_simple_engine_runtime_diffusers/models/runtime/diffusers_latent_diffusion_model.py,sha256=UTgR2mWW3rDtJXyRATpR_lfcWS6wMugeKHlvKneXTbw,478
16
16
  ai_simple_engine_runtime_diffusers/models/runtime/utils.py,sha256=niSrKW6RdZwtRPQVEFCArTyYdGgWWk-rlFSd2ledSPo,347
@@ -20,7 +20,7 @@ ai_simple_engine_runtime_diffusers/models/scheduler/registry/__init__.py,sha256=
20
20
  ai_simple_engine_runtime_diffusers/models/scheduler/registry/diffusers_scheduler_registry.py,sha256=FOuIAAwNmi3_jB25ICOlCPbD7U1WlOcGFZT3rhql5cY,565
21
21
  ai_simple_engine_runtime_diffusers/models/scheduler/utils.py,sha256=tIzwp7fy0Y1pE7XcLJU0dEp4XH2TMxBzY7SnvyfwITM,554
22
22
  ai_simple_engine_runtime_diffusers/plugin.py,sha256=o_5OJSwHj_4Qy1LW-Y_JRIP3-LotSOEUVgB3LdnK3mU,2205
23
- ai_simple_engine_runtime_diffusers-0.0.5.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
24
- ai_simple_engine_runtime_diffusers-0.0.5.dist-info/METADATA,sha256=s1D44NWNtkx2D3sp3TTx0H4W4rkLfYkN6ZFH_6N0su0,841
25
- ai_simple_engine_runtime_diffusers-0.0.5.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
26
- ai_simple_engine_runtime_diffusers-0.0.5.dist-info/RECORD,,
23
+ ai_simple_engine_runtime_diffusers-0.0.6.dist-info/licenses/LICENSE,sha256=6kbiFSfobTZ7beWiKnHpN902HgBx-Jzgcme0SvKqhKY,1091
24
+ ai_simple_engine_runtime_diffusers-0.0.6.dist-info/METADATA,sha256=1IycPuH0vBg3I95R0i9MDKFWUCrlcTUAoI3Jr1_tdLg,841
25
+ ai_simple_engine_runtime_diffusers-0.0.6.dist-info/WHEEL,sha256=M5asmiAlL6HEcOq52Yi5mmk9KmTVjY2RDPtO4p9DMrc,88
26
+ ai_simple_engine_runtime_diffusers-0.0.6.dist-info/RECORD,,