From 89102f76dc5108ede14bd7351a61a552ac13cbb2 Mon Sep 17 00:00:00 2001 From: Jaret Burkett Date: Wed, 19 Aug 2026 13:32:06 -0600 Subject: [PATCH] Allow user to pick if reference images are sent in the image or video reference stream for Hidream H3 ref2va --- .../diffusion_models/minimax_h3/minimax_h3.py | 132 +++++++++++++++--- .../minimax_h3/src/ref_video_cache.py | 17 +++ ui/src/app/jobs/new/options.tsx | 56 +++++++- version.py | 2 +- 4 files changed, 177 insertions(+), 30 deletions(-) diff --git a/extensions_built_in/diffusion_models/minimax_h3/minimax_h3.py b/extensions_built_in/diffusion_models/minimax_h3/minimax_h3.py index 1e3820b..358b0e2 100644 --- a/extensions_built_in/diffusion_models/minimax_h3/minimax_h3.py +++ b/extensions_built_in/diffusion_models/minimax_h3/minimax_h3.py @@ -77,7 +77,12 @@ from .src.packing import ( unpatchify_video_tokens, ) from .src.pipeline import MiniMaxH3Pipeline -from .src.ref_video_cache import load_ref_video_latent, load_video_ref_for_te +from .src.ref_video_cache import ( + load_ref_video_latent, + load_video_ref_for_te, + ref_frame_indices, + static_image_video_ref, +) from .src.text_encoder import ( TEXT_ENCODER_LAYER, VideoRef, @@ -656,6 +661,12 @@ class MinimaxH3Model(BaseModel): # ------------------------------------------------------------------ # Text conditioning # ------------------------------------------------------------------ + def _present_image_control(self, image: Image.Image): + """Hook: how a control IMAGE enters the Qwen3-VL presentation. The + default is a plain ```` image; ref2va can turn it into a + static video reference (``image_refs_as_video``).""" + return image + def get_prompt_embeds(self, prompt, control_images=None) -> AdvancedPromptEmbeds: if isinstance(prompt, str): prompt = [prompt] @@ -681,7 +692,9 @@ class MinimaxH3Model(BaseModel): img = img[0] arr = (img.float().clamp(0, 1) * 255).round().to(torch.uint8) pil_images.append( - Image.fromarray(arr.permute(1, 2, 0).cpu().numpy()) + self._present_image_control( + Image.fromarray(arr.permute(1, 2, 0).cpu().numpy()) + ) ) elif isinstance(img, str): # a control VIDEO path: 2 fps timestamped presentation over @@ -1241,10 +1254,40 @@ class MinimaxH3Ref2VAModel(MinimaxH3Model): clock by 1.0. At sampling, ctrl images are ALWAYS references, never first frames. + + ``model_kwargs.image_refs_as_video`` (default off) routes still-image + references through the VIDEO reference path instead: the image is held + for ``image_ref_video_frames`` frames (17n+5, default 5) as a silent + static clip — video sizing (true area match), multi-frame latent block, + temporal-span rotary advance, and a ``