Diffusers documentation

معالج الفيديو

You are viewing main version, which requires installation from source. If you'd like regular pip install, checkout the latest stable version (v0.42.1).
Hugging Face's logo
Join the Hugging Face community

and get access to the augmented documentation experience

to get started

معالج الفيديو

توفر فئة VideoProcessor واجهة برمجة تطبيقات موحّدة لخطوط أنابيب الفيديو لتحضير المدخلات لتشفير VAE ومعالجة المخرجات بعد فك تشفيرها. ترث هذه الفئة VaeImageProcessor لذا فهي تتضمن تحويلات مثل تغيير الحجم، والتطبيع، والتحويل بين مصفوفات PIL Image وPyTorch وNumPy.

VideoProcessor

diffusers.VideoProcessor.preprocess_video

< >

( 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 to None) -- The width in preprocessed frames of the video. If None, 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

< >

( video: Tensoroutput_type: str = 'np'**kwargs )

المعاملات

  • video (torch.Tensor) — الفيديو على شكل متجه.
  • output_type (str، الافتراضي "np") — نوع المخرجات للموتر video بعد المعالجة.

يحوّل متجه الفيديو إلى قائمة من الإطارات للتصدير. سيتم تمرير الحُجج ذات الأسماء إلى VaeImageProcessor.postprocess.

Update on GitHub