diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2022-10-03 04:54:57 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-10-03 04:54:57 +0000 |
commit | 3fac3764b3fadce828ceffdb7dea2be51bbe7da7 (patch) | |
tree | b2307b40ed86dc825d9954f470a2b1663dfed30a /modules/swinir_model.py | |
parent | 32edf1732f27a1fad5133667c22b948adda1b070 (diff) | |
parent | 4c2eccf8e96825333ed400f8a8a2be78141ed8ec (diff) | |
download | stable-diffusion-webui-gfx803-3fac3764b3fadce828ceffdb7dea2be51bbe7da7.tar.gz stable-diffusion-webui-gfx803-3fac3764b3fadce828ceffdb7dea2be51bbe7da7.tar.bz2 stable-diffusion-webui-gfx803-3fac3764b3fadce828ceffdb7dea2be51bbe7da7.zip |
Merge branch 'master' into #1484_fix_empty_styles_pattern
Diffstat (limited to 'modules/swinir_model.py')
-rw-r--r-- | modules/swinir_model.py | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/modules/swinir_model.py b/modules/swinir_model.py index 41fda5a7..9bd454c6 100644 --- a/modules/swinir_model.py +++ b/modules/swinir_model.py @@ -5,6 +5,7 @@ import numpy as np import torch from PIL import Image from basicsr.utils.download_util import load_file_from_url +from tqdm import tqdm from modules import modelloader from modules.paths import models_path @@ -122,18 +123,20 @@ def inference(img, model, tile, tile_overlap, window_size, scale): E = torch.zeros(b, c, h * sf, w * sf, dtype=torch.half, device=device).type_as(img) W = torch.zeros_like(E, dtype=torch.half, device=device) - for h_idx in h_idx_list: - for w_idx in w_idx_list: - in_patch = img[..., h_idx: h_idx + tile, w_idx: w_idx + tile] - out_patch = model(in_patch) - out_patch_mask = torch.ones_like(out_patch) - - E[ - ..., h_idx * sf: (h_idx + tile) * sf, w_idx * sf: (w_idx + tile) * sf - ].add_(out_patch) - W[ - ..., h_idx * sf: (h_idx + tile) * sf, w_idx * sf: (w_idx + tile) * sf - ].add_(out_patch_mask) + with tqdm(total=len(h_idx_list) * len(w_idx_list), desc="SwinIR tiles") as pbar: + for h_idx in h_idx_list: + for w_idx in w_idx_list: + in_patch = img[..., h_idx: h_idx + tile, w_idx: w_idx + tile] + out_patch = model(in_patch) + out_patch_mask = torch.ones_like(out_patch) + + E[ + ..., h_idx * sf: (h_idx + tile) * sf, w_idx * sf: (w_idx + tile) * sf + ].add_(out_patch) + W[ + ..., h_idx * sf: (h_idx + tile) * sf, w_idx * sf: (w_idx + tile) * sf + ].add_(out_patch_mask) + pbar.update(1) output = E.div_(W) return output |