alexnasa commited on
Commit
584c78f
·
verified ·
1 Parent(s): 7f41dca

Update pipelines/pipeline_seesr.py

Browse files
Files changed (1) hide show
  1. pipelines/pipeline_seesr.py +12 -2
pipelines/pipeline_seesr.py CHANGED
@@ -1237,9 +1237,19 @@ class StableDiffusionControlNetPipeline(DiffusionPipeline, TextualInversionLoade
1237
  alpha_t = self.scheduler.alphas_cumprod[t].sqrt()
1238
  sigma_t = beta_t.sqrt()
1239
  x0_pred = (latents - sigma_t * noise_pred) / alpha_t
1240
-
 
 
 
 
 
 
 
 
 
 
1241
  # 3) Apply KDE steering
1242
- m_shift = kde_grad(x0_pred)
1243
  delta_t = gamma_0 * (1 - i / (len(timesteps) - 1))
1244
  x0_steer = x0_pred + delta_t * m_shift
1245
 
 
1237
  alpha_t = self.scheduler.alphas_cumprod[t].sqrt()
1238
  sigma_t = beta_t.sqrt()
1239
  x0_pred = (latents - sigma_t * noise_pred) / alpha_t
1240
+
1241
+ _, _, H, W = x0_pred.shape
1242
+ # pick the largest patch_size in {4,8,16,32} that divides both H and W
1243
+ for ps in (32,16,8,4):
1244
+ if H % ps == 0 and W % ps == 0:
1245
+ patch_size = ps
1246
+ break
1247
+ else:
1248
+ # fall back if none match:
1249
+ patch_size = 4
1250
+
1251
  # 3) Apply KDE steering
1252
+ m_shift = kde_grad(x0_pred, patch_size=patch_size, bandwidth=0.1)
1253
  delta_t = gamma_0 * (1 - i / (len(timesteps) - 1))
1254
  x0_steer = x0_pred + delta_t * m_shift
1255