Postprocess the image, optionally apply mask overlay
(
self,
image: torch.Tensor,
output_type: str = "pil",
original_image: PIL.Image.Image | None = None,
original_mask: PIL.Image.Image | None = None,
crops_coords: tuple[int, int, int, int] | None = None,
)
| 935 | return processed_image, processed_mask, postprocessing_kwargs |
| 936 | |
| 937 | def postprocess( |
| 938 | self, |
| 939 | image: torch.Tensor, |
| 940 | output_type: str = "pil", |
| 941 | original_image: PIL.Image.Image | None = None, |
| 942 | original_mask: PIL.Image.Image | None = None, |
| 943 | crops_coords: tuple[int, int, int, int] | None = None, |
| 944 | ) -> tuple[PIL.Image.Image, PIL.Image.Image]: |
| 945 | """ |
| 946 | Postprocess the image, optionally apply mask overlay |
| 947 | """ |
| 948 | image = self._image_processor.postprocess( |
| 949 | image, |
| 950 | output_type=output_type, |
| 951 | ) |
| 952 | # optionally apply the mask overlay |
| 953 | if crops_coords is not None and (original_image is None or original_mask is None): |
| 954 | raise ValueError("original_image and original_mask must be provided if crops_coords is provided") |
| 955 | |
| 956 | elif crops_coords is not None and output_type != "pil": |
| 957 | raise ValueError("output_type must be 'pil' if crops_coords is provided") |
| 958 | |
| 959 | elif crops_coords is not None: |
| 960 | image = [ |
| 961 | self._image_processor.apply_overlay(original_mask, original_image, i, crops_coords) for i in image |
| 962 | ] |
| 963 | |
| 964 | return image |
| 965 | |
| 966 | |
| 967 | class VaeImageProcessorLDM3D(VaeImageProcessor): |
no test coverage detected