MCPcopy Create free account
hub / github.com/AlayaLab/Hive / postprocess

Method postprocess

models/flowsep/diffusers/image_processor.py:173–210  ·  view source on GitHub ↗
(
        self,
        image: torch.FloatTensor,
        output_type: str = "pil",
        do_denormalize: Optional[List[bool]] = None,
    )

Source from the content-addressed store, hash-verified

171 return image
172
173 def postprocess(
174 self,
175 image: torch.FloatTensor,
176 output_type: str = "pil",
177 do_denormalize: Optional[List[bool]] = None,
178 ):
179 if not isinstance(image, torch.Tensor):
180 raise ValueError(
181 f"Input for postprocessing is in incorrect format: {type(image)}. We only support pytorch tensor"
182 )
183 if output_type not in ["latent", "pt", "np", "pil"]:
184 deprecation_message = (
185 f"the output_type {output_type} is outdated and has been set to `np`. Please make sure to set it to one of these instead: "
186 "`pil`, `np`, `pt`, `latent`"
187 )
188 deprecate("Unsupported output_type", "1.0.0", deprecation_message, standard_warn=False)
189 output_type = "np"
190
191 if output_type == "latent":
192 return image
193
194 if do_denormalize is None:
195 do_denormalize = [self.config.do_normalize] * image.shape[0]
196
197 image = torch.stack(
198 [self.denormalize(image[i]) if do_denormalize[i] else image[i] for i in range(image.shape[0])]
199 )
200
201 if output_type == "pt":
202 return image
203
204 image = self.pt_to_numpy(image)
205
206 if output_type == "np":
207 return image
208
209 if output_type == "pil":
210 return self.numpy_to_pil(image)

Callers 15

run_safety_checkerMethod · 0.80
__call__Method · 0.80
run_safety_checkerMethod · 0.80
__call__Method · 0.80
run_safety_checkerMethod · 0.80
__call__Method · 0.80
run_safety_checkerMethod · 0.80
__call__Method · 0.80
run_safety_checkerMethod · 0.80
__call__Method · 0.80
run_safety_checkerMethod · 0.80
__call__Method · 0.80

Calls 4

denormalizeMethod · 0.95
pt_to_numpyMethod · 0.95
numpy_to_pilMethod · 0.95
deprecateFunction · 0.85

Tested by

no test coverage detected