Instructions to use MATLOWAI/MiniMax-H3-Variable-Clock with libraries, inference providers, notebooks, and local apps. Follow these links to get started.
- Inference
- Notebooks
- Google Colab
- Kaggle
Download workflows/build_workflows.py from MATLOWAI/MiniMax-H3-Variable-Clock: direct link, hf CLI and curl.
- Browser
- Download file 6.22 kB
-
https://huggingface.co/MATLOWAI/MiniMax-H3-Variable-Clock/resolve/main/workflows/build_workflows.py
- Command line
-
hf download hf://MATLOWAI/MiniMax-H3-Variable-Clock/workflows/build_workflows.py
-
curl -L -o build_workflows.py https://huggingface.co/MATLOWAI/MiniMax-H3-Variable-Clock/resolve/main/workflows/build_workflows.py
6.22 kB
| """Builds the ComfyUI API workflows for the H3 variable-clock LoRA (run from this folder). | |
| source_generation.api.json stock H3 text-to-video at normal speed (the stage 2 input) | |
| stage1_t2v_clock.api.json text-to-video on a variable clock: LoRA + H3 True Clock (keep_fine_bands 2) | |
| stage2_derope_clock.api.json de-rope (time smear -> partial denoise -> exact recover) with the clock + LoRA | |
| Needs ComfyUI with the core MiniMax-H3 nodes and ComfyUI-MAINodes with H3 True Clock's keep_fine_bands input. | |
| """ | |
| import json | |
| from pathlib import Path | |
| HERE = Path(__file__).resolve().parent | |
| PROMPT = (HERE.parent / "assets" / "punching_long_prompt.txt").read_text().strip() | |
| CLOCK = json.loads((HERE.parent / "clock_maps" / "eval_option1_long124_hold_map.json").read_text())["hold_map_used"] | |
| HOLD_MAP = json.dumps({"holds": CLOCK, "world_len": len(CLOCK)}) # MAINodes hold-map format | |
| UNET = "minimax_h3/minimax_h3_fl2va_pruned_int8_convrot.safetensors" | |
| CLIP = "minimax_h3/qwen3vl_32b_minimax_h3_nvfp4_awq.safetensors" | |
| VAE = "minimax_h3/minimax_h3_video_vae_fp16.safetensors" | |
| LORA = "minimax_h3_variable_clock/minimax_h3_variable_clock_runf_step2000_r16.safetensors" | |
| W, H, LEN, SEED, STEPS = 1344, 768, 124, 20260923, 20 | |
| def base(lora): | |
| g = { | |
| "1": {"class_type": "UNETLoader", "inputs": {"unet_name": UNET, "weight_dtype": "default"}}, | |
| "2": {"class_type": "CLIPLoader", "inputs": {"clip_name": CLIP, "type": "minimax", "device": "default"}}, | |
| "3": {"class_type": "VAELoader", "inputs": {"vae_name": VAE}}, | |
| "10": {"class_type": "MiniMaxH3ImageToVideo", "inputs": {"clip": ["2", 0], "vae": ["3", 0], "prompt": PROMPT, | |
| "width": W, "height": H, "length": LEN}}, | |
| "20": {"class_type": "KSamplerSelect", "inputs": {"sampler_name": "euler"}}, | |
| "21": {"class_type": "RandomNoise", "inputs": {"noise_seed": SEED}}, | |
| } | |
| model = ["1", 0] | |
| if lora: | |
| g["4"] = {"class_type": "LoraLoaderModelOnly", "inputs": {"model": model, "lora_name": LORA, "strength_model": 1.0}} | |
| model = ["4", 0] | |
| g["22"] = {"class_type": "BasicGuider", "inputs": {"model": model, "conditioning": ["10", 0]}} | |
| return g, model | |
| def save(g, node, images, prefix): | |
| g[node] = {"class_type": "CreateVideo", "inputs": {"images": images, "fps": 24}} | |
| g[str(int(node) + 1)] = {"class_type": "SaveVideo", "inputs": {"video": [node, 0], "format": "auto", "codec": "auto", | |
| "filename_prefix": prefix}} | |
| # 1) stock source at normal speed | |
| g, model = base(lora=False) | |
| g["23"] = {"class_type": "BasicScheduler", "inputs": {"model": model, "scheduler": "simple", "steps": STEPS, "denoise": 1.0}} | |
| g["30"] = {"class_type": "SamplerCustomAdvanced", "inputs": {"noise": ["21", 0], "guider": ["22", 0], "sampler": ["20", 0], | |
| "sigmas": ["23", 0], "latent_image": ["10", 1]}} | |
| g["31"] = {"class_type": "VAEDecode", "inputs": {"samples": ["30", 0], "vae": ["3", 0]}} | |
| save(g, "40", ["31", 0], "video/h3clock_source_native") | |
| (HERE / "source_generation.api.json").write_text(json.dumps(g, indent=1)) | |
| # 2) stage 1: text-to-video on the variable clock | |
| g, model = base(lora=True) | |
| g["5"] = {"class_type": "PrimitiveStringMultiline", "inputs": {"value": HOLD_MAP}} | |
| g["24"] = {"class_type": "H3TrueClock", "inputs": {"sampler": ["20", 0], "hold_map": ["5", 0], "keep_fine_bands": 2}} | |
| g["23"] = {"class_type": "BasicScheduler", "inputs": {"model": model, "scheduler": "simple", "steps": STEPS, "denoise": 1.0}} | |
| g["30"] = {"class_type": "SamplerCustomAdvanced", "inputs": {"noise": ["21", 0], "guider": ["22", 0], "sampler": ["24", 0], | |
| "sigmas": ["23", 0], "latent_image": ["10", 1]}} | |
| g["31"] = {"class_type": "VAEDecode", "inputs": {"samples": ["30", 0], "vae": ["3", 0]}} | |
| g["32"] = {"class_type": "H3ExactRecover", "inputs": {"images": ["31", 0], "hold_map": ["5", 0]}} | |
| save(g, "40", ["32", 0], "video/h3clock_stage1_kept") | |
| save(g, "42", ["31", 0], "video/h3clock_stage1_all_frames") | |
| (HERE / "stage1_t2v_clock.api.json").write_text(json.dumps(g, indent=1)) | |
| # 3) stage 2: de-rope with the clock enabled | |
| g, model = base(lora=True) | |
| g["5"] = {"class_type": "PrimitiveStringMultiline", "inputs": {"value": HOLD_MAP}} | |
| g["11"] = {"class_type": "LoadVideo", "inputs": {"file": "h3clock_source_native_00001_.mp4"}} | |
| g["12"] = {"class_type": "GetVideoComponents", "inputs": {"video": ["11", 0]}} | |
| g["13"] = {"class_type": "ImageScale", "inputs": {"image": ["12", 0], "upscale_method": "lanczos", "width": W, "height": H, | |
| "crop": "center"}} | |
| g["14"] = {"class_type": "ImageFromBatch", "inputs": {"image": ["13", 0], "batch_index": 20, "length": len(CLOCK)}} | |
| g["15"] = {"class_type": "H3TimeSmear", "inputs": {"images": ["14", 0], "dilation": 1, "hold_map": ["5", 0], "fps": 24, | |
| "expand_to_end": False}} | |
| g["16"] = {"class_type": "VAEEncode", "inputs": {"pixels": ["15", 0], "vae": ["3", 0]}} | |
| g["17"] = {"class_type": "H3V2VInit", "inputs": {"samples": ["16", 0]}} | |
| g["24"] = {"class_type": "H3TrueClock", "inputs": {"sampler": ["20", 0], "hold_map": ["15", 1], "keep_fine_bands": 2}} | |
| g["23"] = {"class_type": "H3InjectSchedule", "inputs": {"model": model, "scheduler": "simple", "total_steps": STEPS, | |
| "inject": 0.45, "preset": "custom"}} | |
| g["30"] = {"class_type": "SamplerCustomAdvanced", "inputs": {"noise": ["21", 0], "guider": ["22", 0], "sampler": ["24", 0], | |
| "sigmas": ["23", 0], "latent_image": ["17", 0]}} | |
| g["31"] = {"class_type": "VAEDecode", "inputs": {"samples": ["30", 0], "vae": ["3", 0]}} | |
| g["32"] = {"class_type": "H3ExactRecover", "inputs": {"images": ["31", 0], "hold_map": ["15", 1]}} | |
| save(g, "40", ["32", 0], "video/h3clock_stage2_kept") | |
| save(g, "42", ["31", 0], "video/h3clock_stage2_all_frames") | |
| (HERE / "stage2_derope_clock.api.json").write_text(json.dumps(g, indent=1)) | |
| print("wrote", sorted(p.name for p in HERE.glob("*.api.json"))) | |