From 70bd8843090936975533bd39cf40e6368aea1857 Mon Sep 17 00:00:00 2001 From: maybleMyers Date: Fri, 29 Aug 2025 04:35:48 -0700 Subject: [PATCH] fix radiance previews --- README.md | 2 ++ modules/sd_samplers_common.py | 12 +++++++++--- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3a6879a9..b8c303cd 100644 --- a/README.md +++ b/README.md @@ -49,6 +49,8 @@ Donate to Lodestone (training is bookoo expensive and crowdfunded): https://ko-f Discord: http://discord.gg/SQVcWVbqKx ## Changlog +8/29/2025 + Fixed previews w/ radiance chroma models, fixed memory management and offloading mechanisms for radiance. 8/28/2025 Added initial support for the radiance model class. 7/13/2025 diff --git a/modules/sd_samplers_common.py b/modules/sd_samplers_common.py index 065eb714..cda30052 100644 --- a/modules/sd_samplers_common.py +++ b/modules/sd_samplers_common.py @@ -37,7 +37,15 @@ approximation_indexes = {"Full": 0, "Approx NN": 1, "Approx cheap": 2, "TAESD": def samples_to_images_tensor(sample, approximation=None, model=None): - """Transforms 4-channel latent space images into 3-channel RGB image tensors, with values in range [-1, 1].""" + """Transforms latent/pixel space tensors into RGB image tensors, with values in range [-1, 1].""" + + if model is None: + model = shared.sd_model + + # Handle ChromaDCT models that work in pixel space + if hasattr(model, '__class__') and 'ChromaDCT' in model.__class__.__name__: + # ChromaDCT outputs are already in pixel space (B, 3, H, W) with range [-1, 1] + return sample.clamp(-1.0, 1.0) if approximation is None or (shared.state.interrupted and opts.live_preview_fast_interrupt): approximation = approximation_indexes.get(opts.show_progress_type, 0) @@ -60,8 +68,6 @@ def samples_to_images_tensor(sample, approximation=None, model=None): x_sample = m(sample.to(devices.device, devices.dtype)).detach() x_sample = x_sample * 2 - 1 else: - if model is None: - model = shared.sd_model x_sample = model.decode_first_stage(sample) return x_sample