Diffusers documentation
معالج الفيديو
معالج الفيديو
توفر فئة VideoProcessor واجهة برمجة تطبيقات موحّدة لخطوط أنابيب الفيديو لتحضير المدخلات لتشفير VAE ومعالجة المخرجات بعد فك تشفيرها. ترث هذه الفئة VaeImageProcessor لذا فهي تتضمن تحويلات مثل تغيير الحجم، والتطبيع، والتحويل بين مصفوفات PIL Image وPyTorch و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)
المعاملات
- video (
list[PIL.Image],list[list[PIL.Image]],torch.Tensor,np.array,list[torch.Tensor],list[np.array]) — الفيديو المُدخل. يمكن أن يكون أحد ما يلي:- قائمة بصور PIL.
- قائمة من قوائم صور PIL.
- مصفوفات Torch رباعية الأبعاد (الشكل المتوقع لكل مصفوفة
(num_frames, num_channels, height, width)). - مصفوفات NumPy رباعية الأبعاد (الشكل المتوقع لكل مصفوفة
(num_frames, height, width, num_channels)). - قائمة من 4D Torch tensors (الشكل المتوقع لكل متجه
(num_frames, num_channels, height, width)). - قائمة من مصفوفات NumPy رباعية الأبعاد (الشكل المتوقع لكل مصفوفة
(num_frames, height, width, num_channels)). - مصفوفات NumPy بخمس أبعاد: الشكل المتوقع لكل مصفوفة
(batch_size, num_frames, height, width, num_channels). - مصفوفات Torch بخمس أبعاد: الشكل المتوقع لكل مصفوفة
(batch_size, num_frames, num_channels, height, width).
- height (
int، اختياري، القيمة الافتراضيةNone) — الارتفاع بالأطارات المُعالجة مسبقًا للفيديو. إذا كانتNone، فسيتم استخدامget_default_height_width()للحصول على الارتفاع الافتراضي. - 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.
يعيد
torch.Tensor من الشكل (batch_size, num_channels, num_frames, height, width)
مصفوفة خماسية الأبعاد تحتوي على مقاطع الفيديو المُجمّعة مع وضع القنوات أولاً.
يعالج الفيديو(الفيديوهات) المدخلة مسبقاً. سيتم تمرير الحُجج ذات الأسماء إلى VaeImageProcessor.preprocess.
diffusers.VideoProcessor.postprocess_video
< source >( video: Tensoroutput_type: str = 'np'**kwargs )
يحوّل متجه الفيديو إلى قائمة من الإطارات للتصدير. سيتم تمرير الحُجج ذات الأسماء إلى VaeImageProcessor.postprocess.