--- license: other license_name: minimax-h3-community-license-agreement license_link: LICENSE base_model: MiniMaxAI/MiniMax-H3 base_model_relation: adapter pipeline_tag: image-text-to-video language: - en tags: - lora - video-generation - reference-to-video - token-pruning - distillation - minimax-h3 ---
You can run the video demo here. Other demos: H3 Image Demo.
Sequence-wise generators (MiniMax-H3 Ref2VA, MiniMax-H3-Image, Qwen-Image 2.1, FLUX 3 Image Klein) append every reference picture or video to the input token sequence, so the token cost grows sharply as more references are added. We propose **CodecOPSD** to prune the redundant condition tokens with a video codec, and we train a small LoRA on the kept tokens via on-policy self-distillation. On average, CodecOPSD drops about 70% of the condition tokens on MiniMax-H3 Ref2VA with almost unchanged quality and 1.87x faster denoising, and up to 8.4x faster with more conditions (three reference videos, higher-resolution references, more frames, and a higher drop rate). On MiniMax-H3-Image, it drops about 65% of the reference tokens and makes denoising about 2x faster. This repo holds the CodecOPSD LoRA for **MiniMax-H3 Ref2VA** (reference-to-video generation). ⭐ **If you like CodecOPSD, please help ⭐⭐star⭐⭐ the [GitHub repo](https://github.com/Kiteretsu77/CodecOPSD). Thanks!** 🤗 ## Model Variants | Variant | Base model | Task | Weights | Demo | |---|---|---|---|---| | **CodecOPSD-H3-Ref2VA** (this repo) | [MiniMax-H3](https://huggingface.co/MiniMaxAI/MiniMax-H3) Ref2VA | Reference-to-video generation | [HikariDawn/CodecOPSD-H3-Ref2VA](https://huggingface.co/HikariDawn/CodecOPSD-H3-Ref2VA) | [H3 Ref2VA Demo](https://huggingface.co/spaces/HikariDawn/CodecOPSD-H3-Ref2VA) | | **CodecOPSD-H3-Image** | [MiniMax-H3-Image](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image) | Reference-to-image generation | [HikariDawn/CodecOPSD-H3-Image](https://huggingface.co/HikariDawn/CodecOPSD-H3-Image) | [H3 Image Demo](https://huggingface.co/spaces/HikariDawn/CodecOPSD-H3-Image) | | CodecOPSD on Cosmos 3 Nano | Cosmos 3 Nano | | Coming soon | | | CodecOPSD on Qwen-Image 2.1 | Qwen-Image 2.1 | | Coming soon | | | CodecOPSD on FLUX 3 Image Klein | FLUX 3 Image Klein | | Coming soon | | ## Short Film **Robot versus Monster**: made with MiniMax-H3 Ref2VA + CodecOPSD in five generations, no Teacher run, no post-editing.Audio is available
Conditions of each part (hatched = tokens dropped by codec pruning):![]() Identity: mech, front −53% | ![]() Identity: mech, back −54% | ![]() Identity: monster −65% | ![]() Scene: street −18% | ![]() Scene: city from above −32% |
Output, part 1 | Greybox video −70% |
![]() First frame −13% | ![]() Last frame −16% | ![]() Thruster effect −87% |
Output, part 2 | Greybox video −79% |
![]() First frame −30% | ![]() Last frame −24% | ![]() Key pose: hand −52% | ![]() Particle effect −34% |
Output, part 3 | Greybox video −75% |
![]() First frame −23% | ![]() Last frame −23% |
Output, part 4 | Greybox video −72% |
![]() First frame −28% | ![]() Slash effect −62% | ![]() Wound, front −47% | ![]() Wound, back −54% |
Output, part 5 | Greybox video −70% |
![]() First frame −46% | ![]() Ring effect −82% | ![]() Wound, back −54% |
## Run it
Install the [CodecOPSD code](https://github.com/Kiteretsu77/CodecOPSD) and download the base models into `models/`:
```bash
git clone https://github.com/Kiteretsu77/CodecOPSD.git && cd CodecOPSD
pip install -e ".[app]"
python -m codecopsd.download minimax_h3_ref2va --no-examples
python app.py ref2va # Gradio demo
```
The CodecOPSD pipeline is a diffusers `DiffusionPipeline` on diffusers' own MiniMax-H3 modules, with codec pruning in
front of the transformer:
```python
import torch
from diffusers.utils import export_to_video
from codecopsd import MiniMaxH3CodecOPSDPipeline
from codecopsd.pipelines.minimax_h3_ref2va import load_reference
pipe = MiniMaxH3CodecOPSDPipeline.from_minimax_h3(
"models/MiniMax-H3-Ref2VA", text_encoder_fp8="fp8",
text_encoder_path="models/MiniMax-H3-ModelOpt-Mixed9-Dynamic-FP8/Ref2VA/text_encoder")
pipe.load_condition_lora("HikariDawn/CodecOPSD-H3-Ref2VA", weight_name="codecopsd_minimax_h3_ref2va.safetensors")
pipe.enable_model_cpu_offload()
video = pipe(
prompt="The golden retriever from