Skip to content

Commit ceac205

Browse files
committed
resolved comments
1 parent c05661f commit ceac205

3 files changed

Lines changed: 49 additions & 12 deletions

File tree

src/maxdiffusion/configs/ltx2_3_video.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ lora_config: {
140140
# LTX-2 Latent Upsampler
141141
run_latent_upsampler: False
142142
upsampler_model_path: "Lightricks/LTX-2.3"
143+
# Following upsampler files are supported:
144+
# ltx-2.3-spatial-upscaler-x2-1.0.safetensors
145+
# ltx-2.3-spatial-upscaler-x2-1.1.safetensors
146+
# ltx-2.3-spatial-upscaler-x1.5-1.0.safetensors
147+
# ltx-2.3-temporal-upscaler-x2-1.0.safetensors
143148
upsampler_filename: "ltx-2.3-spatial-upscaler-x2-1.0.safetensors"
144149
upsampler_spatial_patch_size: 1
145150
upsampler_temporal_patch_size: 1

src/maxdiffusion/models/ltx2/ltx2_utils.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,28 @@
2626
from flax.traverse_util import unflatten_dict, flatten_dict
2727
from ..modeling_flax_pytorch_utils import (rename_key, rename_key_and_reshape_tensor, torch2jax, validate_flax_state_dict)
2828

29+
KNOWN_UPSAMPLER_CONFIGS = {
30+
"ltx-2.3-spatial-upscaler-x2-1.0.safetensors": {
31+
"spatial_upsample": True,
32+
"temporal_upsample": False,
33+
"rational_spatial_scale": None,
34+
},
35+
"ltx-2.3-spatial-upscaler-x2-1.1.safetensors": {
36+
"spatial_upsample": True,
37+
"temporal_upsample": False,
38+
"rational_spatial_scale": None,
39+
},
40+
"ltx-2.3-spatial-upscaler-x1.5-1.0.safetensors": {
41+
"spatial_upsample": True,
42+
"temporal_upsample": False,
43+
"rational_spatial_scale": 1.5,
44+
},
45+
"ltx-2.3-temporal-upscaler-x2-1.0.safetensors": {
46+
"spatial_upsample": False,
47+
"temporal_upsample": True,
48+
"rational_spatial_scale": None,
49+
},
50+
}
2951

3052
def _tuple_str_to_int(in_tuple):
3153
out_list = []

src/maxdiffusion/pipelines/ltx2/ltx2_pipeline.py

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
load_upsampler_weights,
4848
adain_filter_latent,
4949
tone_map_latents,
50+
KNOWN_UPSAMPLER_CONFIGS,
5051
)
5152
from ...models.ltx2.text_encoders.text_encoders_ltx2 import LTX2AudioVideoGemmaTextEncoder
5253
from ...video_processor import VideoProcessor
@@ -572,17 +573,26 @@ def load_upsampler(cls, devices_array: np.array, mesh: Mesh, rngs: nnx.Rngs, con
572573
mid_channels = upsampler_config.get("mid_channels", 1024)
573574

574575
if filename is not None:
575-
if "temporal" in filename:
576-
temporal_upsample = True
577-
spatial_upsample = False
578-
elif "spatial" in filename:
579-
spatial_upsample = True
580-
temporal_upsample = False
581-
582-
if "x1.5" in filename:
583-
rational_spatial_scale = 1.5
584-
elif "x2" in filename:
585-
rational_spatial_scale = None # Force fallback for x2
576+
if filename in KNOWN_UPSAMPLER_CONFIGS:
577+
mapped_config = KNOWN_UPSAMPLER_CONFIGS[filename]
578+
spatial_upsample = mapped_config.get("spatial_upsample", spatial_upsample)
579+
temporal_upsample = mapped_config.get("temporal_upsample", temporal_upsample)
580+
rational_spatial_scale = mapped_config.get("rational_spatial_scale", rational_spatial_scale)
581+
else:
582+
max_logging.log(
583+
f"Warning: Filename '{filename}' not in KNOWN_UPSAMPLER_CONFIGS, falling back to heuristic parsing."
584+
)
585+
if "temporal" in filename:
586+
temporal_upsample = True
587+
spatial_upsample = False
588+
elif "spatial" in filename:
589+
spatial_upsample = True
590+
temporal_upsample = False
591+
592+
if "x1.5" in filename:
593+
rational_spatial_scale = 1.5
594+
elif "x2" in filename:
595+
rational_spatial_scale = None # Force fallback for x2
586596

587597
max_logging.log(
588598
f"Upsampler config inferred: spatial={spatial_upsample}, temporal={temporal_upsample}, scale={rational_spatial_scale}, mid_channels={mid_channels}"
@@ -1315,7 +1325,7 @@ def __call__(
13151325
audio_channels = (
13161326
self.audio_vae.config.latent_channels
13171327
if hasattr(self.audio_vae, "config") and hasattr(self.audio_vae.config, "latent_channels")
1318-
else 128
1328+
else 8
13191329
)
13201330

13211331
duration_s = num_frames / frame_rate

0 commit comments

Comments
 (0)