Model card
Browse files
README.md
CHANGED
|
@@ -1,3 +1,119 @@
|
|
| 1 |
---
|
| 2 |
-
license:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
---
|
| 2 |
+
license: other
|
| 3 |
+
license_name: minimax-h3-image-community-license-agreement
|
| 4 |
+
license_link: LICENSE
|
| 5 |
+
base_model: MiniMaxAI/MiniMax-H3-Image
|
| 6 |
+
base_model_relation: adapter
|
| 7 |
+
pipeline_tag: image-to-image
|
| 8 |
+
language:
|
| 9 |
+
- en
|
| 10 |
+
tags:
|
| 11 |
+
- lora
|
| 12 |
+
- image-generation
|
| 13 |
+
- reference-to-image
|
| 14 |
+
- token-pruning
|
| 15 |
+
- distillation
|
| 16 |
+
- minimax-h3
|
| 17 |
---
|
| 18 |
+
|
| 19 |
+
<div align="center">
|
| 20 |
+
<img width="100%" src="assets/codecopsd_header.gif" alt="CodecOPSD">
|
| 21 |
+
</div>
|
| 22 |
+
|
| 23 |
+
<p align="center">
|
| 24 |
+
<a href="https://github.com/Kiteretsu77/CodecOPSD" target="_blank"><img src="https://img.shields.io/badge/GitHub-181717?logo=github&logoColor=white" alt="GitHub"></a>
|
| 25 |
+
<a href="https://kiteretsu77.github.io/CodecOPSD_website/" target="_blank"><img src="https://img.shields.io/badge/Project%20Page-E91E63?logo=googlechrome&logoColor=white" alt="Project Page"></a>
|
| 26 |
+
<a href="#"><img src="https://img.shields.io/badge/arXiv-Paper%20(TODO)-b31b1b?logo=arxiv&logoColor=white" alt="Paper"></a>
|
| 27 |
+
<a href="#"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Space-Demo%20(TODO)-FF9D00" alt="Space"></a>
|
| 28 |
+
<a href="https://huggingface.co/HikariDawn/CodecOPSD-H3-Ref2VA"><img src="https://img.shields.io/badge/%F0%9F%A4%97%20Model-CodecOPSD--H3--Ref2VA-FFD21E" alt="CodecOPSD-H3-Ref2VA"></a>
|
| 29 |
+
<a href="LICENSE"><img src="https://img.shields.io/badge/LICENSE-4CAF50?logo=creativecommons&logoColor=white" alt="LICENSE"></a>
|
| 30 |
+
</p>
|
| 31 |
+
|
| 32 |
+
# CodecOPSD-H3-Image
|
| 33 |
+
|
| 34 |
+
**On-Policy Codec Distillation for Efficient All-in-One Video Generation**
|
| 35 |
+
|
| 36 |
+
Sequence-wise generators (MiniMax-H3 Ref2VA, MiniMax-H3-Image, Qwen-Image 2.1, FLUX 3 Image Klein) append every
|
| 37 |
+
reference picture or video to the input token sequence, so the token cost grows sharply as more references are added.
|
| 38 |
+
|
| 39 |
+
We propose **CodecOPSD** to prune the redundant condition tokens with a video codec, and we train a small LoRA on the
|
| 40 |
+
kept tokens via on-policy self-distillation.
|
| 41 |
+
|
| 42 |
+
On average, CodecOPSD drops about 70% of the condition tokens on MiniMax-H3 Ref2VA with almost unchanged quality and
|
| 43 |
+
1.87x faster denoising, and up to 8.4x faster with more conditions (three reference videos, higher-resolution
|
| 44 |
+
references, more frames, and a higher drop rate).
|
| 45 |
+
|
| 46 |
+
On MiniMax-H3-Image, it drops about 65% of the reference tokens and makes denoising about 2x faster.
|
| 47 |
+
|
| 48 |
+
This repo holds the CodecOPSD LoRA for **MiniMax-H3-Image** (reference-to-image generation).
|
| 49 |
+
|
| 50 |
+
⭐ **If you like CodecOPSD, please help ⭐⭐star⭐⭐ the [GitHub repo](https://github.com/Kiteretsu77/CodecOPSD). Thanks!** 🤗
|
| 51 |
+
|
| 52 |
+
## Model Variants
|
| 53 |
+
|
| 54 |
+
| Variant | Base model | Task | Weights |
|
| 55 |
+
|---|---|---|---|
|
| 56 |
+
| **CodecOPSD-H3-Ref2VA** | [MiniMax-H3](https://huggingface.co/MiniMaxAI/MiniMax-H3) Ref2VA | Reference-to-video generation | [HikariDawn/CodecOPSD-H3-Ref2VA](https://huggingface.co/HikariDawn/CodecOPSD-H3-Ref2VA) |
|
| 57 |
+
| **CodecOPSD-H3-Image** (this repo) | [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) |
|
| 58 |
+
| CodecOPSD on Cosmos 3 Nano | Cosmos 3 Nano | | Coming soon |
|
| 59 |
+
| CodecOPSD on Qwen-Image 2.1 | Qwen-Image 2.1 | | Coming soon |
|
| 60 |
+
| CodecOPSD on FLUX 3 Image Klein | FLUX 3 Image Klein | | Coming soon |
|
| 61 |
+
|
| 62 |
+
## Gallery
|
| 63 |
+
|
| 64 |
+
<a href="https://kiteretsu77.github.io/CodecOPSD_website/#gallery-h3img"><img src="assets/gallery_image.jpg" width="100%" alt="CodecOPSD MiniMax-H3-Image gallery"></a>
|
| 65 |
+
|
| 66 |
+
Click the gallery to open it on the [project page](https://kiteretsu77.github.io/CodecOPSD_website/#gallery-h3img).
|
| 67 |
+
|
| 68 |
+
## Run it
|
| 69 |
+
|
| 70 |
+
Install the [CodecOPSD code](https://github.com/Kiteretsu77/CodecOPSD) and download the base models into `models/`:
|
| 71 |
+
|
| 72 |
+
```bash
|
| 73 |
+
git clone https://github.com/Kiteretsu77/CodecOPSD.git && cd CodecOPSD
|
| 74 |
+
pip install -e ".[app]"
|
| 75 |
+
python -m codecopsd.download minimax_h3_image --no-examples
|
| 76 |
+
python app.py ref2image # Gradio demo
|
| 77 |
+
```
|
| 78 |
+
|
| 79 |
+
The CodecOPSD pipeline is a diffusers `DiffusionPipeline` on diffusers' own MiniMax-H3 modules, with codec pruning in
|
| 80 |
+
front of the transformer:
|
| 81 |
+
|
| 82 |
+
```python
|
| 83 |
+
import torch
|
| 84 |
+
from PIL import Image
|
| 85 |
+
from codecopsd import MiniMaxH3ImageCodecOPSDPipeline
|
| 86 |
+
|
| 87 |
+
pipe = MiniMaxH3ImageCodecOPSDPipeline.from_minimax_h3_image(
|
| 88 |
+
"models/MiniMax-H3-Image", text_encoder_fp8="fp8",
|
| 89 |
+
text_encoder_path="models/MiniMax-H3-ModelOpt-Mixed9-Dynamic-FP8/Ref2VA/text_encoder")
|
| 90 |
+
pipe.load_condition_lora("HikariDawn/CodecOPSD-H3-Image", weight_name="codecopsd_minimax_h3_image.safetensors")
|
| 91 |
+
pipe.enable_model_cpu_offload()
|
| 92 |
+
|
| 93 |
+
image = pipe(
|
| 94 |
+
prompt="Put the lamp <Picture 1> on the desk in <Picture 2>.",
|
| 95 |
+
images=[Image.open("lamp.jpg"), Image.open("desk.jpg")],
|
| 96 |
+
generator=torch.Generator().manual_seed(42),
|
| 97 |
+
).images[0]
|
| 98 |
+
image.save("output.png")
|
| 99 |
+
```
|
| 100 |
+
|
| 101 |
+
## Weights
|
| 102 |
+
|
| 103 |
+
| File | Base trunk | Format |
|
| 104 |
+
|---|---|---|
|
| 105 |
+
| `codecopsd_minimax_h3_image.safetensors` | MiniMax-H3-Image `transformer_diffusers` | FP32 LoRA, rank / alpha 128, 2.6 GB |
|
| 106 |
+
| `config.json` | | Base model, LoRA rank and alpha, version |
|
| 107 |
+
| `LICENSE`, `NOTICE` | | The MiniMax-H3-Image Community License Agreement and its required notice |
|
| 108 |
+
|
| 109 |
+
## License
|
| 110 |
+
|
| 111 |
+
These LoRA weights are Model Derivatives of MiniMax-H3-Image and are distributed under the
|
| 112 |
+
[MiniMax-H3-Image Community License Agreement](https://huggingface.co/MiniMaxAI/MiniMax-H3-Image/blob/492fd8c4eca666f1085f57e30738c1e0d86b3439/LICENSE).
|
| 113 |
+
|
| 114 |
+
See [NOTICE](NOTICE) for the required MiniMax notice and the CodecOPSD authors' copyright statement. The CodecOPSD code
|
| 115 |
+
is on [GitHub](https://github.com/Kiteretsu77/CodecOPSD) under its own license.
|
| 116 |
+
|
| 117 |
+
## Citation
|
| 118 |
+
|
| 119 |
+
TBD
|