GJuarez67 commited on
Commit
2af5027
·
verified ·
1 Parent(s): 193772b

Add app.py and requirements.txt

Browse files
Files changed (1) hide show
  1. requirements.txt +186 -1
requirements.txt CHANGED
@@ -1 +1,186 @@
1
- gradio>=4.0,<5.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ MODEL_INFO = {
4
+ "name": "MiniMax-H3-Fun-Controlnet-Union",
5
+ "author": "alibaba-pai",
6
+ "base_model": "MiniMaxAI/MiniMax-H3",
7
+ "description": (
8
+ "ControlNet-Union for MiniMax-H3 — a single checkpoint that conditions the "
9
+ "MiniMax-H3 video generator on Canny, Depth, HED, MLSD, or Pose control videos, "
10
+ "and also runs video inpainting. Trained with the VideoX-Fun pipeline."
11
+ ),
12
+ }
13
+
14
+ RESULTS = [
15
+ ("Canny", "A Tokyo street scene", "canny_tokyo_street"),
16
+ ("Depth", "An astronaut floating in space", "depth_astronaut"),
17
+ ("HED", "A T-Rex riding a BMX", "hed_trex_bmx"),
18
+ ("MLSD", "A village with straight-line architecture", "mlsd_village"),
19
+ ("Pose", "A dancer transformed into a flamenco dancer", "pose_dance"),
20
+ ]
21
+
22
+ ASSET_URL = "https://huggingface.co/alibaba-pai/MiniMax-H3-Fun-Controlnet-Union/resolve/main"
23
+ RESULT_URL = "https://huggingface.co/alibaba-pai/MiniMax-H3-Fun-Controlnet-Union/resolve/main/results"
24
+
25
+
26
+ def result_section(control_type, caption, key):
27
+ return gr.HTML(
28
+ f"""
29
+ <div style="display:flex; gap:12px; flex-wrap:wrap; margin:8px 0;">
30
+ <div style="flex:1; min-width:240px;">
31
+ <p style="font-weight:600; margin:0 0 4px;">Control — {control_type}</p>
32
+ <video src="{ASSET_URL}/asset/{key}.mp4"
33
+ width="100%" controls muted loop
34
+ style="border-radius:8px; background:#111;"></video>
35
+ <p style="font-size:0.8em; color:#888; margin:4px 0 0;">{caption}</p>
36
+ </div>
37
+ <div style="flex:1; min-width:240px;">
38
+ <p style="font-weight:600; margin:0 0 4px;">Output — MiniMax-H3 + ControlNet-Union</p>
39
+ <video src="{RESULT_URL}/{key}.mp4"
40
+ width="100%" controls muted loop
41
+ style="border-radius:8px; background:#111;"></video>
42
+ </div>
43
+ </div>
44
+ """
45
+ )
46
+
47
+
48
+ with gr.Blocks(
49
+ theme=gr.themes.Soft(),
50
+ title="MiniMax-H3-Fun-Controlnet-Union",
51
+ css="""
52
+ .model-header { text-align:center; padding:1.5rem 0 0.5rem; }
53
+ .model-header h1 { font-size:1.8rem; font-weight:700; }
54
+ .model-header .badge { display:inline-block; background:#6366f1; color:#fff;
55
+ padding:0.2rem 0.7rem; border-radius:999px; font-size:0.75rem; margin-left:0.5rem; }
56
+ video { box-shadow:0 4px 16px rgba(0,0,0,0.3); }
57
+ .section-title { font-size:1.1rem; font-weight:600; margin-bottom:0.5rem;
58
+ border-bottom:2px solid #e5e7eb; padding-bottom:0.3rem; }
59
+ .info-table td { padding:0.4rem 0.8rem; vertical-align:top; }
60
+ .info-table td:first-child { font-weight:600; white-space:nowrap; width:160px; }
61
+ """
62
+ ) as demo:
63
+ gr.HTML(
64
+ """
65
+ <div class="model-header">
66
+ <h1>MiniMax-H3-Fun-Controlnet-Union
67
+ <span class="badge">alibaba-pai</span>
68
+ </h1>
69
+ <p style="color:#666; margin-top:0.3rem;">
70
+ ControlNet-Union for <a href="https://huggingface.co/MiniMaxAI/MiniMax-H3" target="_blank">MiniMax-H3</a>
71
+ &middot; <a href="https://github.com/aigc-apps/VideoX-Fun" target="_blank">VideoX-Fun</a> pipeline
72
+ </p>
73
+ </div>
74
+ """
75
+ )
76
+
77
+ gr.Markdown("""
78
+ **MiniMax-H3-Fun-Controlnet-Union** is a single ControlNet-Union checkpoint for the
79
+ [MiniMax-H3](https://huggingface.co/MiniMaxAI/MiniMax-H3) video diffusion transformer.
80
+ One model handles **Canny, Depth, HED, MLSD, and Pose** control conditions for
81
+ video-to-video generation — no per-condition checkpoint switching — and also supports
82
+ video inpainting.
83
+
84
+ | File | Description |
85
+ |------|-------------|
86
+ | `MiniMax-H3-Fun-Controlnet-Union.safetensors` | Control branch weights (~6.8 GB): `control_proj_in` + 5 `control_blocks`. Loaded on top of the base MiniMax-H3 transformer. |
87
+ """)
88
+
89
+ with gr.Row():
90
+ with gr.Column(scale=1):
91
+ gr.Markdown("### Model Features")
92
+ gr.Markdown("""
93
+ - **Union control** — one checkpoint for Canny, Depth, HED, MLSD, and Pose.
94
+ - **5 control injection points** — layers 0, 10, 20, 30, 40 of the 50-block transformer.
95
+ - **Guidance-distilled** — run with `guidance_scale = 1.0`; one forward pass per step.
96
+ - **Inpainting** — control input widened to `control_in_dim = 49` (latent + masked latent + mask channels).
97
+ - **`control_context_scale`** — scales every control skip before adding to the main branch:
98
+ `1.0` = strongest control, `0.0` = control branch off.
99
+ - **Frame snap** — frame count snaps to the largest `17*n + 5` the video VAE can decode
100
+ (duration capped at 15 s), canvas keeps the control video's aspect ratio.
101
+ """)
102
+ with gr.Column(scale=1):
103
+ gr.Markdown("### Inference Defaults")
104
+ gr.HTML(
105
+ """
106
+ <table class="info-table">
107
+ <tr><td>num_inference_steps</td><td>40</td></tr>
108
+ <tr><td>guidance_scale</td><td>1.0 (guidance-distilled)</td></tr>
109
+ <tr><td>control_context_scale</td><td>1.00</td></tr>
110
+ <tr><td>seed</td><td>43</td></tr>
111
+ <tr><td>fps</td><td>24</td></tr>
112
+ </table>
113
+ """
114
+ )
115
+
116
+ gr.Markdown("---")
117
+ gr.Markdown("### Results — All 5 Control Conditions")
118
+ gr.Markdown(
119
+ "All samples generated with `num_inference_steps=40`, `guidance_scale=1.0`, "
120
+ "`control_context_scale=1.00`, seed 43."
121
+ )
122
+
123
+ for control_type, caption, key in RESULTS:
124
+ result_section(control_type, caption, key)
125
+
126
+ gr.Markdown("---")
127
+ gr.Markdown("### How to Run Inference")
128
+ gr.Markdown(
129
+ """
130
+ 1. Clone the [VideoX-Fun](https://github.com/aigc-apps/VideoX-Fun) repository.
131
+ 2. Download the base **MiniMax-H3** model and this ControlNet-Union checkpoint.
132
+ 3. Place them under `models/Diffusion_Transformer/`:
133
+
134
+ ```
135
+ models/
136
+ └── Diffusion_Transformer/
137
+ ├── MiniMax-H3/ # base transformer (~62 GB)
138
+ └── MiniMax-H3-Fun-Controlnet-Union/
139
+ └── MiniMax-H3-Fun-Controlnet-Union.safetensors # control branch (~6.8 GB)
140
+ ```
141
+
142
+ 4. Edit the variables at the top of `examples/minimax_h3_fun/predict_v2v_control.py`:
143
+
144
+ ```python
145
+ model_name = "models/Diffusion_Transformer/MiniMax-H3"
146
+ config_path = "config/minimax_h3/minimax_h3_control.yaml"
147
+ transformer_path = "models/Diffusion_Transformer/MiniMax-H3-Fun-Controlnet-Union/MiniMax-H3-Fun-Controlnet-Union.safetensors"
148
+ control_video = "your_control_video.mp4"
149
+ prompt = "your prompt"
150
+ ```
151
+
152
+ 5. Run: `python examples/minimax_h3_fun/predict_v2v_control.py`
153
+
154
+ **Important notes:**
155
+ - `config_path` must use the exact trained layout: `control_blocks_places: [0, 10, 20, 30, 40]`,
156
+ `control_in_dim: 49`, `control_apply_audio: false`.
157
+ - Keep `guidance_scale = 1.0` — higher values apply guidance twice and degrade output.
158
+ - The control checkpoint carries **only the control branch**; the base MiniMax-H3 weights
159
+ must be present at `model_name`.
160
+ - **Memory:** transformer (~62 GB) + Qwen3-VL text encoder (~62 GB) do **not** fit a single
161
+ 80 GB GPU fully loaded. Use `model_group_offload` (fastest) or `model_cpu_offload_and_qfloat8`.
162
+ """
163
+ )
164
+
165
+ gr.Markdown("---")
166
+ gr.Markdown("### Links")
167
+ gr.HTML(
168
+ """
169
+ <p>
170
+ <a href="https://huggingface.co/alibaba-pai/MiniMax-H3-Fun-Controlnet-Union" target="_blank">
171
+ Model page on Hugging Face
172
+ </a>
173
+ &middot;
174
+ <a href="https://huggingface.co/MiniMaxAI/MiniMax-H3" target="_blank">
175
+ MiniMax-H3 base model
176
+ </a>
177
+ &middot;
178
+ <a href="https://github.com/aigc-apps/VideoX-Fun" target="_blank">
179
+ VideoX-Fun repository
180
+ </a>
181
+ </p>
182
+ """
183
+ )
184
+
185
+ if __name__ == "__main__":
186
+ demo.launch(server_name="0.0.0.0", server_port=7860)