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

Method postprocess

src/diffusers/image_processor.py:937–964  ·  view source on GitHub ↗

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,
    )

Source from the content-addressed store, hash-verified

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
967class VaeImageProcessorLDM3D(VaeImageProcessor):

Callers 15

postprocess_videoMethod · 0.45
__call__Method · 0.45
__call__Method · 0.45
run_safety_checkerMethod · 0.45
__call__Method · 0.45
mainFunction · 0.45
run_safety_checkerMethod · 0.45
__call__Method · 0.45
__call__Method · 0.45
run_safety_checkerMethod · 0.45
__call__Method · 0.45
__call__Method · 0.45

Calls 1

apply_overlayMethod · 0.80

Tested by

no test coverage detected