Diffusers documentation
Video Processor
Video Processor
VideoProcessor menyediakan API terpadu untuk pipeline video guna menyiapkan input untuk encoding VAE dan memproses output setelah didekode. Kelas ini mewarisi VaeImageProcessor sehingga mencakup transformasi seperti pengubahan ukuran, normalisasi, dan konversi antara PIL Image, PyTorch, dan array NumPy.
VideoProcessor
diffusers.VideoProcessor.preprocess_video
< source >( videoheight: int | None = Nonewidth: int | None = None**kwargs ) → torch.Tensor of shape (batch_size, num_channels, num_frames, height, width)
Parameter
- video (
list[PIL.Image],list[list[PIL.Image]],torch.Tensor,np.array,list[torch.Tensor],list[np.array]) — Video input. Bisa berupa salah satu dari berikut ini:- daftar gambar PIL.
- daftar dari daftar gambar PIL.
- Tensor Torch 4D (bentuk yang diharapkan untuk setiap tensor
(num_frames, num_channels, height, width)). - Array NumPy 4D (bentuk yang diharapkan untuk setiap array
(num_frames, height, width, num_channels)). - daftar tensor Torch 4D (bentuk yang diharapkan untuk setiap tensor
(num_frames, num_channels, height, width)). - daftar array NumPy 4D (bentuk yang diharapkan untuk setiap array
(num_frames, height, width, num_channels)). - Array NumPy 5D: bentuk yang diharapkan untuk setiap array
(batch_size, num_frames, height, width, num_channels). - Tensor Torch 5D: bentuk yang diharapkan untuk setiap array
(batch_size, num_frames, num_channels, height, width).
- height (
int, opsional, defaultNone) — Tinggi dalam frame video yang telah dipreprocess. JikaNone, akan menggunakanget_default_height_width()untuk mendapatkan tinggi default. - width (
int, optional, defaults toNone) -- The width in preprocessed frames of the video. IfNone, will use get_default_height_width()to get the default width.
Mengembalikan
torch.Tensor dengan bentuk (batch_size, num_channels, num_frames, height, width)
Tensor 5D yang menyimpan video dengan format channel-first dalam batch.
Memproses prapemrosesan video input. Argumen kata kunci akan diteruskan ke VaeImageProcessor.preprocess.
diffusers.VideoProcessor.postprocess_video
< source >( video: Tensoroutput_type: str = 'np'**kwargs )
Mengonversi tensor video menjadi daftar frame untuk diekspor. Argumen kata kunci akan diteruskan ke VaeImageProcessor.postprocess.