From dd65ae570e142ce82dd74e6e8c966879536c0196 Mon Sep 17 00:00:00 2001 From: DN6 Date: Fri, 15 Nov 2024 17:04:56 +0530 Subject: [PATCH 1/2] update --- docs/source/en/api/pipelines/mochi.md | 44 ++++++++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/docs/source/en/api/pipelines/mochi.md b/docs/source/en/api/pipelines/mochi.md index f29297e5901c..a19783b91419 100644 --- a/docs/source/en/api/pipelines/mochi.md +++ b/docs/source/en/api/pipelines/mochi.md @@ -13,7 +13,7 @@ # limitations under the License. --> -# Mochi +# Mochi 1 Preview [Mochi 1 Preview](https://huggingface.co/genmo/mochi-1-preview) from Genmo. @@ -25,6 +25,48 @@ Make sure to check out the Schedulers [guide](../../using-diffusers/schedulers.m +## Generating videos with Mochi-1 Preview + +The following example will download the full precision `mochi-1-preview` weights and produce the highest quality results but will require at least 42GB VRAM to run. + +```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.enable_vae_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=84).frames[0] + +export_to_video(frames, "mochi.mp4", fps=30) +``` + +## Using a lower precision variant to save memory + +```python +import torch +from diffusers import MochiPipeline +from diffusers.utils import export_to_video + +pipe = MochiPipeline.from_pretrained("genmo/mochi-1-preview", variant="bf16", torch_dtype=torch.bfloat16) + +# Enable memory savings +pipe.enable_model_cpu_offload() +pipe.enable_vae_tiling() + +prompt = "Close-up of a chameleon's eye, with its scaly skin changing color. Ultra high resolution 4k." +frames = pipe(prompt, num_frames=84).frames[0] + +export_to_video(frames, "mochi.mp4", fps=30) +``` + ## MochiPipeline [[autodoc]] MochiPipeline From ee285964125af61c38d7133e885eff2ee0519eda Mon Sep 17 00:00:00 2001 From: DN6 Date: Fri, 15 Nov 2024 17:07:36 +0530 Subject: [PATCH 2/2] update --- docs/source/en/api/pipelines/mochi.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/source/en/api/pipelines/mochi.md b/docs/source/en/api/pipelines/mochi.md index a19783b91419..c9b0e2013429 100644 --- a/docs/source/en/api/pipelines/mochi.md +++ b/docs/source/en/api/pipelines/mochi.md @@ -50,6 +50,8 @@ export_to_video(frames, "mochi.mp4", fps=30) ## Using a lower precision variant to save memory +The following example will use the `bfloat16` variant of the model and requires 22GB VRAM to run. There is a slight drop in the quality of the generated video as a result. + ```python import torch from diffusers import MochiPipeline