fix: restore model_hijack.clip after LDSR upscale

LDSR calls sd_hijack.model_hijack.hijack() on its own diffusion model,
which overwrites model_hijack.clip with the LDSR cond_stage_model (a
VQ-VAE autoencoder). After upscaling completes, clip remains set to
this wrong object, causing token counters to fail with:
  AttributeError: 'Identity' object has no attribute 'process_texts'

Save and restore model_hijack.clip around the upscale operation so the
original SD model's CLIP encoder is preserved.

Fixes #12942
pull/17357/head
Satish K C 2026-04-03 14:57:55 -05:00
parent 82a973c043
commit 61a91186e5
1 changed files with 3 additions and 0 deletions

View File

@ -104,6 +104,7 @@ class LDSR:
return logs
def super_resolution(self, image, steps=100, target_scale=2, half_attention=False):
previous_clip = sd_hijack.model_hijack.clip
model = self.load_model_from_config(half_attention)
# Run settings
@ -151,6 +152,8 @@ class LDSR:
gc.collect()
devices.torch_gc()
sd_hijack.model_hijack.clip = previous_clip
return a