Instructions to use HanLiii/mochi-1-preview-diffusers with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use HanLiii/mochi-1-preview-diffusers with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("HanLiii/mochi-1-preview-diffusers", dtype=torch.bfloat16, device_map="cuda") prompt = "Astronaut in a jungle, cold color palette, muted colors, detailed, 8k" image = pipe(prompt).images[0] - Notebooks
- Google Colab
- Kaggle
| license: apache-2.0 | |
| Diffusers formation for mochi-1-preview model. | |
| Use following code to inference | |
| ```bash | |
| import torch | |
| from diffusers import MochiPipeline | |
| from diffusers.utils import export_to_video | |
| pipe = MochiPipeline.from_pretrained('HanLiii/mochi-1-preview-diffusers', torch_dtype=torch.bfloat16) | |
| pipe.to("cuda") | |
| prompt = """ | |
| A hand with delicate fingers picks up a bright yellow lemon from a wooden bowl | |
| filled with lemons and sprigs of mint against a peach-colored background. | |
| The hand gently tosses the lemon up and catches it, showcasing its smooth texture. | |
| A beige string bag sits beside the bowl, adding a rustic touch to the scene. | |
| Additional lemons, one halved, are scattered around the base of the bowl. | |
| The even lighting enhances the vibrant colors and creates a fresh, | |
| inviting atmosphere. | |
| """ | |
| frames = pipe(prompt, | |
| num_inference_steps=64, | |
| guidance_scale=4.5, | |
| num_frames=61, | |
| generator=torch.Generator(device="cuda").manual_seed(42), | |
| ).frames[0] | |
| export_to_video(frames, "mochi_test.mp4") | |
| ``` | |
| bf16 diffusers version result(num_frames=61): | |
| <video controls autoplay src="https://cdn-uploads.huggingface.co/production/uploads/647d3f9683cdb93baf76f963/83xA9RMgF4Rx3M1P-deav.mp4"></video> | |
| github version result(num_frames=163): | |
| <video controls autoplay src="https://cdn-uploads.huggingface.co/production/uploads/647d3f9683cdb93baf76f963/OY29N7HQK2TVSZcAXQAPx.mp4"></video> | |
| --- | |
| license: apache-2.0 | |
| --- |