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

Function preprocess_image

models/flowsep/diffusers/utils/testing_utils.py:291–298  ·  view source on GitHub ↗
(image: PIL.Image, batch_size: int)

Source from the content-addressed store, hash-verified

289
290
291def preprocess_image(image: PIL.Image, batch_size: int):
292 w, h = image.size
293 w, h = (x - x % 8 for x in (w, h)) # resize to integer multiple of 8
294 image = image.resize((w, h), resample=PIL.Image.LANCZOS)
295 image = np.array(image).astype(np.float32) / 255.0
296 image = np.vstack([image[None].transpose(0, 3, 1, 2)] * batch_size)
297 image = torch.from_numpy(image)
298 return 2.0 * image - 1.0
299
300
301def export_to_video(video_frames: List[np.ndarray], output_video_path: str = None) -> str:

Callers

nothing calls this directly

Calls 1

resizeMethod · 0.80

Tested by

no test coverage detected