Diffusers documentation

SkyReels-V2: 무한 길이 영화 생성 모델

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

LoRA

SkyReels-V2: 무한 길이 영화 생성 모델

Skywork AI의 SkyReels 팀이 개발한 SkyReels-V2.

최근 비디오 생성 분야의 발전은 diffusion models와 autoregressive frameworks에 의해 주도되어 왔으나, 프롬프트 준수, 시각적 품질, 모션 동역학, 길이 간의 조화라는 핵심적인 과제가 여전히 남아 있습니다: 시간적 시각 품질을 향상시키기 위해 모션 동역학을 타협하는 점, 해상도를 우선시하기 위해 비디오 길이(5-10초)가 제한되는 점, 그리고 shot composition, 배우의 표정, 카메라 모션과 같은 시네마틱 문법을 해석하는 데 일반 목적 MLLM이 갖는 한계로 인해 shot-aware 생성이 불충분한 점입니다. 이러한 서로 얽힌 한계들은 현실적인 롱폼 합성 및 전문 영화 스타일 생성을 방해합니다. 이러한 한계를 해결하기 위해, 우리는 Multi-modal Large Language Model (MLLM), Multi-stage Pretraining, Reinforcement Learning, Diffusion Forcing Framework를 시너지 효과로 결합한 무한 길이 영화 생성 모델인 SkyReels-V2를 제안합니다. 첫째, Multi-modal LLM의 일반적 설명과 서브 전문가 모델의 상세한 shot language를 결합한 비디오의 포괄적인 구조적 표현을 설계합니다. 인간 어노테이션의 도움을 받아, 비디오 데이터를 효율적으로 라벨링하는 통합 Video Captioner인 SkyCaptioner-V1을 학습합니다. 둘째, 기본 비디오 생성을 위한 progressive-resolution pretraining을 확립한 후, 4단계 post-training 강화 과정을 수행합니다: 초기 개념 균형 Supervised Fine-Tuning (SFT)은 베이스라인 품질을 향상시키고, 인간 어노테이션 및 합성 왜곡 데이터를 활용한 모션 특화 Reinforcement Learning (RL) 학습은 동적 아티팩트를 해결하며, 비감소(non-decreasing) 노이즈 스케줄을 갖춘 우리의 diffusion forcing framework는 효율적인 탐색 공간에서 롱 비디오 합성을 가능하게 하고, 최종 고품질 SFT는 시각적 충실도를 정교하게 다듬습니다. 모든 코드와 모델은 이 https URL에서 사용할 수 있습니다.

모든 원본 SkyReels-V2 체크포인트는 Skywork 조직에서 찾을 수 있습니다.

다음 SkyReels-V2 모델들이 Diffusers에서 지원됩니다:

이 모델은 M. Tolga Cangöz님이 기여했습니다.

오른쪽 사이드바의 SkyReles-V2 모델에 클릭하여 비디오 생성의 더 많은 예시를 확인하세요.

시각적 데모

…

  • base_num_frames=97
  • num_frames=97
  • num_inference_steps=30
  • ar_step=5
  • causal_block_size=5

vae_scale_factor_temporal=4인 경우, 다음 계산에 따라 5개의 블록, 각 블록당 5프레임을 예상할 수 있습니다:

num_latent_frames: (97-1)//vae_scale_factor_temporal+1 = 25 frames -> 5 blocks of 5 frames each

그리고 잠재 공간의 최대 컨텍스트 길이는 base_num_latent_frames로 계산됩니다:

base_num_latent_frames = (97-1)//vae_scale_factor_temporal+1 = 25 -> 25//5 = 5 blocks

비동기 처리 타임라인:

┌─────────────────────────────────────────────────────────────────┐
│ Steps:    1    6   11   16   21   26   31   36   41   46   50   │
│ Block 1: [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■]                       │
│ Block 2:      [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■]                  │
│ Block 3:           [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■]             │
│ Block 4:                [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■]        │
│ Block 5:                     [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■]   │
└─────────────────────────────────────────────────────────────────┘

긴 영상(num_frames > base_num_frames)의 경우: base_num_frames는 긴 영상을 처리할 때 “슬라이딩 윈도우 크기” 역할을 합니다.

예: 257프레임 비디오, base_num_frames=97, overlap_history=17

┌──── Iteration 1 (frames 1-97) ────┐
│ Processing window: 97 frames      │ → 5 blocks,
│ Generates: frames 1-97            │   async processing
└───────────────────────────────────┘
            ┌────── Iteration 2 (frames 81-177) ──────┐
            │ Processing window: 97 frames            │
            │ Overlap: 17 frames (81-97) from prev    │ → 5 blocks,
            │ Generates: frames 98-177                │   async processing
            └─────────────────────────────────────────┘
                        ┌────── Iteration 3 (frames 161-257) ──────┐
                        │ Processing window: 97 frames             │
                        │ Overlap: 17 frames (161-177) from prev   │ → 5 blocks,
                        │ Generates: frames 178-257                │   async processing
                        └──────────────────────────────────────────┘

각 반복은 자체 5 블록을 사용하여 비동기 처리를 독립적으로 실행합니다. base_num_frames은 다음을 제어합니다:

  1. 메모리 사용량(더 큰 윈도우 = 더 많은 VRAM)
  2. 모델 컨텍스트 길이(학습 제약 조건과 일치해야 함)
  3. 반복당 블록 수 (base_num_latent_frames // causal_block_size)

각 블록은 디노이징을 완료하는 데 30개의 스텝을 사용합니다. 블록 N은 스텝 1 + (N-1) x ar_step에서 시작합니다. 총 스텝 수: 30 + (5-1) x 5 = 50 스텝

동기 모드(ar_step=0)는 모든 블록/프레임을 동시에 처리합니다:

┌──────────────────────────────────────────────┐
│ Steps:       1            ...            30  │
│ All blocks: [■■■■■■■■■■■■■■■■■■■■■■■■■■■■■■] │
└──────────────────────────────────────────────┘

총 스텝: 30 스텝

비동기 처리를 위한 스텝 행렬 구성 예시: 다음 매개변수가 주어졌을 때: (num_inference_steps=30, flow_shift=8, num_frames=97, ar_step=5, causal_block_size=5)

- num_latent_frames = (97 frames - 1) // (4 temporal downsampling) + 1 = 25
- step_template = [999, 995, 991, 986, 980, 975, 969, 963, 956, 948,
                   941, 932, 922, 912, 901, 888, 874, 859, 841, 822,
                   799, 773, 743, 708, 666, 615, 551, 470, 363, 216]

알고리즘은 다음 조건을 만족하는 50x25 크기의 step_matrix를 생성합니다:

- Row 1:  [999×5, 999×5, 999×5, 999×5, 999×5]
- Row 2:  [995×5, 999×5, 999×5, 999×5, 999×5]
- Row 3:  [991×5, 999×5, 999×5, 999×5, 999×5]
- ...
- Row 7:  [969×5, 995×5, 999×5, 999×5, 999×5]
- ...
- Row 21: [799×5, 888×5, 941×5, 975×5, 999×5]
- ...
- Row 35: [  0×5, 216×5, 666×5, 822×5, 901×5]
- ...
- Row 42: [  0×5,   0×5,   0×5, 551×5, 773×5]
- ...
- Row 50: [  0×5,   0×5,   0×5,   0×5, 216×5]

6 행의 상세 분석:

- step_matrix[5]:      [ 975×5,  999×5,   999×5,   999×5,   999×5]
- step_index[5]:       [   6×5,    1×5,     0×5,     0×5,     0×5]
- step_update_mask[5]: [True×5, True×5, False×5, False×5, False×5]
- valid_interval[5]:   (0, 25)

핵심 패턴: Block i는 Block i-1보다 정확히 ar_step=5개의 timesteps만큼 뒤처져 있어, 뒤의 블록이 더 깨끗한 앞의 블록에 조건부 의존하는 단계적 “diffusion forcing” 효과를 만듭니다.

텍스트-투-비디오 생성

아래 예시는 텍스트에서 비디오를 생성하는 방법을 보여줍니다.

T2V 메모리

다양한 메모리 절약 기법에 대한 자세한 내용은 메모리 사용량 줄이기 가이드를 참조하세요.

원본 저장소에서:

—ar_step 5를 사용하여 비동기 추론을 활성화할 수 있습니다. 비동기 추론의 경우 —causal_block_size 5를 사용하는 것이 권장되며, 동기 생성에서는 이 값을 설정하지 않아야 합니다… 비동기 추론은 전체 시퀀스를 디퓨즈하는 데 더 많은 스텝이 필요하므로 동기 모드보다 느려집니다. 우리의 실험에 따르면, 비동기 추론은 지시 따름 및 시각적 일관성 성능을 향상시킬 수 있습니다.

import torch
from diffusers import AutoModel, SkyReelsV2DiffusionForcingPipeline, UniPCMultistepScheduler
from diffusers.utils import export_to_video


model_id = "Skywork/SkyReels-V2-DF-1.3B-540P-Diffusers"
vae = AutoModel.from_pretrained(model_id, subfolder="vae", dtype=torch.float32)

pipeline = SkyReelsV2DiffusionForcingPipeline.from_pretrained(
    model_id,
    vae=vae,
    dtype=torch.bfloat16,
)
pipeline.to("cuda")  # or "mps", "xpu", "cpu"
flow_shift = 8.0  # 8.0 for T2V, 5.0 for I2V
pipeline.scheduler = UniPCMultistepScheduler.from_config(pipeline.scheduler.config, flow_shift=flow_shift)

prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."

output = pipeline(
    prompt=prompt,
    num_inference_steps=30,
    height=544,  # 720 for 720P
    width=960,   # 1280 for 720P
    num_frames=97,
    base_num_frames=97,  # 121 for 720P
    ar_step=5,  # Controls asynchronous inference (0 for synchronous mode)
    causal_block_size=5,  # Number of frames in each block for asynchronous processing
    overlap_history=None,  # Number of frames to overlap for smooth transitions in long videos; 17 for long video generations
    addnoise_condition=20,  # Improves consistency in long video generation
).frames[0]
export_to_video(output, "video.mp4", fps=24, quality=8)

첫 번째-마지막 프레임-투-비디오 생성

…

사용법
import numpy as np
import torch
import torchvision.transforms.functional as TF
from diffusers import AutoencoderKLWan, SkyReelsV2DiffusionForcingImageToVideoPipeline, UniPCMultistepScheduler
from diffusers.utils import export_to_video, load_image


model_id = "Skywork/SkyReels-V2-DF-1.3B-720P-Diffusers"
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", dtype=torch.float32)
pipeline = SkyReelsV2DiffusionForcingImageToVideoPipeline.from_pretrained(
    model_id, vae=vae, dtype=torch.bfloat16
)
pipeline.to("cuda")  # or "mps", "xpu", "cpu"
flow_shift = 5.0  # 8.0 for T2V, 5.0 for I2V
pipeline.scheduler = UniPCMultistepScheduler.from_config(pipeline.scheduler.config, flow_shift=flow_shift)

first_frame = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_first_frame.png")
last_frame = load_image("https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/flf2v_input_last_frame.png")

def aspect_ratio_resize(image, pipeline, max_area=720 * 1280):
    aspect_ratio = image.height / image.width
    mod_value = pipeline.vae_scale_factor_spatial * pipeline.transformer.config.patch_size[1]
    height = round(np.sqrt(max_area * aspect_ratio)) // mod_value * mod_value
    width = round(np.sqrt(max_area / aspect_ratio)) // mod_value * mod_value
    image = image.resize((width, height))
    return image, height, width

def center_crop_resize(image, height, width):
    # Calculate resize ratio to match first frame dimensions
    resize_ratio = max(width / image.width, height / image.height)

    # Resize the image
    width = round(image.width * resize_ratio)
    height = round(image.height * resize_ratio)
    size = [width, height]
    image = TF.center_crop(image, size)

    return image, height, width

first_frame, height, width = aspect_ratio_resize(first_frame, pipeline)
if last_frame.size != first_frame.size:
    last_frame, _, _ = center_crop_resize(last_frame, height, width)

prompt = "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird's feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."

output = pipeline(
    image=first_frame, last_image=last_frame, prompt=prompt, height=height, width=width, guidance_scale=5.0
).frames[0]
export_to_video(output, "video.mp4", fps=24, quality=8)

비디오-투-비디오 생성

사용법

SkyReelsV2DiffusionForcingVideoToVideoPipeline은 주어진 비디오를 확장합니다.

import numpy as np
import torch
import torchvision.transforms.functional as TF
from diffusers import AutoencoderKLWan, SkyReelsV2DiffusionForcingVideoToVideoPipeline, UniPCMultistepScheduler
from diffusers.utils import export_to_video, load_video


model_id = "Skywork/SkyReels-V2-DF-1.3B-720P-Diffusers"
vae = AutoencoderKLWan.from_pretrained(model_id, subfolder="vae", dtype=torch.float32)
pipeline = SkyReelsV2DiffusionForcingVideoToVideoPipeline.from_pretrained(
    model_id, vae=vae, dtype=torch.bfloat16
)
pipeline.to("cuda")  # or "mps", "xpu", "cpu"
flow_shift = 5.0  # 8.0 for T2V, 5.0 for I2V
pipeline.scheduler = UniPCMultistepScheduler.from_config(pipeline.scheduler.config, flow_shift=flow_shift)

video = load_video("input_video.mp4")

prompt = "CG animation style, a small blue bird takes off from the ground, flapping its wings. The bird's feathers are delicate, with a unique pattern on its chest. The background shows a blue sky with white clouds under bright sunshine. The camera follows the bird upward, capturing its flight and the vastness of the sky from a close-up, low-angle perspective."

output = pipeline(
    video=video, prompt=prompt, height=720, width=1280, guidance_scale=5.0, overlap_history=17,
    num_inference_steps=30, num_frames=257, base_num_frames=121#, ar_step=5, causal_block_size=5,
).frames[0]
export_to_video(output, "video.mp4", fps=24, quality=8)
# Total frames will be the number of frames of the given video + 257

The input is a single word "Notes". 참고

SkyReelsV2Pipeline와 SkyReelsV2ImageToVideoPipeline은 Diffusion Forcing 프레임워크가 적용되지 않은 버전으로도 사용할 수 있습니다.

SkyReelsV2DiffusionForcingPipeline

클래스 diffusers.SkyReelsV2DiffusionForcingPipeline

< >

( tokenizer: AutoTokenizertext_encoder: transformers.models.t5.modeling_t5.T5EncoderModel | transformers.models.umt5.modeling_umt5.UMT5EncoderModeltransformer: SkyReelsV2Transformer3DModelvae: AutoencoderKLWanscheduler: UniPCMultistepScheduler )

매개변수

  • tokenizer (AutoTokenizer) — T5의 토크나이저, 구체적으로 google/umt5-xxl 변형입니다.
  • text_encoder (UMT5EncoderModel) — 구체적으로 google/umt5-xxl 변형인 T5입니다.
  • transformer (SkyReelsV2Transformer3DModel) — 인코딩된 이미지 레이턴트를 디노이즈하기 위한 조건부 Transformer입니다.
  • scheduler (UniPCMultistepScheduler) — transformer와 함께 사용되어 인코딩된 이미지 latents의 노이즈를 제거하는 데 사용되는 스케줄러.
  • vae (AutoencoderKLWan) — 잠재 표현으로 비디오를 인코딩 및 디코딩하는 Variational Auto-Encoder (VAE) 모델.

diffusion forcing를 사용하여 SkyReels-V2로 텍스트-비디오(t2v) 생성을 수행하는 파이프라인입니다.

이 모델은 DiffusionPipeline에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

__call__

< >

( prompt: str | list[str]negative_prompt: str | list[str] = Noneheight: int = 544width: int = 960num_frames: int = 97num_inference_steps: int = 50guidance_scale: float = 6.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'np'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']max_sequence_length: int = 512overlap_history: int | None = Noneaddnoise_condition: float = 0base_num_frames: int = 97ar_step: int = 0causal_block_size: int | None = Nonefps: int = 24 ) → ~SkyReelsV2PipelineOutput or tuple

매개변수

  • prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 prompt_embeds를 대신 전달해야 합니다.
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않을 때 무시됩니다(즉, guidance_scale이 1보다 작으면 무시됩니다).
  • height (int, 기본값 544) — 생성된 비디오의 높이입니다.
  • width (int, 기본값 960) — 생성된 비디오의 너비입니다.
  • num_frames (int, 기본값 97) — 생성된 비디오의 프레임 수입니다.
  • num_inference_steps (int, 기본값 50) — 디노이징 단계의 수입니다. 디노이징 단계가 많을수록 일반적으로 더 높은 품질의 이미지를 생성하지만, 추론 속도는 느려집니다.
  • guidance_scale (float, 기본값 6.0) — Classifier-Free Diffusion Guidance에서 정의한 guidance scale입니다. guidance_scale은 Imagen Paper의 방정식 2의 w로 정의됩니다. guidance_scale > 1로 설정하면 guidance scale이 활성화됩니다. guidance scale이 높을수록 prompt 텍스트와 밀접하게 연결된 이미지를 생성하도록 유도하지만, 일반적으로 이미지 품질이 낮아지는 대가를 치릅니다. (T2V의 경우 6.0, I2V의 경우 5.0)
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 이미지의 수.
  • generator (torch.Generator 또는 list[torch.Generator], 선택 사항) — 생성을 결정적으로 만들기 위한 torch.Generator.
  • latents (torch.Tensor, 선택 사항) — 가우시안 분포에서 샘플링된 사전 생성된 노이즈 latents로, 이미지 생성의 입력으로 사용됩니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서를 생성합니다.
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • output_type (str, 선택 사항, 기본값 "np") — 생성된 이미지의 출력 형식입니다. PIL.Image 또는 np.array 중 하나를 선택합니다.
  • return_dict (bool, 선택 사항, 기본값 True) — SkyReelsV2PipelineOutput을 반환할지, 아니면 일반 튜플을 반환할지를 결정합니다.
  • attention_kwargs (dict, 선택 사항) — 지정된 경우 diffusers.models.attention_processor의 self.processor에서 정의된 AttentionProcessor로 전달되는 kwargs 사전입니다.
  • callback_on_step_end (Callable, PipelineCallback, MultiPipelineCallbacks, 선택 사항) — 추론 중 각 denoising 단계의 끝에서 호출되는 함수 또는 PipelineCallback 또는 MultiPipelineCallbacks의 하위 클래스입니다. 다음 인수를 가집니다: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict). callback_kwargs에는 callback_on_step_end_tensor_inputs로 지정된 모든 텐서 목록이 포함됩니다.
  • callback_on_step_end_tensor_inputs (list, 선택 사항) — callback_on_step_end 함수의 텐서 입력 목록입니다. 목록에 지정된 텐서는 callback_kwargs 인수로 전달됩니다. 파이프라인 클래스의 ._callback_tensor_inputs 속성에 나열된 변수만 포함할 수 있습니다.
  • max_sequence_length (int, 선택 사항, 기본값 512) — 프롬프트의 최대 시퀀스 길이입니다.
  • overlap_history (int, 선택 사항, 기본값 None) — 긴 영상에서 부드러운 전환을 위해 겹칠 프레임 수입니다. None인 경우 파이프라인은 짧은 영상 생성 모드를 가정하며 겹침을 적용하지 않습니다. 17 또는 37을 설정하는 것이 권장됩니다.
  • addnoise_condition (float, 선택 사항, 기본값 0) — 이 값은 깨끗한 조건에 노이즈를 추가하여 긴 비디오 생성을 부드럽게 만드는 데 사용됩니다. 노이즈가 너무 크면 일관성이 깨질 수도 있습니다. 권장 값은 20이며, 더 큰 값을 시도해 볼 수 있지만 50을 초과하지 않는 것이 좋습니다.
  • base_num_frames (int, 선택 사항, 기본값 97) — 97 또는 121 | 기본 프레임 수 (540P의 경우 97, 720P의 경우 121)
  • ar_step (int, 선택 사항, 기본값 0) — 비동기 추론을 제어합니다(동기화 모드는 0). 비동기 추론을 활성화하려면 ar_step=5로 설정할 수 있습니다. 비동기 추론을 사용하는 경우 causal_block_size=5를 권장하며, 동기화 생성에서는 설정하지 않는 것이 좋습니다. 비동기 추론은 전체 시퀀스를 디퓨즈하는 데 더 많은 단계가 필요하므로 동기화 모드보다 느립니다. 실험 결과에 따르면, 비동기 추론은 지시 따르기 및 시각적 일관성 성능을 향상시킬 수 있습니다.
  • causal_block_size (int, 선택 사항, 기본값 None) — 각 블록/청크의 프레임 수입니다. 비동기 추론(ar_step > 0)을 사용할 때 권장됩니다.
  • fps (int, 선택 사항, 기본값 24) — 생성된 비디오의 프레임 레이트

반환값

~SkyReelsV2PipelineOutput 또는 tuple

return_dict가 True인 경우 SkyReelsV2PipelineOutput가 반환되고, 그렇지 않으면 tuple이 반환됩니다. 이 튜플의 첫 번째 요소는 생성된 이미지 목록이며, 두 번째 요소는 각 생성된 이미지에 “not-safe-for-work”(nsfw) 콘텐츠가 포함되어 있는지 여부를 나타내는 bool 목록입니다.

생성을 위한 pipeline의 호출 함수.

예:

>>> import torch
>>> from diffusers import (
...     SkyReelsV2DiffusionForcingPipeline,
...     UniPCMultistepScheduler,
...     AutoencoderKLWan,
... )
>>> from diffusers.utils import export_to_video

>>> # Load the pipeline
>>> # Available models:
>>> # - Skywork/SkyReels-V2-DF-1.3B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-DF-14B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-DF-14B-720P-Diffusers
>>> vae = AutoencoderKLWan.from_pretrained(
...     "Skywork/SkyReels-V2-DF-14B-720P-Diffusers",
...     subfolder="vae",
...     torch_dtype=torch.float32,
... )
>>> pipe = SkyReelsV2DiffusionForcingPipeline.from_pretrained(
...     "Skywork/SkyReels-V2-DF-14B-720P-Diffusers",
...     vae=vae,
...     torch_dtype=torch.bfloat16,
... )
>>> flow_shift = 8.0  # 8.0 for T2V, 5.0 for I2V
>>> pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
>>> pipe = pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."

>>> output = pipe(
...     prompt=prompt,
...     num_inference_steps=30,
...     height=544,
...     width=960,
...     guidance_scale=6.0,  # 6.0 for T2V, 5.0 for I2V
...     num_frames=97,
...     ar_step=5,  # Controls asynchronous inference (0 for synchronous mode)
...     causal_block_size=5,  # Number of frames processed together in a causal block
...     overlap_history=None,  # Number of frames to overlap for smooth transitions in long videos
...     addnoise_condition=20,  # Improves consistency in long video generation
... ).frames[0]
>>> export_to_video(output, "video.mp4", fps=24, quality=8)

encode_prompt

< >

( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )

매개변수

  • prompt (str 또는 list[str], 선택 사항) — 인코딩할 프롬프트
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않을 때 무시됩니다(즉, guidance_scale이 1보다 작으면 무시됩니다).
  • do_classifier_free_guidance (bool, 선택 사항, 기본값 True) — classifier free guidance를 사용할지 여부.
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch device
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택 사항) — 미리 생성된 negative text embeddings입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 negative_prompt_embeds가 생성됩니다.
  • device — (torch.device, 선택 사항): torch device
  • dtype — (torch.dtype, 선택 사항): torch dtype

프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.

generate_timestep_matrix

< >

( num_latent_frames: intstep_template: Tensorbase_num_latent_frames: intar_step: int = 5num_pre_ready: int = 0causal_block_size: int = 1shrink_interval_with_mask: bool = False ) → tuple containing

매개변수

  • num_latent_frames (int) — 생성할 latent frame의 총 개수
  • step_template (torch.Tensor) — 기본 timestep 스케줄 (예: [1000, 800, 600, …, 0])
  • base_num_latent_frames (int) — 모델이 하나의 forward pass에서 처리할 수 있는 최대 프레임 수
  • ar_step (int, optional) — 시간 지연을 위한 자기회귀 단계 크기. 0 = 동기식, >0 = 비동기식. 기본값은 5입니다.
  • num_pre_ready (int, optional) — 이미 노이즈 제거가 완료된 프레임의 수(예: video2video 작업의 prefix에서 가져온 경우). 기본값은 0입니다.
  • causal_block_size (int, optional) — 인과 블록으로 처리되는 프레임 수. 기본값은 1입니다.
  • shrink_interval_with_mask (bool, optional) — 처리 간격을 최적화할지 여부입니다. 기본값은 False입니다.

반환값

을 포함하는

  • step_matrix (torch.Tensor): 각 반복에서 각 프레임의 타임스텝 행렬 Shape: [num_iterations, num_latent_frames]
  • step_index (torch.Tensor): 타임스텝 조회를 위한 인덱스 행렬 Shape: [num_iterations, num_latent_frames]
  • step_update_mask (torch.Tensor): 업데이트할 프레임을 나타내는 불리언 마스크 Shape: [num_iterations, num_latent_frames]
  • valid_interval (list[tuple]): 각 반복에 대한 (start, end) 구간의 목록

발생

ValueError

  • ValueError — 주어진 구성에 대해 ar_step이 너무 작은 경우

이 함수는 시간 프레임에 걸쳐 조율된 디노이징 스케줄을 생성하는 핵심 diffusion forcing 알고리즘을 구현합니다. 동기 및 비동기 생성 모드를 모두 지원합니다:

동기 모드 (ar_step=0, causal_block_size=1):

  • 모든 프레임은 각 timestep에서 동시에 노이즈 제거됩니다
  • 각 프레임은 동일한 노이즈 제거 궤적을 따릅니다: [1000, 800, 600, …, 0]
  • 더 간단하지만 긴 비디오의 경우 시간적 일관성이 낮을 수 있습니다

비동기 모드(ar_step>0, causal_block_size>1):

  • Frames은 인과 블록으로 그룹화되어 블록/청크 단위로 처리됩니다
  • 각 블록은 단계적으로 노이즈가 제거되어 “denoising wave”를 생성합니다
  • 이전 블록은 더 많이 노이즈가 제거되고, 후속 블록은 ar_step 타임스텝만큼 뒤처집니다
  • 더 강한 시간적 의존성과 더 나은 일관성을 생성합니다

SkyReelsV2DiffusionForcingImageToVideoPipeline

class diffusers.SkyReelsV2DiffusionForcingImageToVideoPipeline

< >

( tokenizer: AutoTokenizertext_encoder: transformers.models.t5.modeling_t5.T5EncoderModel | transformers.models.umt5.modeling_umt5.UMT5EncoderModeltransformer: SkyReelsV2Transformer3DModelvae: AutoencoderKLWanscheduler: UniPCMultistepScheduler )

매개변수

  • tokenizer (AutoTokenizer) — T5의 토크나이저, 구체적으로 google/umt5-xxl 변형입니다.
  • text_encoder (UMT5EncoderModel) — 구체적으로 google/umt5-xxl 변형인 T5입니다.
  • transformer (SkyReelsV2Transformer3DModel) — 인코딩된 이미지 레이턴트를 디노이즈하기 위한 조건부 Transformer입니다.
  • scheduler (UniPCMultistepScheduler) — transformer와 함께 사용되어 인코딩된 이미지 latents의 노이즈를 제거하는 데 사용되는 스케줄러.
  • vae (AutoencoderKLWan) — 잠재 표현으로 비디오를 인코딩 및 디코딩하는 Variational Auto-Encoder (VAE) 모델.

diffusion forcing를 사용하여 SkyReels-V2로 이미지-비디오(i2v) 생성을 위한 파이프라인.

이 모델은 DiffusionPipeline에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

__call__

< >

( image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]prompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneheight: int = 544width: int = 960num_frames: int = 97num_inference_steps: int = 50guidance_scale: float = 5.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneimage_embeds: typing.Optional[torch.Tensor] = Nonelast_image: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'np'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']max_sequence_length: int = 512overlap_history: int | None = Noneaddnoise_condition: float = 0base_num_frames: int = 97ar_step: int = 0causal_block_size: int | None = Nonefps: int = 24 ) → ~SkyReelsV2PipelineOutput or tuple

매개변수

  • image (PipelineImageInput) — 생성을 조건화할 입력 이미지입니다. 이미지, 이미지 목록 또는 torch.Tensor여야 합니다.
  • prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 prompt_embeds를 대신 전달해야 합니다.
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않을 때 무시됩니다(즉, guidance_scale이 1보다 작으면 무시됩니다).
  • height (int, 기본값 544) — 생성된 비디오의 높이입니다.
  • width (int, 기본값 960) — 생성된 비디오의 너비입니다.
  • num_frames (int, 기본값 97) — 생성된 비디오의 프레임 수입니다.
  • num_inference_steps (int, 기본값 50) — 디노이징 단계의 수입니다. 디노이징 단계가 많을수록 일반적으로 더 높은 품질의 이미지를 생성하지만, 추론 속도는 느려집니다.
  • guidance_scale (float, 기본값 5.0) — Classifier-Free Diffusion Guidance에서 정의한 guidance scale입니다. guidance_scale은 Imagen Paper의 방정식 2의 w로 정의됩니다. guidance_scale > 1로 설정하면 guidance scale이 활성화됩니다. guidance scale이 높을수록 prompt 텍스트와 밀접하게 연결된 이미지를 생성하도록 유도하지만, 일반적으로 이미지 품질이 낮아지는 대가를 치릅니다. (T2V의 경우 6.0, I2V의 경우 5.0)
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 이미지의 수.
  • generator (torch.Generator 또는 list[torch.Generator], 선택 사항) — 생성을 결정적으로 만들기 위한 torch.Generator.
  • latents (torch.Tensor, 선택 사항) — 가우시안 분포에서 샘플링된 사전 생성된 노이즈 latents로, 이미지 생성의 입력으로 사용됩니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서를 생성합니다.
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • image_embeds (torch.Tensor, 선택) — 미리 생성된 이미지 임베딩입니다. 이미지 입력(가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 image 입력 인자로부터 이미지 임베딩이 생성됩니다.
  • last_image (torch.Tensor, 선택 사항) — 미리 생성된 이미지 임베딩입니다. 이미지 입력(가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 image 입력 인자에서 이미지 임베딩이 생성됩니다.
  • output_type (str, 선택 사항, 기본값 "np") — 생성된 이미지의 출력 형식입니다. PIL.Image 또는 np.array 중 하나를 선택합니다.
  • return_dict (bool, 선택 사항, 기본값 True) — SkyReelsV2PipelineOutput을 반환할지, 아니면 일반 튜플을 반환할지를 결정합니다.
  • attention_kwargs (dict, 선택 사항) — 지정된 경우 diffusers.models.attention_processor의 self.processor에서 정의된 AttentionProcessor로 전달되는 kwargs 사전입니다.
  • callback_on_step_end (Callable, PipelineCallback, MultiPipelineCallbacks, 선택 사항) — 추론 중 각 denoising 단계의 끝에서 호출되는 함수 또는 PipelineCallback 또는 MultiPipelineCallbacks의 하위 클래스입니다. 다음 인수를 가집니다: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict). callback_kwargs에는 callback_on_step_end_tensor_inputs로 지정된 모든 텐서 목록이 포함됩니다.
  • callback_on_step_end_tensor_inputs (list, 선택 사항) — callback_on_step_end 함수의 텐서 입력 목록입니다. 목록에 지정된 텐서는 callback_kwargs 인수로 전달됩니다. 파이프라인 클래스의 ._callback_tensor_inputs 속성에 나열된 변수만 포함할 수 있습니다.
  • max_sequence_length (int, 선택 사항, 기본값 512) — 프롬프트의 최대 시퀀스 길이입니다.
  • overlap_history (int, 선택 사항, 기본값 None) — 긴 영상에서 부드러운 전환을 위해 겹칠 프레임 수입니다. None인 경우 파이프라인은 짧은 영상 생성 모드를 가정하며 겹침을 적용하지 않습니다. 17 또는 37을 설정하는 것이 권장됩니다.
  • addnoise_condition (float, 선택 사항, 기본값 0) — 이 값은 깨끗한 조건에 노이즈를 추가하여 긴 비디오 생성을 부드럽게 만드는 데 사용됩니다. 노이즈가 너무 크면 일관성이 깨질 수도 있습니다. 권장 값은 20이며, 더 큰 값을 시도해 볼 수 있지만 50을 초과하지 않는 것이 좋습니다.
  • base_num_frames (int, 선택 사항, 기본값 97) — 97 또는 121 | 기본 프레임 수 (540P의 경우 97, 720P의 경우 121)
  • ar_step (int, 선택 사항, 기본값 0) — 비동기 추론을 제어합니다(동기화 모드는 0). 비동기 추론을 활성화하려면 ar_step=5로 설정할 수 있습니다. 비동기 추론을 사용하는 경우 causal_block_size=5를 권장하며, 동기화 생성에서는 설정하지 않는 것이 좋습니다. 비동기 추론은 전체 시퀀스를 디퓨즈하는 데 더 많은 단계가 필요하므로 동기화 모드보다 느립니다. 실험 결과에 따르면, 비동기 추론은 지시 따르기 및 시각적 일관성 성능을 향상시킬 수 있습니다.
  • causal_block_size (int, 선택 사항, 기본값 None) — 각 블록/청크의 프레임 수입니다. 비동기 추론(ar_step > 0)을 사용할 때 권장됩니다.
  • fps (int, 선택 사항, 기본값 24) — 생성된 비디오의 프레임 레이트

반환값

~SkyReelsV2PipelineOutput 또는 tuple

return_dict가 True인 경우 SkyReelsV2PipelineOutput가 반환되고, 그렇지 않으면 tuple이 반환됩니다. 이 튜플의 첫 번째 요소는 생성된 이미지 목록이며, 두 번째 요소는 각 생성된 이미지에 “not-safe-for-work”(nsfw) 콘텐츠가 포함되어 있는지 여부를 나타내는 bool 목록입니다.

생성을 위한 pipeline의 호출 함수.

예:

>>> import torch
>>> from diffusers import (
...     SkyReelsV2DiffusionForcingImageToVideoPipeline,
...     UniPCMultistepScheduler,
...     AutoencoderKLWan,
... )
>>> from diffusers.utils import export_to_video
>>> from PIL import Image

>>> # Load the pipeline
>>> # Available models:
>>> # - Skywork/SkyReels-V2-DF-1.3B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-DF-14B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-DF-14B-720P-Diffusers
>>> vae = AutoencoderKLWan.from_pretrained(
...     "Skywork/SkyReels-V2-DF-14B-720P-Diffusers",
...     subfolder="vae",
...     torch_dtype=torch.float32,
... )
>>> pipe = SkyReelsV2DiffusionForcingImageToVideoPipeline.from_pretrained(
...     "Skywork/SkyReels-V2-DF-14B-720P-Diffusers",
...     vae=vae,
...     torch_dtype=torch.bfloat16,
... )
>>> flow_shift = 5.0  # 8.0 for T2V, 5.0 for I2V
>>> pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
>>> pipe = pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."
>>> image = Image.open("path/to/image.png")

>>> output = pipe(
...     image=image,
...     prompt=prompt,
...     num_inference_steps=50,
...     height=544,
...     width=960,
...     guidance_scale=5.0,  # 6.0 for T2V, 5.0 for I2V
...     num_frames=97,
...     ar_step=0,  # Controls asynchronous inference (0 for synchronous mode)
...     overlap_history=None,  # Number of frames to overlap for smooth transitions in long videos
...     addnoise_condition=20,  # Improves consistency in long video generation
... ).frames[0]
>>> export_to_video(output, "video.mp4", fps=24, quality=8)

encode_prompt

< >

( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )

매개변수

  • prompt (str 또는 list[str], 선택 사항) — 인코딩할 프롬프트
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않을 때 무시됩니다(즉, guidance_scale이 1보다 작으면 무시됩니다).
  • do_classifier_free_guidance (bool, 선택 사항, 기본값 True) — classifier free guidance를 사용할지 여부.
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch device
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택 사항) — 미리 생성된 negative text embeddings입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 negative_prompt_embeds가 생성됩니다.
  • device — (torch.device, 선택 사항): torch device
  • dtype — (torch.dtype, 선택 사항): torch dtype

프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.

generate_timestep_matrix

< >

( num_latent_frames: intstep_template: Tensorbase_num_latent_frames: intar_step: int = 5num_pre_ready: int = 0causal_block_size: int = 1shrink_interval_with_mask: bool = False ) → tuple containing

매개변수

  • num_latent_frames (int) — 생성할 latent frame의 총 개수
  • step_template (torch.Tensor) — 기본 timestep 스케줄 (예: [1000, 800, 600, …, 0])
  • base_num_latent_frames (int) — 모델이 하나의 forward pass에서 처리할 수 있는 최대 프레임 수
  • ar_step (int, optional) — 시간 지연을 위한 자기회귀 단계 크기. 0 = 동기식, >0 = 비동기식. 기본값은 5입니다.
  • num_pre_ready (int, optional) — 이미 노이즈 제거가 완료된 프레임의 수(예: video2video 작업의 prefix에서 가져온 경우). 기본값은 0입니다.
  • causal_block_size (int, optional) — 인과 블록으로 처리되는 프레임 수. 기본값은 1입니다.
  • shrink_interval_with_mask (bool, optional) — 처리 간격을 최적화할지 여부입니다. 기본값은 False입니다.

반환값

을 포함하는

  • step_matrix (torch.Tensor): 각 반복에서 각 프레임의 타임스텝 행렬 Shape: [num_iterations, num_latent_frames]
  • step_index (torch.Tensor): 타임스텝 조회를 위한 인덱스 행렬 Shape: [num_iterations, num_latent_frames]
  • step_update_mask (torch.Tensor): 업데이트할 프레임을 나타내는 불리언 마스크 Shape: [num_iterations, num_latent_frames]
  • valid_interval (list[tuple]): 각 반복에 대한 (start, end) 구간의 목록

발생

ValueError

  • ValueError — 주어진 구성에 대해 ar_step이 너무 작은 경우

이 함수는 시간 프레임에 걸쳐 조율된 디노이징 스케줄을 생성하는 핵심 diffusion forcing 알고리즘을 구현합니다. 동기 및 비동기 생성 모드를 모두 지원합니다:

동기 모드 (ar_step=0, causal_block_size=1):

  • 모든 프레임은 각 timestep에서 동시에 노이즈 제거됩니다
  • 각 프레임은 동일한 노이즈 제거 궤적을 따릅니다: [1000, 800, 600, …, 0]
  • 더 간단하지만 긴 비디오의 경우 시간적 일관성이 낮을 수 있습니다

비동기 모드(ar_step>0, causal_block_size>1):

  • Frames은 인과 블록으로 그룹화되어 블록/청크 단위로 처리됩니다
  • 각 블록은 단계적으로 노이즈가 제거되어 “denoising wave”를 생성합니다
  • 이전 블록은 더 많이 노이즈가 제거되고, 후속 블록은 ar_step 타임스텝만큼 뒤처집니다
  • 더 강한 시간적 의존성과 더 나은 일관성을 생성합니다

SkyReelsV2DiffusionForcingVideoToVideoPipeline

class diffusers.SkyReelsV2DiffusionForcingVideoToVideoPipeline

< >

( tokenizer: AutoTokenizertext_encoder: transformers.models.t5.modeling_t5.T5EncoderModel | transformers.models.umt5.modeling_umt5.UMT5EncoderModeltransformer: SkyReelsV2Transformer3DModelvae: AutoencoderKLWanscheduler: UniPCMultistepScheduler )

매개변수

  • tokenizer (AutoTokenizer) — T5의 토크나이저, 구체적으로 google/umt5-xxl 변형입니다.
  • text_encoder (UMT5EncoderModel) — 구체적으로 google/umt5-xxl 변형인 T5입니다.
  • transformer (SkyReelsV2Transformer3DModel) — 인코딩된 이미지 레이턴트를 디노이즈하기 위한 조건부 Transformer입니다.
  • scheduler (UniPCMultistepScheduler) — transformer와 함께 사용되어 인코딩된 이미지 latents의 노이즈를 제거하는 데 사용되는 스케줄러.
  • vae (AutoencoderKLWan) — 잠재 표현으로 비디오를 인코딩 및 디코딩하는 Variational Auto-Encoder (VAE) 모델.

diffusion forcing를 사용하여 SkyReels-V2로 비디오-투-비디오(v2v) 생성을 수행하는 파이프라인입니다.

이 모델은 DiffusionPipeline에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

__call__

< >

( video: listprompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneheight: int = 544width: int = 960num_frames: int = 120num_inference_steps: int = 50guidance_scale: float = 6.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'np'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']max_sequence_length: int = 512overlap_history: int | None = Noneaddnoise_condition: float = 0base_num_frames: int = 97ar_step: int = 0causal_block_size: int | None = Nonefps: int = 24 ) → ~SkyReelsV2PipelineOutput or tuple

매개변수

  • video (list[Image.Image]) — 비디오 생성을 안내할 비디오.
  • prompt (str 또는 list[str], 선택 사항) — 비디오 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 prompt_embeds를 대신 전달해야 합니다.
  • negative_prompt (str 또는 list[str], 선택 사항) — 비디오 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않는 경우 무시됩니다(즉, guidance_scale이 1보다 작은 경우 무시됩니다).
  • height (int, 기본값 544) — 생성된 비디오의 높이입니다.
  • width (int, 기본값 960) — 생성된 비디오의 너비입니다.
  • num_frames (int, 기본값 120) — 생성된 비디오의 프레임 수입니다.
  • num_inference_steps (int, 기본값 50) — 디노이징 단계의 수입니다. 디노이징 단계가 많을수록 일반적으로 더 높은 품질의 이미지를 생성하지만, 추론 속도는 느려집니다.
  • guidance_scale (float, 기본값 6.0) — Classifier-Free Diffusion Guidance에서 정의한 guidance scale입니다. guidance_scale은 Imagen Paper의 2번 식의 w로 정의됩니다. guidance_scale > 1로 설정하면 guidance scale이 활성화됩니다. guidance scale이 높을수록 prompt 텍스트와 밀접하게 연결된 이미지를 생성하도록 유도하지만, 일반적으로 이미지 품질이 낮아지는 대가를 치릅니다. (T2V의 경우 6.0, I2V의 경우 5.0)
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 이미지의 수.
  • generator (torch.Generator 또는 list[torch.Generator], 선택 사항) — 생성을 결정적으로 만들기 위한 torch.Generator.
  • latents (torch.Tensor, 선택 사항) — 가우시안 분포에서 샘플링된 사전 생성된 노이즈 latents로, 이미지 생성의 입력으로 사용됩니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서를 생성합니다.
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • output_type (str, 선택 사항, 기본값 "np") — 생성된 이미지의 출력 형식입니다. PIL.Image 또는 np.array 중 하나를 선택합니다.
  • return_dict (bool, 선택 사항, 기본값 True) — SkyReelsV2PipelineOutput을 반환할지, 아니면 일반 튜플을 반환할지를 결정합니다.
  • attention_kwargs (dict, 선택 사항) — 지정된 경우 diffusers.models.attention_processor의 self.processor에서 정의된 AttentionProcessor로 전달되는 kwargs 사전입니다.
  • callback_on_step_end (Callable, PipelineCallback, MultiPipelineCallbacks, 선택 사항) — 추론 중 각 denoising 단계의 끝에서 호출되는 함수 또는 PipelineCallback 또는 MultiPipelineCallbacks의 하위 클래스입니다. 다음 인수를 가집니다: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict). callback_kwargs에는 callback_on_step_end_tensor_inputs로 지정된 모든 텐서 목록이 포함됩니다.
  • callback_on_step_end_tensor_inputs (list, 선택 사항) — callback_on_step_end 함수의 텐서 입력 목록입니다. 목록에 지정된 텐서는 callback_kwargs 인수로 전달됩니다. 파이프라인 클래스의 ._callback_tensor_inputs 속성에 나열된 변수만 포함할 수 있습니다.
  • max_sequence_length (int, 선택 사항, 기본값 512) — 프롬프트의 최대 시퀀스 길이입니다.
  • overlap_history (int, 선택 사항, 기본값 None) — 긴 영상에서 부드러운 전환을 위해 겹칠 프레임 수입니다. None인 경우 파이프라인은 짧은 영상 생성 모드를 가정하며 겹침을 적용하지 않습니다. 17 또는 37을 설정하는 것이 권장됩니다.
  • addnoise_condition (float, 선택 사항, 기본값 0) — 이 값은 깨끗한 조건에 노이즈를 추가하여 긴 비디오 생성을 부드럽게 만드는 데 사용됩니다. 노이즈가 너무 크면 일관성이 깨질 수도 있습니다. 권장 값은 20이며, 더 큰 값을 시도해 볼 수 있지만 50을 초과하지 않는 것이 좋습니다.
  • base_num_frames (int, 선택 사항, 기본값 97) — 97 또는 121 | 기본 프레임 수 (540P의 경우 97, 720P의 경우 121)
  • ar_step (int, 선택 사항, 기본값 0) — 비동기 추론을 제어합니다(동기화 모드는 0). 비동기 추론을 활성화하려면 ar_step=5로 설정할 수 있습니다. 비동기 추론을 사용하는 경우 causal_block_size=5를 권장하며, 동기화 생성에서는 설정하지 않는 것이 좋습니다. 비동기 추론은 전체 시퀀스를 디퓨즈하는 데 더 많은 단계가 필요하므로 동기화 모드보다 느립니다. 실험 결과에 따르면, 비동기 추론은 지시 따르기 및 시각적 일관성 성능을 향상시킬 수 있습니다.
  • causal_block_size (int, 선택 사항, 기본값 None) — 각 블록/청크의 프레임 수입니다. 비동기 추론(ar_step > 0)을 사용할 때 권장됩니다.
  • fps (int, 선택 사항, 기본값 24) — 생성된 비디오의 프레임 레이트

반환값

~SkyReelsV2PipelineOutput 또는 tuple

return_dict가 True인 경우 SkyReelsV2PipelineOutput가 반환되고, 그렇지 않으면 tuple이 반환됩니다. 이 튜플의 첫 번째 요소는 생성된 이미지 목록이며, 두 번째 요소는 각 생성된 이미지에 “not-safe-for-work”(nsfw) 콘텐츠가 포함되어 있는지 여부를 나타내는 bool 목록입니다.

생성을 위한 pipeline의 호출 함수.

예:

>>> import torch
>>> from diffusers import (
...     SkyReelsV2DiffusionForcingVideoToVideoPipeline,
...     UniPCMultistepScheduler,
...     AutoencoderKLWan,
... )
>>> from diffusers.utils import export_to_video

>>> # Load the pipeline
>>> # Available models:
>>> # - Skywork/SkyReels-V2-DF-1.3B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-DF-14B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-DF-14B-720P-Diffusers
>>> vae = AutoencoderKLWan.from_pretrained(
...     "Skywork/SkyReels-V2-DF-14B-720P-Diffusers",
...     subfolder="vae",
...     torch_dtype=torch.float32,
... )
>>> pipe = SkyReelsV2DiffusionForcingVideoToVideoPipeline.from_pretrained(
...     "Skywork/SkyReels-V2-DF-14B-720P-Diffusers",
...     vae=vae,
...     torch_dtype=torch.bfloat16,
... )
>>> flow_shift = 8.0  # 8.0 for T2V, 5.0 for I2V
>>> pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
>>> pipe = pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."

>>> output = pipe(
...     prompt=prompt,
...     num_inference_steps=50,
...     height=544,
...     width=960,
...     guidance_scale=6.0,  # 6.0 for T2V, 5.0 for I2V
...     num_frames=97,
...     ar_step=0,  # Controls asynchronous inference (0 for synchronous mode)
...     overlap_history=None,  # Number of frames to overlap for smooth transitions in long videos
...     addnoise_condition=20,  # Improves consistency in long video generation
... ).frames[0]
>>> export_to_video(output, "video.mp4", fps=24, quality=8)

encode_prompt

< >

( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )

매개변수

  • prompt (str 또는 list[str], 선택 사항) — 인코딩할 프롬프트
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않을 때 무시됩니다(즉, guidance_scale이 1보다 작으면 무시됩니다).
  • do_classifier_free_guidance (bool, 선택 사항, 기본값 True) — classifier free guidance를 사용할지 여부.
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch device
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택 사항) — 미리 생성된 negative text embeddings입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 negative_prompt_embeds가 생성됩니다.
  • device — (torch.device, 선택 사항): torch device
  • dtype — (torch.dtype, 선택 사항): torch dtype

프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.

generate_timestep_matrix

< >

( num_latent_frames: intstep_template: Tensorbase_num_latent_frames: intar_step: int = 5num_pre_ready: int = 0causal_block_size: int = 1shrink_interval_with_mask: bool = False ) → tuple containing

매개변수

  • num_latent_frames (int) — 생성할 latent frame의 총 개수
  • step_template (torch.Tensor) — 기본 timestep 스케줄 (예: [1000, 800, 600, …, 0])
  • base_num_latent_frames (int) — 모델이 하나의 forward pass에서 처리할 수 있는 최대 프레임 수
  • ar_step (int, optional) — 시간 지연을 위한 자기회귀 단계 크기. 0 = 동기식, >0 = 비동기식. 기본값은 5입니다.
  • num_pre_ready (int, optional) — 이미 노이즈 제거가 완료된 프레임의 수(예: video2video 작업의 prefix에서 가져온 경우). 기본값은 0입니다.
  • causal_block_size (int, optional) — 인과 블록으로 처리되는 프레임 수. 기본값은 1입니다.
  • shrink_interval_with_mask (bool, optional) — 처리 간격을 최적화할지 여부입니다. 기본값은 False입니다.

반환값

을 포함하는

  • step_matrix (torch.Tensor): 각 반복에서 각 프레임의 타임스텝 행렬 Shape: [num_iterations, num_latent_frames]
  • step_index (torch.Tensor): 타임스텝 조회를 위한 인덱스 행렬 Shape: [num_iterations, num_latent_frames]
  • step_update_mask (torch.Tensor): 업데이트할 프레임을 나타내는 불리언 마스크 Shape: [num_iterations, num_latent_frames]
  • valid_interval (list[tuple]): 각 반복에 대한 (start, end) 구간의 목록

발생

ValueError

  • ValueError — 주어진 구성에 대해 ar_step이 너무 작은 경우

이 함수는 시간 프레임에 걸쳐 조율된 디노이징 스케줄을 생성하는 핵심 diffusion forcing 알고리즘을 구현합니다. 동기 및 비동기 생성 모드를 모두 지원합니다:

동기 모드 (ar_step=0, causal_block_size=1):

  • 모든 프레임은 각 timestep에서 동시에 노이즈 제거됩니다
  • 각 프레임은 동일한 노이즈 제거 궤적을 따릅니다: [1000, 800, 600, …, 0]
  • 더 간단하지만 긴 비디오의 경우 시간적 일관성이 낮을 수 있습니다

비동기 모드(ar_step>0, causal_block_size>1):

  • Frames은 인과 블록으로 그룹화되어 블록/청크 단위로 처리됩니다
  • 각 블록은 단계적으로 노이즈가 제거되어 “denoising wave”를 생성합니다
  • 이전 블록은 더 많이 노이즈가 제거되고, 후속 블록은 ar_step 타임스텝만큼 뒤처집니다
  • 더 강한 시간적 의존성과 더 나은 일관성을 생성합니다

SkyReelsV2Pipeline

클래스 diffusers.SkyReelsV2Pipeline

< >

( tokenizer: AutoTokenizertext_encoder: transformers.models.t5.modeling_t5.T5EncoderModel | transformers.models.umt5.modeling_umt5.UMT5EncoderModeltransformer: SkyReelsV2Transformer3DModelvae: AutoencoderKLWanscheduler: UniPCMultistepScheduler )

매개변수

  • tokenizer (T5Tokenizer) — T5의 토크나이저로, 구체적으로 google/umt5-xxl 변형입니다.
  • text_encoder (T5EncoderModel) — 구체적으로 google/umt5-xxl 변형을 사용하는 T5입니다.
  • transformer (SkyReelsV2Transformer3DModel) — 입력 latents의 노이즈를 제거하기 위한 조건부 Transformer.
  • scheduler (UniPCMultistepScheduler) — transformer와 함께 사용되어 인코딩된 이미지 latents의 노이즈를 제거하는 데 사용되는 스케줄러.
  • vae (AutoencoderKLWan) — 잠재 표현으로 비디오를 인코딩 및 디코딩하는 Variational Auto-Encoder (VAE) 모델.

SkyReels-V2를 사용한 텍스트-비디오(t2v) 생성을 위한 Pipeline

이 모델은 DiffusionPipeline에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

__call__

< >

( prompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneheight: int = 544width: int = 960num_frames: int = 97num_inference_steps: int = 50guidance_scale: float = 6.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'np'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']max_sequence_length: int = 512 ) → ~SkyReelsV2PipelineOutput or tuple

매개변수

  • prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 prompt_embeds를 대신 전달해야 합니다.
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 대신 negative_prompt_embeds를 전달해야 합니다. 가이던스를 사용하지 않을 때(guidance_scale < 1) 무시됩니다.
  • height (int, 기본값 544) — 생성된 이미지의 픽셀 단위 높이입니다.
  • width (int, 기본값 960) — 생성된 이미지의 픽셀 단위 너비입니다.
  • num_frames (int, 기본값 97) — 생성된 비디오의 프레임 수입니다.
  • num_inference_steps (int, 기본값 50) — 디노이징 단계의 수입니다. 디노이징 단계가 많을수록 일반적으로 더 높은 품질의 이미지를 생성하지만, 추론 속도는 느려집니다.
  • guidance_scale (float, 기본값 6.0) — Classifier-Free Diffusion Guidance에서 정의한 가이던스 스케일입니다. guidance_scale은 Imagen Paper의 방정식 2의 w로 정의됩니다. guidance_scale > 1로 설정하면 가이던스 스케일이 활성화됩니다. 가이던스 스케일이 높을수록 prompt 텍스트와 밀접하게 연결된 이미지를 생성하도록 유도하지만, 일반적으로 이미지 품질이 낮아지는 대가를 치릅니다.
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 이미지의 수.
  • generator (torch.Generator 또는 list[torch.Generator], 선택 사항) — 생성을 결정적으로 만들기 위한 torch.Generator.
  • latents (torch.Tensor, 선택 사항) — 가우시안 분포에서 샘플링된 사전 생성된 노이즈 latents로, 이미지 생성의 입력으로 사용됩니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서를 생성합니다.
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택 사항) — 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 negative_prompt_embeds가 생성됩니다.
  • output_type (str, 선택 사항, 기본값 "np") — 생성된 이미지의 출력 형식입니다. PIL.Image 또는 np.array 중 하나를 선택합니다.
  • return_dict (bool, 선택 사항, 기본값 True) — SkyReelsV2PipelineOutput을 반환할지, 아니면 일반 튜플을 반환할지를 결정합니다.
  • attention_kwargs (dict, 선택 사항) — 지정된 경우 diffusers.models.attention_processor의 self.processor에서 정의된 AttentionProcessor로 전달되는 kwargs 사전입니다.
  • callback_on_step_end (Callable, PipelineCallback, MultiPipelineCallbacks, 선택 사항) — 추론 중 각 denoising 단계의 끝에서 호출되는 함수 또는 PipelineCallback 또는 MultiPipelineCallbacks의 하위 클래스입니다. 다음 인수를 가집니다: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict). callback_kwargs에는 callback_on_step_end_tensor_inputs로 지정된 모든 텐서 목록이 포함됩니다.
  • callback_on_step_end_tensor_inputs (list, 선택 사항) — callback_on_step_end 함수의 텐서 입력 목록입니다. 목록에 지정된 텐서는 callback_kwargs 인수로 전달됩니다. 파이프라인 클래스의 ._callback_tensor_inputs 속성에 나열된 변수만 포함할 수 있습니다.
  • max_sequence_length (int, 선택 사항, 기본값 512) — 텍스트 인코더의 최대 시퀀스 길이입니다.

반환값

~SkyReelsV2PipelineOutput 또는 tuple

return_dict가 True인 경우 SkyReelsV2PipelineOutput가 반환되고, 그렇지 않으면 tuple이 반환됩니다. 이 튜플의 첫 번째 요소는 생성된 이미지 목록이며, 두 번째 요소는 각 생성된 이미지에 “not-safe-for-work”(nsfw) 콘텐츠가 포함되어 있는지 여부를 나타내는 bool 목록입니다.

생성을 위한 pipeline의 호출 함수.

예:

>>> import torch
>>> from diffusers import (
...     SkyReelsV2Pipeline,
...     UniPCMultistepScheduler,
...     AutoencoderKLWan,
... )
>>> from diffusers.utils import export_to_video

>>> # Load the pipeline
>>> # Available models:
>>> # - Skywork/SkyReels-V2-T2V-14B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-T2V-14B-720P-Diffusers
>>> vae = AutoencoderKLWan.from_pretrained(
...     "Skywork/SkyReels-V2-T2V-14B-720P-Diffusers",
...     subfolder="vae",
...     torch_dtype=torch.float32,
... )
>>> pipe = SkyReelsV2Pipeline.from_pretrained(
...     "Skywork/SkyReels-V2-T2V-14B-720P-Diffusers",
...     vae=vae,
...     torch_dtype=torch.bfloat16,
... )
>>> flow_shift = 8.0  # 8.0 for T2V, 5.0 for I2V
>>> pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
>>> pipe = pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."

>>> output = pipe(
...     prompt=prompt,
...     num_inference_steps=50,
...     height=544,
...     width=960,
...     guidance_scale=6.0,  # 6.0 for T2V, 5.0 for I2V
...     num_frames=97,
... ).frames[0]
>>> export_to_video(output, "video.mp4", fps=24, quality=8)

encode_prompt

< >

( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )

매개변수

  • prompt (str 또는 list[str], 선택 사항) — 인코딩할 프롬프트
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않을 때 무시됩니다(즉, guidance_scale이 1보다 작으면 무시됩니다).
  • do_classifier_free_guidance (bool, 선택 사항, 기본값 True) — classifier free guidance를 사용할지 여부.
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch device
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택 사항) — 미리 생성된 negative text embeddings입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 negative_prompt_embeds가 생성됩니다.
  • device — (torch.device, 선택 사항): torch device
  • dtype — (torch.dtype, 선택 사항): torch dtype

프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.

SkyReelsV2ImageToVideoPipeline

class diffusers.SkyReelsV2ImageToVideoPipeline

< >

( tokenizer: AutoTokenizertext_encoder: transformers.models.t5.modeling_t5.T5EncoderModel | transformers.models.umt5.modeling_umt5.UMT5EncoderModelimage_encoder: CLIPVisionModelWithProjectionimage_processor: CLIPProcessortransformer: SkyReelsV2Transformer3DModelvae: AutoencoderKLWanscheduler: UniPCMultistepScheduler )

매개변수

  • tokenizer (T5Tokenizer) — T5의 토크나이저로, 구체적으로 google/umt5-xxl 변형입니다.
  • text_encoder (T5EncoderModel) — 구체적으로 google/umt5-xxl 변형을 사용하는 T5입니다.
  • image_encoder (CLIPVisionModelWithProjection) — 구체적으로 clip-vit-huge-patch14 변형인 CLIP
  • transformer (SkyReelsV2Transformer3DModel) — 입력 latents의 노이즈를 제거하기 위한 조건부 Transformer.
  • scheduler (UniPCMultistepScheduler) — transformer와 함께 사용되어 인코딩된 이미지 latents의 노이즈를 제거하는 데 사용되는 스케줄러.
  • vae (AutoencoderKLWan) — 잠재 표현으로 비디오를 인코딩 및 디코딩하는 Variational Auto-Encoder (VAE) 모델.

SkyReels-V2를 사용하여 이미지에서 비디오(i2v)를 생성하는 Pipeline입니다.

이 모델은 DiffusionPipeline에서 상속됩니다. 모든 파이프라인에 대해 구현된 일반적 메서드(다운로드, 저장, 특정 디바이스에서 실행 등)에 대해서는 상위 클래스 문서를 확인하세요.

__call__

< >

( image: typing.Union[PIL.Image.Image, numpy.ndarray, torch.Tensor, list[PIL.Image.Image], list[numpy.ndarray], list[torch.Tensor]]prompt: str | list[str] = Nonenegative_prompt: str | list[str] = Noneheight: int = 544width: int = 960num_frames: int = 97num_inference_steps: int = 50guidance_scale: float = 5.0num_videos_per_prompt: int | None = 1generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = Nonelatents: typing.Optional[torch.Tensor] = Noneprompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Noneimage_embeds: typing.Optional[torch.Tensor] = Nonelast_image: typing.Optional[torch.Tensor] = Noneoutput_type: str | None = 'np'return_dict: bool = Trueattention_kwargs: dict[str, typing.Any] | None = Nonecallback_on_step_end: typing.Union[typing.Callable[[int, int], NoneType], diffusers.callbacks.PipelineCallback, diffusers.callbacks.MultiPipelineCallbacks, NoneType] = Nonecallback_on_step_end_tensor_inputs: list = ['latents']max_sequence_length: int = 512 ) → ~SkyReelsV2PipelineOutput or tuple

매개변수

  • image (PipelineImageInput) — 생성을 조건화할 입력 이미지입니다. 이미지, 이미지 목록 또는 torch.Tensor여야 합니다.
  • prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 prompt_embeds를 대신 전달해야 합니다.
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않을 때 무시됩니다(즉, guidance_scale이 1보다 작으면 무시됩니다).
  • height (int, 기본값 544) — 생성된 비디오의 높이입니다.
  • width (int, 기본값 960) — 생성된 비디오의 너비입니다.
  • num_frames (int, 기본값 97) — 생성된 비디오의 프레임 수입니다.
  • num_inference_steps (int, 기본값 50) — 디노이징 단계의 수입니다. 디노이징 단계가 많을수록 일반적으로 더 높은 품질의 이미지를 생성하지만, 추론 속도는 느려집니다.
  • guidance_scale (float, 기본값 5.0) — Classifier-Free Diffusion Guidance에서 정의한 가이던스 스케일입니다. guidance_scale은 Imagen Paper의 방정식 2의 w로 정의됩니다. guidance_scale > 1로 설정하면 가이던스 스케일이 활성화됩니다. 가이던스 스케일이 높을수록 prompt 텍스트와 밀접하게 연결된 이미지를 생성하도록 유도하지만, 일반적으로 이미지 품질이 낮아지는 대가를 치릅니다.
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 이미지의 수.
  • generator (torch.Generator 또는 list[torch.Generator], 선택 사항) — 생성을 결정적으로 만들기 위한 torch.Generator.
  • latents (torch.Tensor, 선택 사항) — 가우시안 분포에서 샘플링된 사전 생성된 노이즈 latents로, 이미지 생성의 입력으로 사용됩니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 generator를 사용하여 샘플링하여 latents 텐서를 생성합니다.
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 prompt 입력 인자에서 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력(프롬프트 가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • image_embeds (torch.Tensor, 선택) — 미리 생성된 이미지 임베딩입니다. 이미지 입력(가중치)을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 image 입력 인자로부터 이미지 임베딩이 생성됩니다.
  • last_image (torch.Tensor, 선택 사항) — 생성된 비디오의 끝을 고정하는 이미지-비디오 조건화에 사용되는 선택적 마지막 이미지입니다.
  • output_type (str, 선택 사항, 기본값 "np") — 생성된 이미지의 출력 형식입니다. PIL.Image 또는 np.array 중 하나를 선택합니다.
  • return_dict (bool, 선택 사항, 기본값 True) — WanPipelineOutput을 반환할지, 아니면 일반 튜플을 반환할지를 결정합니다.
  • attention_kwargs (dict, 선택 사항) — 지정된 경우 diffusers.models.attention_processor의 self.processor에서 정의된 AttentionProcessor로 전달되는 kwargs 사전입니다.
  • callback_on_step_end (Callable, PipelineCallback, MultiPipelineCallbacks, 선택 사항) — 추론 중 각 denoising 단계의 끝에서 호출되는 함수 또는 PipelineCallback 또는 MultiPipelineCallbacks의 하위 클래스입니다. 다음 인수를 가집니다: callback_on_step_end(self: DiffusionPipeline, step: int, timestep: int, callback_kwargs: Dict). callback_kwargs에는 callback_on_step_end_tensor_inputs로 지정된 모든 텐서 목록이 포함됩니다.
  • callback_on_step_end_tensor_inputs (list, 선택 사항) — callback_on_step_end 함수의 텐서 입력 목록입니다. 목록에 지정된 텐서는 callback_kwargs 인수로 전달됩니다. 파이프라인 클래스의 ._callback_tensor_inputs 속성에 나열된 변수만 포함할 수 있습니다.
  • max_sequence_length (int, 선택 사항, 기본값 512) — 프롬프트의 최대 시퀀스 길이입니다.

반환값

~SkyReelsV2PipelineOutput 또는 tuple

return_dict가 True인 경우 SkyReelsV2PipelineOutput가 반환되고, 그렇지 않으면 tuple이 반환됩니다. 이 튜플의 첫 번째 요소는 생성된 이미지 목록이며, 두 번째 요소는 각 생성된 이미지에 “not-safe-for-work”(nsfw) 콘텐츠가 포함되어 있는지 여부를 나타내는 bool 목록입니다.

생성을 위한 pipeline의 호출 함수.

예:

>>> import torch
>>> from diffusers import (
...     SkyReelsV2ImageToVideoPipeline,
...     UniPCMultistepScheduler,
...     AutoencoderKLWan,
... )
>>> from diffusers.utils import export_to_video
>>> from PIL import Image

>>> # Load the pipeline
>>> # Available models:
>>> # - Skywork/SkyReels-V2-I2V-1.3B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-I2V-14B-540P-Diffusers
>>> # - Skywork/SkyReels-V2-I2V-14B-720P-Diffusers
>>> vae = AutoencoderKLWan.from_pretrained(
...     "Skywork/SkyReels-V2-I2V-14B-720P-Diffusers",
...     subfolder="vae",
...     torch_dtype=torch.float32,
... )
>>> pipe = SkyReelsV2ImageToVideoPipeline.from_pretrained(
...     "Skywork/SkyReels-V2-I2V-14B-720P-Diffusers",
...     vae=vae,
...     torch_dtype=torch.bfloat16,
... )
>>> flow_shift = 5.0  # 8.0 for T2V, 5.0 for I2V
>>> pipe.scheduler = UniPCMultistepScheduler.from_config(pipe.scheduler.config, flow_shift=flow_shift)
>>> pipe = pipe.to("cuda")

>>> prompt = "A cat and a dog baking a cake together in a kitchen. The cat is carefully measuring flour, while the dog is stirring the batter with a wooden spoon. The kitchen is cozy, with sunlight streaming through the window."
>>> image = Image.open("path/to/image.png")

>>> output = pipe(
...     image=image,
...     prompt=prompt,
...     num_inference_steps=50,
...     height=544,
...     width=960,
...     guidance_scale=5.0,  # 6.0 for T2V, 5.0 for I2V
...     num_frames=97,
... ).frames[0]
>>> export_to_video(output, "video.mp4", fps=24, quality=8)

encode_prompt

< >

( prompt: str | list[str]negative_prompt: str | list[str] | None = Nonedo_classifier_free_guidance: bool = Truenum_videos_per_prompt: int = 1prompt_embeds: typing.Optional[torch.Tensor] = Nonenegative_prompt_embeds: typing.Optional[torch.Tensor] = Nonemax_sequence_length: int = 226device: typing.Optional[torch.device] = Nonedtype: typing.Optional[torch.dtype] = None )

매개변수

  • prompt (str 또는 list[str], 선택 사항) — 인코딩할 프롬프트
  • negative_prompt (str 또는 list[str], 선택 사항) — 이미지 생성을 안내하지 않을 프롬프트입니다. 정의되지 않은 경우 negative_prompt_embeds를 대신 전달해야 합니다. 가이던스를 사용하지 않을 때 무시됩니다(즉, guidance_scale이 1보다 작으면 무시됩니다).
  • do_classifier_free_guidance (bool, 선택 사항, 기본값 True) — classifier free guidance를 사용할지 여부.
  • num_videos_per_prompt (int, 선택 사항, 기본값 1) — 프롬프트당 생성할 비디오의 수. 결과 임베딩을 배치할 torch device
  • prompt_embeds (torch.Tensor, 선택) — 미리 생성된 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 prompt 입력 인자로부터 텍스트 임베딩이 생성됩니다.
  • negative_prompt_embeds (torch.Tensor, 선택 사항) — 미리 생성된 negative text embeddings입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, 예를 들어 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 negative_prompt 입력 인자로부터 negative_prompt_embeds가 생성됩니다.
  • device — (torch.device, 선택 사항): torch device
  • dtype — (torch.dtype, 선택 사항): torch dtype

프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다.

SkyReelsV2PipelineOutput

클래스 diffusers.pipelines.skyreels_v2.pipeline_output.SkyReelsV2PipelineOutput

< >

( frames: Tensor )

매개변수

  • frames (torch.Tensor, np.ndarray, 또는 list[list[PIL.Image.Image]]) — 비디오 출력 목록 - batch_size, 길이의 중첩 목록일 수 있으며, 각 하위 목록에는 num_frames. 길이의 노이즈 제거된 PIL 이미지 시퀀스가 포함됩니다. 또한 (batch_size, num_frames, channels, height, width) 형상의 NumPy 배열 또는 Torch 텐서일 수도 있습니다.

SkyReelsV2 파이프라인의 출력 클래스입니다.

Update on GitHub