MCPcopy Index your code
hub / github.com/huggingface/diffusers / normalize

Method normalize

src/diffusers/image_processor.py:207–219  ·  view source on GitHub ↗

r""" Normalize an image array to [-1,1]. Args: images (`np.ndarray` or `torch.Tensor`): The image array to normalize. Returns: `np.ndarray` or `torch.Tensor`: The normalized image array.

(images: np.ndarray | torch.Tensor)

Source from the content-addressed store, hash-verified

205
206 @staticmethod
207 def normalize(images: np.ndarray | torch.Tensor) -> np.ndarray | torch.Tensor:
208 r"""
209 Normalize an image array to [-1,1].
210
211 Args:
212 images (`np.ndarray` or `torch.Tensor`):
213 The image array to normalize.
214
215 Returns:
216 `np.ndarray` or `torch.Tensor`:
217 The normalized image array.
218 """
219 return 2.0 * images - 1.0
220
221 @staticmethod
222 def denormalize(images: np.ndarray | torch.Tensor) -> np.ndarray | torch.Tensor:

Callers 14

preprocessMethod · 0.95
preprocessMethod · 0.45
transformMethod · 0.45
transformMethod · 0.45
transformMethod · 0.45
transformMethod · 0.45
to_latentFunction · 0.45
spherical_dist_lossFunction · 0.45
cond_fnMethod · 0.45
spherical_dist_lossFunction · 0.45
cond_fnMethod · 0.45
spherical_dist_lossFunction · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected