Buckets:
| # 视频处理器 | |
| `VideoProcessor` 为视频流水线提供了统一的 API,用于在 VAE 编码前准备输入,以及在解码后对输出进行后处理。该类继承自 [VaeImageProcessor](/docs/diffusers/v0.43.0/zh/api/image_processor#diffusers.VaeImageProcessor),因此包含诸如调整大小、归一化以及在 PIL Image、PyTorch 和 NumPy 数组之间进行转换等变换操作。 | |
| ## VideoProcessor[[diffusers.VideoProcessor.preprocess_video]] | |
| #### diffusers.VideoProcessor.preprocess_video[[diffusers.VideoProcessor.preprocess_video]] | |
| ```python | |
| diffusers.VideoProcessor.preprocess_video(video, height: int | None = None, width: int | None = None, **kwargs) | |
| ``` | |
| [源代码](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/video_processor.py#L28) | |
| **参数:** | |
| video (`list[PIL.Image]`、`list[list[PIL.Image]]`、`torch.Tensor`、`np.array`、`list[torch.Tensor]`、`list[np.array]`):输入视频。可以是以下之一:* PIL 图像列表。* PIL 图像列表的列表。* 4D Torch 张量(每个张量的预期形状为 `(num_frames, num_channels, height, width)`)。* 4D NumPy 数组(每个数组的预期形状为 `(num_frames, height, width, num_channels)`)。* 4D Torch 张量列表(每个张量的预期形状为 `(num_frames, num_channels, height, width)`)。* 4D NumPy 数组列表(每个数组的预期形状为 `(num_frames, height, width, num_channels)`)。* 5D NumPy 数组:每个数组的预期形状为 `(batch_size, num_frames, height, width, num_channels)`。* 5D Torch 张量:每个张量的预期形状为 `(batch_size, num_frames, num_channels, height, width)`。 | |
| height (`int`,*可选*,默认为 `None`):视频预处理后帧的高度。如果为 `None`,将使用 `get_default_height_width()` 获取默认高度。 | |
| width (`int`, *optional*`, defaults to `None`) : The width in preprocessed frames of the video. If `None`, will use get_default_height_width()` to get the default width. | |
| **返回:** 形状为 `(batch_size, num_channels, num_frames, height, width)` 的 `torch.Tensor` | |
| 一个 5D 张量,保存了批量化的通道优先(channels-first)视频。 | |
| 对输入视频进行预处理。关键字参数将转发至 `VaeImageProcessor.preprocess`。 | |
| #### diffusers.VideoProcessor.postprocess_video[[diffusers.VideoProcessor.postprocess_video]] | |
| ```python | |
| diffusers.VideoProcessor.postprocess_video(video: Tensor, output_type: str = 'np', **kwargs) | |
| ``` | |
| [源代码](https://github.com/huggingface/diffusers/blob/v0.43.0/src/diffusers/video_processor.py#L93) | |
| **参数:** | |
| video (`torch.Tensor`):以张量形式表示的视频。 | |
| output_type (`str`,默认为 `"np"`):后处理的 `video` 张量的输出类型。 | |
| 将视频张量转换为帧列表以用于导出。关键字参数将转发给 `VaeImageProcessor.postprocess`。 | |
Xet Storage Details
- Size:
- 2.85 kB
- Xet hash:
- f24be6a0f8fb6205577f47d51739b3b2117678ac22eadea5e732627e802c78cc
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.