From a3f98124ca07cc7146c74390eb424f40e80472d3 Mon Sep 17 00:00:00 2001 From: Adrien Toupet Date: Sun, 9 Nov 2025 12:26:18 -0500 Subject: [PATCH] Fix: Restore natural look for 7b model (v2.5.6) - Replace split-stack-mean with unflatten in unconcat_coalesce - Corrects computation order to eliminate plastic/high-specular artifacts - Maintains torch.compile compatibility (no .item() graph breaks) - Applied to both dit_3b and dit_7b models --- README.md | 4 +++- pyproject.toml | 2 +- src/models/dit_3b/na.py | 15 ++++++--------- src/models/dit_7b/na.py | 15 ++++++--------- 4 files changed, 16 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 629c789..bb9bc03 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,9 @@ We're actively working on improvements and new features. To stay informed: ## 🚀 Updates -**2025.11.09 - Version 2.5.5** +**2025.11.09 - Version 2.5.6** + +- 🎨 **Fix: Restored natural look for 7b model** - Corrected torch.compile optimization that was causing overly plastic/ high-specular appearance in upscaled videos with 7b model. - 💾 **Memory: Fixed RAM leak for long videos** - On-demand reconstruction with lightweight batch indices instead of storing full transformed videos, fixed release_tensor_memory to handle CPU/CUDA/MPS consistently, and refactored batch processing helpers diff --git a/pyproject.toml b/pyproject.toml index 35a3fa8..a0fb82c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,7 +1,7 @@ [project] name = "seedvr2_videoupscaler" description = "SeedVR2 official ComfyUI integration: ByteDance-Seed's one-step diffusion-based video/image upscaling with memory-efficient inference" -version = "2.5.5" +version = "2.5.6" authors = [ {name = "numz"}, {name = "adrientoupet"} diff --git a/src/models/dit_3b/na.py b/src/models/dit_3b/na.py index dd1bf55..26f1795 100644 --- a/src/models/dit_3b/na.py +++ b/src/models/dit_3b/na.py @@ -400,22 +400,19 @@ def repeat_concat_idx( The text features appear multiple times (once per window) and need to be averaged to produce a single set of text features. - COMPILE OPTIMIZATION: Uses split-stack-mean instead of reshape to avoid .item() + COMPILE OPTIMIZATION: Uses unflatten with tensor dims (compile-friendly) """ vid_out, txt_out = all[src_idx].split([len(vid_idx), txt_idx_len]) - # Coalesce repeated text using pure tensor operations (no .item()) + # Coalesce repeated text using unflatten and mean txt_splits = _tensor_split(txt_out, repeat_txt_len, dim=0) txt_out_coalesced = [] - for txt, base_len in zip(txt_splits, txt_len): + for txt in txt_splits: # txt has shape (base_len * num_repeats, *other_dims) - # Split into num_repeats equal pieces using tensor operations - split_lens = base_len.unsqueeze(0).repeat_interleave(num_repeats_tensor.squeeze()) - pieces = _tensor_split(txt, split_lens, dim=0) - # Stack and average across repetitions - txt_avg = torch.stack(pieces, dim=0).mean(0) - txt_out_coalesced.append(txt_avg) + # unflatten to (base_len, num_repeats, *other_dims) then average dim 1 + txt = txt.unflatten(0, (-1, num_repeats_tensor.squeeze())).mean(1) + txt_out_coalesced.append(txt) return vid_out, torch.cat(txt_out_coalesced) diff --git a/src/models/dit_7b/na.py b/src/models/dit_7b/na.py index dd1bf55..26f1795 100644 --- a/src/models/dit_7b/na.py +++ b/src/models/dit_7b/na.py @@ -400,22 +400,19 @@ def repeat_concat_idx( The text features appear multiple times (once per window) and need to be averaged to produce a single set of text features. - COMPILE OPTIMIZATION: Uses split-stack-mean instead of reshape to avoid .item() + COMPILE OPTIMIZATION: Uses unflatten with tensor dims (compile-friendly) """ vid_out, txt_out = all[src_idx].split([len(vid_idx), txt_idx_len]) - # Coalesce repeated text using pure tensor operations (no .item()) + # Coalesce repeated text using unflatten and mean txt_splits = _tensor_split(txt_out, repeat_txt_len, dim=0) txt_out_coalesced = [] - for txt, base_len in zip(txt_splits, txt_len): + for txt in txt_splits: # txt has shape (base_len * num_repeats, *other_dims) - # Split into num_repeats equal pieces using tensor operations - split_lens = base_len.unsqueeze(0).repeat_interleave(num_repeats_tensor.squeeze()) - pieces = _tensor_split(txt, split_lens, dim=0) - # Stack and average across repetitions - txt_avg = torch.stack(pieces, dim=0).mean(0) - txt_out_coalesced.append(txt_avg) + # unflatten to (base_len, num_repeats, *other_dims) then average dim 1 + txt = txt.unflatten(0, (-1, num_repeats_tensor.squeeze())).mean(1) + txt_out_coalesced.append(txt) return vid_out, torch.cat(txt_out_coalesced)