Buckets:
| # | |
| # Apache License, Version 2.0("라이선스")에 따라 라이선스가 부여됩니다. | |
| # 이 파일은 라이선스에 따라만 사용할 수 있습니다. | |
| # 라이선스 사본은 다음에서 가져올 수 있습니다 | |
| # | |
| # http://www.apache.org/licenses/LICENSE-2.0 | |
| # | |
| # 적용 가능한 법률에 의해 요구되거나 서면으로 합의되지 않는 한, 소프트웨어 | |
| # 라이선스에 따라 배포되는 본 소프트웨어는 "있는 그대로" | |
| # 명시적이든 묵시적이든 어떠한 종류의 보증이나 조건도 없이 제공됩니다. | |
| # 권한을 관리하는 특정 언어에 대한 라이선스를 참조하세요 | |
| # 라이선스 하의 제한 사항. | |
| --> | |
| # Mochi 1 Preview | |
| > [!TIP] | |
| > 현재는 모델 가중치의 연구용 미리보기만 제공됩니다. | |
| [Mochi 1](https://huggingface.co/genmo/mochi-1-preview)은 Genmo에서 개발한 비디오 생성 모델로, 프롬프트 준수와 모션 품질에 중점을 두고 있습니다. 이 모델은 10B 파라미터의 Asmmetric Diffusion Transformer(AsymmDiT) 아키텍처를 갖추고 있으며, 추론 시 메모리 요구량을 줄이기 위해 비정방형(non-square) QKV 및 출력 투영 레이어를 사용합니다. 프롬프트 인코딩에는 단일 T5-XXL 모델이 사용됩니다. | |
| *Mochi 1 preview는 예비 평가에서 높은 충실도의 움직임과 강력한 프롬프트 준수 능력을 갖춘 오픈 최첨단 비디오 생성 모델입니다. 이 모델은 폐쇄형과 오픈형 비디오 생성 시스템 간의 격차를 크게 줄였습니다. 이 모델은 관대한 Apache 2.0 라이선스로 공개되었습니다.* | |
| > [!TIP] | |
| > Scheduler의 [가이드](../../using-diffusers/schedulers)를 확인하여 스케줄러의 속도와 품질 사이의 트레이드오프를 탐색하는 방법을 배우고, [파이프라인 간 구성 요소 재사용](../../using-diffusers/loading#reusing-models-in-multiple-pipelines) 섹션을 확인하여 동일한 구성 요소를 여러 파이프라인에 효율적으로 로드하는 방법을 배워보세요. | |
| ## 양자화 | |
| Quantization은 모델 가중치를 더 낮은 정밀도의 데이터 타입으로 저장하여 매우 큰 모델의 메모리 요구 사항을 줄이는 데 도움이 됩니다. 그러나 quantization은 비디오 모델에 따라 비디오 품질에 다양한 영향을 미칠 수 있습니다. | |
| 지원되는 양자화 백엔드와 사용 사례에 맞는 양자화 백엔드 선택에 대해 자세히 알아보려면 [Quantization](../../quantization/overview) 개요를 참조하세요. 아래 예제는 bitsandbytes를 사용하여 추론을 위해 양자화된 [MochiPipeline](/docs/diffusers/main/ko/api/pipelines/mochi#diffusers.MochiPipeline)을 로드하는 방법을 보여줍니다. | |
| ```py | |
| import torch | |
| from diffusers import BitsAndBytesConfig as DiffusersBitsAndBytesConfig, MochiTransformer3DModel, MochiPipeline | |
| from diffusers.utils import export_to_video | |
| from transformers import BitsAndBytesConfig as BitsAndBytesConfig, T5EncoderModel | |
| quant_config = BitsAndBytesConfig(load_in_8bit=True) | |
| text_encoder_8bit = T5EncoderModel.from_pretrained( | |
| "genmo/mochi-1-preview", | |
| subfolder="text_encoder", | |
| quantization_config=quant_config, | |
| dtype=torch.float16, | |
| ) | |
| quant_config = DiffusersBitsAndBytesConfig(load_in_8bit=True) | |
| transformer_8bit = MochiTransformer3DModel.from_pretrained( | |
| "genmo/mochi-1-preview", | |
| subfolder="transformer", | |
| quantization_config=quant_config, | |
| dtype=torch.float16, | |
| ) | |
| pipeline = MochiPipeline.from_pretrained( | |
| "genmo/mochi-1-preview", | |
| text_encoder=text_encoder_8bit, | |
| transformer=transformer_8bit, | |
| dtype=torch.float16, | |
| device_map="balanced", | |
| ) | |
| video = pipeline( | |
| "Close-up of a cats eye, with the galaxy reflected in the cats eye. Ultra high resolution 4k.", | |
| num_inference_steps=28, | |
| guidance_scale=3.5 | |
| ).frames[0] | |
| export_to_video(video, "cat.mp4") | |
| ``` | |
| ## Mochi-1 Preview로 비디오 생성 | |
| 다음 예제는 전체 정밀도의 `mochi-1-preview` 가중치를 다운로드하여 가장 높은 품질의 결과를 생성하지만, 실행하려면 최소 42GB의 VRAM이 필요합니다. | |
| ```python | |
| import torch | |
| from diffusers import MochiPipeline | |
| from diffusers.utils import export_to_video | |
| pipe = MochiPipeline.from_pretrained("genmo/mochi-1-preview") | |
| # Enable memory savings | |
| pipe.enable_model_cpu_offload() | |
| pipe.vae.enable_tiling() | |
| prompt = "Close-up of a chameleon's eye, with its scaly skin changing color. Ultra high resolution 4k." | |
| with torch.autocast("cuda", torch.bfloat16, cache_enabled=False): | |
| frames = pipe(prompt, num_frames=85).frames[0] | |
| export_to_video(frames, "mochi.mp4", fps=30) | |
| ``` | |
| ## 메모리를 절약하기 위해 낮은 정밀도 변형 사용 | |
| 다음 예제는 모델의 `bfloat16` 변형을 사용하며 실행에 22GB의 VRAM이 필요합니다. 이로 인해 생성된 비디오의 품질이 약간 저하됩니다. | |
| ```python | |
| import torch | |
| from diffusers import MochiPipeline | |
| from diffusers.utils import export_to_video | |
| pipe = MochiPipeline.from_pretrained("genmo/mochi-1-preview", variant="bf16", dtype=torch.bfloat16) | |
| # Enable memory savings | |
| pipe.enable_model_cpu_offload() | |
| pipe.vae.enable_tiling() | |
| prompt = "Close-up of a chameleon's eye, with its scaly skin changing color. Ultra high resolution 4k." | |
| frames = pipe(prompt, num_frames=85).frames[0] | |
| export_to_video(frames, "mochi.mp4", fps=30) | |
| ``` | |
| ## Genmo Mochi 저장소의 결과를 재현하기 | |
| [Genmo Mochi 구현](https://github.com/genmoai/mochi/tree/main)은 추론 과정의 각 단계에 대해 다른 정밀도 값을 사용합니다. 텍스트 인코더와 VAE는 `torch.float32`를 사용하는 반면, DiT는 [attention kernel](https://pytorch.org/docs/stable/generated/torch.nn.attention.sdpa_kernel.html#torch.nn.attention.sdpa_kernel)을 `EFFICIENT_ATTENTION`으로 설정하고 `torch.bfloat16`를 사용합니다. Diffusers 파이프라인은 현재 파이프라인의 서로 다른 단계에 대해 서로 다른 `dtypes`를 설정하는 것을 지원하지 않습니다. 원래 구현과 동일한 방식으로 추론을 실행하려면 다음 예시를 참고하세요. | |
| > [!TIP] | |
| > original Mochi implementation은 빈 프롬프트를 0으로 초기화합니다. 그러나 이 옵션을 활성화하고 파이프라인 전체를 autocast 아래에 두면 T5 텍스트 인코더에서 수치 오버플로가 발생할 수 있습니다. | |
| > | |
| > `force_zeros_for_empty_prompt`를 활성화할 경우, 텍스트 인코딩 단계를 전체 정밀도로 autocast 컨텍스트 외부에서 실행하는 것이 권장됩니다. | |
| > [!TIP] | |
| > 전체 정밀도로 latents를 디코딩하는 것은 메모리 사용량이 매우 높습니다. 이 예시의 163프레임을 생성하려면 최소 70GB의 VRAM이 필요합니다. 메모리를 줄이려면 프레임 수를 줄이거나 `torch.bfloat16`로 디코딩 단계를 실행하세요. | |
| ```python | |
| import torch | |
| from torch.nn.attention import SDPBackend, sdpa_kernel | |
| from diffusers import MochiPipeline | |
| from diffusers.utils import export_to_video | |
| from diffusers.video_processor import VideoProcessor | |
| pipe = MochiPipeline.from_pretrained("genmo/mochi-1-preview", force_zeros_for_empty_prompt=True) | |
| pipe.vae.enable_tiling() | |
| pipe.enable_model_cpu_offload() | |
| prompt = "An aerial shot of a parade of elephants walking across the African savannah. The camera showcases the herd and the surrounding landscape." | |
| with torch.no_grad(): | |
| prompt_embeds, prompt_attention_mask, negative_prompt_embeds, negative_prompt_attention_mask = ( | |
| pipe.encode_prompt(prompt=prompt) | |
| ) | |
| with torch.autocast("cuda", torch.bfloat16): | |
| with sdpa_kernel(SDPBackend.EFFICIENT_ATTENTION): | |
| frames = pipe( | |
| prompt_embeds=prompt_embeds, | |
| prompt_attention_mask=prompt_attention_mask, | |
| negative_prompt_embeds=negative_prompt_embeds, | |
| negative_prompt_attention_mask=negative_prompt_attention_mask, | |
| guidance_scale=4.5, | |
| num_inference_steps=64, | |
| height=480, | |
| width=848, | |
| num_frames=163, | |
| generator=torch.Generator("cuda").manual_seed(0), | |
| output_type="latent", | |
| return_dict=False, | |
| )[0] | |
| video_processor = VideoProcessor(vae_scale_factor=8) | |
| has_latents_mean = hasattr(pipe.vae.config, "latents_mean") and pipe.vae.config.latents_mean is not None | |
| has_latents_std = hasattr(pipe.vae.config, "latents_std") and pipe.vae.config.latents_std is not None | |
| if has_latents_mean and has_latents_std: | |
| latents_mean = ( | |
| torch.tensor(pipe.vae.config.latents_mean).view(1, 12, 1, 1, 1).to(frames.device, frames.dtype) | |
| ) | |
| latents_std = ( | |
| torch.tensor(pipe.vae.config.latents_std).view(1, 12, 1, 1, 1).to(frames.device, frames.dtype) | |
| ) | |
| frames = frames * latents_std / pipe.vae.config.scaling_factor + latents_mean | |
| else: | |
| frames = frames / pipe.vae.config.scaling_factor | |
| with torch.no_grad(): | |
| video = pipe.vae.decode(frames.to(pipe.vae.dtype), return_dict=False)[0] | |
| video = video_processor.postprocess_video(video)[0] | |
| export_to_video(video, "mochi.mp4", fps=30) | |
| ``` | |
| ## 여러 GPU를 사용하여 추론 실행 | |
| `from_pretrained`의 `device_map` 및 `max_memory` 옵션을 사용하여 대형 Mochi transformer를 여러 GPU에 나눠 배치할 수 있습니다. 다음 예시에서는 VRAM이 24GB인 두 개의 GPU에 모델을 나눠 배치합니다. | |
| ```python | |
| import torch | |
| from diffusers import MochiPipeline, MochiTransformer3DModel | |
| from diffusers.utils import export_to_video | |
| model_id = "genmo/mochi-1-preview" | |
| transformer = MochiTransformer3DModel.from_pretrained( | |
| model_id, | |
| subfolder="transformer", | |
| device_map="auto", | |
| max_memory={0: "24GB", 1: "24GB"} | |
| ) | |
| pipe = MochiPipeline.from_pretrained(model_id, transformer=transformer) | |
| pipe.enable_model_cpu_offload() | |
| pipe.vae.enable_tiling() | |
| with torch.autocast(device_type="cuda", dtype=torch.bfloat16, cache_enabled=False): | |
| frames = pipe( | |
| prompt="Close-up of a chameleon's eye, with its scaly skin changing color. Ultra high resolution 4k.", | |
| negative_prompt="", | |
| height=480, | |
| width=848, | |
| num_frames=85, | |
| num_inference_steps=50, | |
| guidance_scale=4.5, | |
| num_videos_per_prompt=1, | |
| generator=torch.Generator(device="cuda").manual_seed(0), # or "mps", "xpu", "cpu" | |
| max_sequence_length=256, | |
| output_type="pil", | |
| ).frames[0] | |
| export_to_video(frames, "output.mp4", fps=30) | |
| ``` | |
| ## Mochi Transformer를 사용한 단일 파일 로딩 | |
| `from_single_file`를 사용하여 Mochi transformer를 원래 형식으로 로드할 수 있습니다. | |
| > [!TIP] | |
| > Diffusers는 현재 Mochi 단일 파일 체크포인트의 FP8 스케일 버전을 지원하지 않습니다. | |
| ```python | |
| import torch | |
| from diffusers import MochiPipeline, MochiTransformer3DModel | |
| from diffusers.utils import export_to_video | |
| model_id = "genmo/mochi-1-preview" | |
| ckpt_path = "https://huggingface.co/Comfy-Org/mochi_preview_repackaged/blob/main/split_files/diffusion_models/mochi_preview_bf16.safetensors" | |
| transformer = MochiTransformer3DModel.from_pretrained(ckpt_path, dtype=torch.bfloat16) | |
| pipe = MochiPipeline.from_pretrained(model_id, transformer=transformer) | |
| pipe.enable_model_cpu_offload() | |
| pipe.vae.enable_tiling() | |
| with torch.autocast(device_type="cuda", dtype=torch.bfloat16, cache_enabled=False): | |
| frames = pipe( | |
| prompt="Close-up of a chameleon's eye, with its scaly skin changing color. Ultra high resolution 4k.", | |
| negative_prompt="", | |
| height=480, | |
| width=848, | |
| num_frames=85, | |
| num_inference_steps=50, | |
| guidance_scale=4.5, | |
| num_videos_per_prompt=1, | |
| generator=torch.Generator(device="cuda").manual_seed(0), # or "mps", "xpu", "cpu" | |
| max_sequence_length=256, | |
| output_type="pil", | |
| ).frames[0] | |
| export_to_video(frames, "output.mp4", fps=30) | |
| ``` | |
| ## MochiPipeline[[diffusers.MochiPipeline]] | |
| #### diffusers.MochiPipeline[[diffusers.MochiPipeline]] | |
| ```python | |
| diffusers.MochiPipeline(scheduler: FlowMatchEulerDiscreteScheduler, vae: AutoencoderKLMochi, text_encoder: T5EncoderModel, tokenizer: T5Tokenizer, transformer: MochiTransformer3DModel, force_zeros_for_empty_prompt: bool = False) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/mochi/pipeline_mochi.py#L138) | |
| **매개변수:** | |
| transformer ([MochiTransformer3DModel](/docs/diffusers/main/ko/api/models/mochi_transformer3d#diffusers.MochiTransformer3DModel)) : 인코딩된 비디오 잠재 변수를 디노이즈하기 위한 조건부 Transformer 아키텍처. | |
| scheduler ([FlowMatchEulerDiscreteScheduler](/docs/diffusers/main/ko/api/schedulers/flow_match_euler_discrete#diffusers.FlowMatchEulerDiscreteScheduler)) : `transformer`와 함께 사용하여 인코딩된 이미지 라텐트를 디노이즈하는 데 사용되는 스케줄러입니다. | |
| vae ([AutoencoderKLMochi](/docs/diffusers/main/ko/api/models/autoencoderkl_mochi#diffusers.AutoencoderKLMochi)) : 잠재 표현으로 비디오를 인코딩 및 디코딩하는 Variational Auto-Encoder (VAE) 모델. | |
| text_encoder (`T5EncoderModel`) : [T5](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5EncoderModel), 구체적으로 [google/t5-v1_1-xxl](https://huggingface.co/google/t5-v1_1-xxl) 변형입니다. | |
| tokenizer (`CLIPTokenizer`) : [CLIPTokenizer](https://huggingface.co/docs/transformers/en/model_doc/clip#transformers.CLIPTokenizer) 클래스의 토크나이저. | |
| tokenizer (`T5TokenizerFast`) : [T5TokenizerFast](https://huggingface.co/docs/transformers/en/model_doc/t5#transformers.T5TokenizerFast) 클래스의 두 번째 Tokenizer. | |
| 텍스트-투-비디오 생성을 위한 mochi 파이프라인. | |
| 참고: https://github.com/genmoai/models | |
| #### __호출__[[diffusers.MochiPipeline.__call__]] | |
| ```python | |
| __call__(prompt: str | list[str] = None, negative_prompt: str | list[str] | None = None, height: int | None = None, width: int | None = None, num_frames: int = 19, num_inference_steps: int = 64, timesteps: list[int] = None, guidance_scale: float = 4.5, num_videos_per_prompt: int | None = 1, generator: typing.Union[torch.Generator, list[torch.Generator], NoneType] = None, latents: typing.Optional[torch.Tensor] = None, prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, output_type: str | None = 'pil', return_dict: bool = True, attention_kwargs: dict[str, typing.Any] | None = None, callback_on_step_end: typing.Optional[typing.Callable[[int, int], NoneType]] = None, callback_on_step_end_tensor_inputs: list[str] = ['latents'], max_sequence_length: int = 256) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/mochi/pipeline_mochi.py#L444) | |
| **매개변수:** | |
| prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 안내할 프롬프트입니다. 정의되지 않은 경우 `prompt_embeds`를 대신 전달해야 합니다. | |
| negative_prompt (`str` 또는 `list[str]`, *선택 사항*) : 이미지 생성을 유도하지 않을 프롬프트입니다. 정의되지 않은 경우 대신 `negative_prompt_embeds`를 전달해야 합니다. 가이던스를 사용하지 않을 때(`guidance_scale < 1`)에는 무시됩니다. | |
| height (`int`, *선택 사항*, 기본값은 `self.default_height`) : 생성된 이미지의 픽셀 단위 높이입니다. 최적의 결과를 위해 기본값은 480으로 설정되어 있습니다. | |
| width (`int`, *선택 사항*, 기본값은 `self.default_width`) : 생성된 이미지의 픽셀 단위 너비입니다. 최적의 결과를 위해 기본값은 848로 설정되어 있습니다. | |
| num_frames (`int`, 기본값 `19`) : 생성할 비디오 프레임 수 | |
| num_inference_steps (`int`, *선택 사항*, 기본값 50) : 디노이징 단계의 수입니다. 디노이징 단계가 많을수록 일반적으로 추론 속도가 느려지는 대신 더 높은 품질의 이미지를 생성합니다. | |
| timesteps (`list[int]`, *선택 사항*) : `set_timesteps` 메서드에 `timesteps` 인수를 지원하는 스케줄러의 노이즈 제거 과정에 사용할 커스텀 타임스텝입니다. 정의되지 않은 경우, `num_inference_steps`가 전달될 때의 기본 동작이 사용됩니다. 내림차순으로 정렬되어 있어야 합니다. | |
| guidance_scale (`float`, 기본값 `4.5`) : [Classifier-Free Diffusion Guidance](https://huggingface.co/papers/2207.12598)에서 정의한 Guidance scale입니다. `guidance_scale`은 [Imagen Paper](https://huggingface.co/papers/2205.11487)의 2번 식의 `w`로 정의됩니다. `guidance_scale > 1`을 설정하여 Guidance scale을 활성화합니다. Guidance scale이 높을수록 `prompt` 텍스트와 밀접하게 연결된 이미지를 생성하도록 장려하지만, 일반적으로 이미지 품질이 낮아지는 대가를 치릅니다. | |
| num_videos_per_prompt (`int`, *선택 사항*, 기본값 1) : 프롬프트당 생성할 비디오의 수입니다. | |
| generator (`torch.Generator` 또는 `list[torch.Generator]`, *선택 사항*) : 생성을 결정적으로 만들기 위한 [torch generator](https://pytorch.org/docs/stable/generated/torch.Generator.html) 하나 또는 목록. | |
| latents (`torch.Tensor`, *선택 사항*) : 이미지 생성의 입력으로 사용할 가우시안 분포에서 샘플링된 사전 생성된 노이즈된 latents입니다. 동일한 생성을 다른 프롬프트로 조정하는 데 사용할 수 있습니다. 제공되지 않으면, 제공된 랜덤 `generator`를 사용하여 샘플링하여 latents 텐서가 생성됩니다. | |
| prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 텍스트 임베딩입니다. *예를 들어* 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 `prompt` 입력 인자에서 텍스트 임베딩이 생성됩니다. | |
| prompt_attention_mask (`torch.Tensor`, *선택 사항*) : 텍스트 임베딩을 위한 사전 생성된 어텐션 마스크입니다. | |
| negative_prompt_embeds (`torch.FloatTensor`, *선택*) : 미리 생성된 부정 텍스트 임베딩입니다. PixArt-Sigma의 경우 이 negative prompt는 ""여야 합니다. 제공되지 않으면 `negative_prompt` 입력 인수에서 negative_prompt_embeds가 생성됩니다. | |
| negative_prompt_attention_mask (`torch.FloatTensor`, *선택 사항*) : 부정 텍스트 임베딩에 사용할 사전 생성된 어텐션 마스크입니다. | |
| output_type (`str`, *선택 사항*, 기본값 `"pil"`) : 이미지 생성의 출력 형식입니다. [PIL](https://pillow.readthedocs.io/en/stable/): `PIL.Image.Image` 또는 `np.array` 중 하나를 선택합니다. | |
| return_dict (`bool`, *선택 사항*, 기본값 `True`) : 일반 튜플 대신 `~pipelines.mochi.MochiPipelineOutput`을 반환할지 여부. | |
| attention_kwargs (`dict`, *선택 사항*) : 지정된 경우 [diffusers.models.attention_processor](https://github.com/huggingface/diffusers/blob/main/src/diffusers/models/attention_processor.py)의 `self.processor` 아래에서 정의된 `AttentionProcessor`로 전달되는 kwargs 사전입니다. | |
| callback_on_step_end (`Callable`, *선택 사항*) : 추론 중 각 디노이징 단계의 끝에서 호출되는 함수입니다. 이 함수는 다음 인수를 받아 호출됩니다: `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` 기본값은 `256`) : `prompt`에 사용할 최대 시퀀스 길이. | |
| **반환값:** `~pipelines.mochi.MochiPipelineOutput` 또는 `tuple` | |
| `return_dict`가 `True`인 경우 `~pipelines.mochi.MochiPipelineOutput`가 반환되고, 그렇지 않으면 첫 번째 요소가 생성된 이미지의 목록인 `tuple`이 반환됩니다. | |
| 생성을 위해 파이프라인을 호출할 때 호출되는 함수. | |
| 예: | |
| ```py | |
| >>> import torch | |
| >>> from diffusers import MochiPipeline | |
| >>> from diffusers.utils import export_to_video | |
| >>> pipe = MochiPipeline.from_pretrained("genmo/mochi-1-preview", torch_dtype=torch.bfloat16) | |
| >>> pipe.enable_model_cpu_offload() | |
| >>> pipe.vae.enable_tiling() | |
| >>> prompt = "Close-up of a chameleon's eye, with its scaly skin changing color. Ultra high resolution 4k." | |
| >>> frames = pipe(prompt, num_inference_steps=28, guidance_scale=3.5).frames[0] | |
| >>> export_to_video(frames, "mochi.mp4") | |
| ``` | |
| #### encode_prompt[[diffusers.MochiPipeline.encode_prompt]] | |
| ```python | |
| encode_prompt(prompt: str | list[str], negative_prompt: str | list[str] | None = None, do_classifier_free_guidance: bool = True, num_videos_per_prompt: int = 1, prompt_embeds: typing.Optional[torch.Tensor] = None, negative_prompt_embeds: typing.Optional[torch.Tensor] = None, prompt_attention_mask: typing.Optional[torch.Tensor] = None, negative_prompt_attention_mask: typing.Optional[torch.Tensor] = None, max_sequence_length: int = 256, device: typing.Optional[torch.device] = None, dtype: typing.Optional[torch.dtype] = None) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/mochi/pipeline_mochi.py#L254) | |
| **매개변수:** | |
| 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 장치 | |
| prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 텍스트 임베딩입니다. *예를 들어* 프롬프트 가중치와 같은 텍스트 입력을 쉽게 조정하는 데 사용할 수 있습니다. 제공되지 않으면 `prompt` 입력 인자에서 텍스트 임베딩이 생성됩니다. | |
| negative_prompt_embeds (`torch.Tensor`, *선택 사항*) : 미리 생성된 부정 텍스트 임베딩입니다. 텍스트 입력을 쉽게 조정하는 데 사용할 수 있으며, *예를 들어* 프롬프트 가중치 설정에 활용할 수 있습니다. 제공되지 않으면 `negative_prompt` 입력 인수에서 negative_prompt_embeds가 생성됩니다. | |
| device : (`torch.device`, *선택 사항*): torch device | |
| dtype : (`torch.dtype`, *선택 사항*): torch dtype | |
| 프롬프트를 텍스트 인코더의 히든 상태로 인코딩합니다. | |
| ## MochiPipelineOutput[[diffusers.pipelines.mochi.pipeline_output.MochiPipelineOutput]] | |
| #### diffusers.pipelines.mochi.pipeline_output.MochiPipelineOutput[[diffusers.pipelines.mochi.pipeline_output.MochiPipelineOutput]] | |
| ```python | |
| diffusers.pipelines.mochi.pipeline_output.MochiPipelineOutput(frames: Tensor) | |
| ``` | |
| [소스](https://github.com/huggingface/diffusers/blob/main/src/diffusers/pipelines/mochi/pipeline_output.py#L9) | |
| **매개변수:** | |
| frames (`torch.Tensor`, `np.ndarray`, 또는 list[list[PIL.Image.Image]]) : 비디오 출력 목록 - `batch_size,` 길이의 중첩 목록일 수 있으며, 각 하위 목록에는 `num_frames.` 길이의 노이즈 제거된 PIL 이미지 시퀀스가 포함됩니다. 또한 `(batch_size, num_frames, channels, height, width)` 형상의 NumPy 배열 또는 Torch 텐서일 수도 있습니다. | |
| Mochi 파이프라인의 출력 클래스입니다. | |
Xet Storage Details
- Size:
- 24.2 kB
- Xet hash:
- 6e4b3ef860ebedb6ae73ba4fdf6c6a7f89f113f0ca274ab66a371053c86ddc0c
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.