Update custom-hires-fix-mod-for-automatic1111-2.9/scripts/custom_hires_fix.py
Browse files
custom-hires-fix-mod-for-automatic1111-2.9/scripts/custom_hires_fix.py
CHANGED
|
@@ -2454,12 +2454,17 @@ class CustomHiresFix(scripts.Script):
|
|
| 2454 |
else:
|
| 2455 |
_, _, w2d = cached
|
| 2456 |
|
| 2457 |
-
|
| 2458 |
-
|
| 2459 |
-
|
| 2460 |
-
|
| 2461 |
-
|
| 2462 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2463 |
|
| 2464 |
weight = np.clip(weight, 1e-6, None)
|
| 2465 |
out = (accum / weight[..., None]).astype(np.uint8)
|
|
|
|
| 2454 |
else:
|
| 2455 |
_, _, w2d = cached
|
| 2456 |
|
| 2457 |
+
# Клауним координаты в пределах полотна и при необходимости режем тайл/окно
|
| 2458 |
+
y_to = min(oy + uh, TH)
|
| 2459 |
+
x_to = min(ox + uw, TW)
|
| 2460 |
+
crop_h = y_to - oy
|
| 2461 |
+
crop_w = x_to - ox
|
| 2462 |
+
if crop_h <= 0 or crop_w <= 0:
|
| 2463 |
+
# Тайл полностью вне холста (защита от редких погрешностей округления)
|
| 2464 |
+
continue
|
| 2465 |
+
# Аккумулируем только видимую часть тайла и соответствующее окно весов
|
| 2466 |
+
accum[oy:y_to, ox:x_to, :] += up_np[:crop_h, :crop_w, :] * w2d[:crop_h, :crop_w][..., None]
|
| 2467 |
+
weight[oy:y_to, ox:x_to] += w2d[:crop_h, :crop_w]
|
| 2468 |
|
| 2469 |
weight = np.clip(weight, 1e-6, None)
|
| 2470 |
out = (accum / weight[..., None]).astype(np.uint8)
|