Diffusers 文件
影片處理器
加入 Hugging Face 社群
並獲得增強的文件體驗
開始使用
影片處理器
VideoProcessor 為影片管道提供統一的 API,用於準備 VAE 編碼的輸入和解碼後處理輸出。該類繼承自 VaeImageProcessor,因此它包含大小調整、歸一化以及 PIL Image、PyTorch 和 NumPy 陣列之間的轉換等操作。
VideoProcessor
diffusers.video_processor.VideoProcessor.preprocess_video
< 源 >( video height: typing.Optional[int] = None width: typing.Optional[int] = None )
引數
- 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, 可選, 預設為None) -- 影片預處理幀的寬度。如果為None,將使用 get_default_height_width()獲取預設寬度。
預處理輸入影片。
diffusers.video_processor.VideoProcessor.postprocess_video
< 源 >( video: Tensor output_type: str = 'np' )
將影片張量轉換為幀列表以供匯出。