Image-Text-to-Video
Diffusers
Safetensors
orbitquant
comfyui
w4
w4a4
native-w4a4-transformer-runtime
text-to-video
audio-video-generation
8-bit precision
Instructions to use WaveCut/MiniMax-H3-OrbitQuant-W4A4 with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Libraries
- Diffusers
How to use WaveCut/MiniMax-H3-OrbitQuant-W4A4 with Diffusers:
pip install -U diffusers transformers accelerate
import torch from diffusers import DiffusionPipeline # switch to "mps" for apple devices pipe = DiffusionPipeline.from_pretrained("WaveCut/MiniMax-H3-OrbitQuant-W4A4", 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
File size: 1,474 Bytes
fa2d87b | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 | #!/usr/bin/env python3
from __future__ import annotations
from pathlib import Path
from typing import Any
import torch
FORMAT_VERSION = 1
def prepare_inference_model(model: torch.nn.Module) -> torch.nn.Module:
return model.eval().requires_grad_(False)
def save_latent_bundle(
path: Path,
*,
video_latents: torch.Tensor,
audio_latents: torch.Tensor,
metadata: dict[str, Any],
) -> None:
if video_latents.ndim != 5 or video_latents.shape[0] != 1:
raise ValueError(
"video latents must have shape (1, channels, frames, height, width)"
)
if audio_latents.ndim != 3 or audio_latents.shape[0] != 2:
raise ValueError("audio latents must have shape (2, channels, samples)")
path.parent.mkdir(parents=True, exist_ok=True)
temporary = path.with_suffix(path.suffix + ".tmp")
torch.save(
{
"format_version": FORMAT_VERSION,
"metadata": dict(metadata),
"video_latents": video_latents.detach().to("cpu").contiguous(),
"audio_latents": audio_latents.detach().to("cpu").contiguous(),
},
temporary,
)
temporary.replace(path)
def load_latent_bundle(path: Path) -> dict[str, Any]:
payload = torch.load(path, map_location="cpu", weights_only=False)
if payload.get("format_version") != FORMAT_VERSION:
raise ValueError(f"unsupported latent bundle format: {payload.get('format_version')}")
return payload
|