r""" Convert a PyTorch tensor to a NumPy image. Args: images (`torch.Tensor`): The PyTorch tensor to convert to NumPy format. Returns: `np.ndarray`: A NumPy array representation of the images.
(images: torch.Tensor)
| 189 | |
| 190 | @staticmethod |
| 191 | def pt_to_numpy(images: torch.Tensor) -> np.ndarray: |
| 192 | r""" |
| 193 | Convert a PyTorch tensor to a NumPy image. |
| 194 | |
| 195 | Args: |
| 196 | images (`torch.Tensor`): |
| 197 | The PyTorch tensor to convert to NumPy format. |
| 198 | |
| 199 | Returns: |
| 200 | `np.ndarray`: |
| 201 | A NumPy array representation of the images. |
| 202 | """ |
| 203 | images = images.cpu().permute(0, 2, 3, 1).float().numpy() |
| 204 | return images |
| 205 | |
| 206 | @staticmethod |
| 207 | def normalize(images: np.ndarray | torch.Tensor) -> np.ndarray | torch.Tensor: |