(images)
| 43 | |
| 44 | |
| 45 | def is_valid_image_imagelist(images): |
| 46 | # check if the image input is one of the supported formats for image and image list: |
| 47 | # it can be either one of below 3 |
| 48 | # (1) a 4d pytorch tensor or numpy array, |
| 49 | # (2) a valid image: PIL.Image.Image, 2-d np.ndarray or torch.Tensor (grayscale image), 3-d np.ndarray or torch.Tensor |
| 50 | # (3) a list of valid image |
| 51 | if isinstance(images, (np.ndarray, torch.Tensor)) and images.ndim == 4: |
| 52 | return True |
| 53 | elif is_valid_image(images): |
| 54 | return True |
| 55 | elif isinstance(images, list): |
| 56 | return all(is_valid_image(image) for image in images) |
| 57 | return False |
| 58 | |
| 59 | |
| 60 | class VaeImageProcessor(ConfigMixin): |
no test coverage detected