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
| #!/usr/bin/env python3 | |
| from __future__ import annotations | |
| import argparse | |
| from contextlib import contextmanager | |
| import html | |
| import os | |
| import subprocess | |
| from pathlib import Path | |
| from typing import Iterator | |
| import uuid | |
| def atomic_media_output(output: Path) -> Iterator[Path]: | |
| output.parent.mkdir(parents=True, exist_ok=True) | |
| partial = output.with_name( | |
| f"{output.stem}.partial-{os.getpid()}-{uuid.uuid4().hex}{output.suffix}" | |
| ) | |
| try: | |
| yield partial | |
| with partial.open("rb") as handle: | |
| os.fsync(handle.fileno()) | |
| os.replace(partial, output) | |
| finally: | |
| partial.unlink(missing_ok=True) | |
| def hevc_command(source: Path, output: Path) -> list[str]: | |
| return [ | |
| "ffmpeg", | |
| "-y", | |
| "-i", | |
| str(source), | |
| "-map", | |
| "0:v:0", | |
| "-map", | |
| "0:a:0?", | |
| "-c:v", | |
| "libx265", | |
| "-tag:v", | |
| "hvc1", | |
| "-pix_fmt", | |
| "yuv420p", | |
| "-preset", | |
| "medium", | |
| "-crf", | |
| "24", | |
| "-c:a", | |
| "copy", | |
| "-movflags", | |
| "+faststart", | |
| str(output), | |
| ] | |
| def h264_command(source: Path, output: Path) -> list[str]: | |
| return [ | |
| "ffmpeg", | |
| "-y", | |
| "-i", | |
| str(source), | |
| "-map", | |
| "0:v:0", | |
| "-map", | |
| "0:a:0?", | |
| "-c:v", | |
| "libx264", | |
| "-pix_fmt", | |
| "yuv420p", | |
| "-preset", | |
| "medium", | |
| "-crf", | |
| "20", | |
| "-c:a", | |
| "copy", | |
| "-movflags", | |
| "+faststart", | |
| str(output), | |
| ] | |
| def embedded_video_html(*, repo_id: str, stem: str, title: str) -> str: | |
| base = f"https://huggingface.co/{repo_id}/resolve/main/examples" | |
| label = html.escape(title, quote=True) | |
| hevc = html.escape(f"{base}/hevc/{stem}.mp4", quote=True) | |
| h264 = html.escape(f"{base}/h264/{stem}.mp4", quote=True) | |
| return ( | |
| f'<video controls playsinline preload="metadata" width="608" aria-label="{label}">\n' | |
| f' <source src="{hevc}" type="video/mp4; codecs="hvc1"">\n' | |
| f' <source src="{h264}" type="video/mp4">\n' | |
| f' <a href="{h264}">{label} MP4</a>\n' | |
| "</video>" | |
| ) | |
| def main() -> int: | |
| parser = argparse.ArgumentParser() | |
| parser.add_argument("--source", type=Path, required=True) | |
| parser.add_argument("--output", type=Path, required=True) | |
| args = parser.parse_args() | |
| with atomic_media_output(args.output) as partial: | |
| subprocess.run(hevc_command(args.source, partial), check=True) | |
| return 0 | |
| if __name__ == "__main__": | |
| raise SystemExit(main()) | |