aboutsummaryrefslogtreecommitdiffstats
path: root/modules/upscaler_utils.py
diff options
context:
space:
mode:
authorAarni Koskela <akx@iki.fi>2023-12-30 22:20:30 +0000
committerAarni Koskela <akx@iki.fi>2023-12-31 11:22:43 +0000
commit5768afc776a66bb94e77a9c1daebeea58fa731d5 (patch)
tree06c015a95076b2de579a72750aa7862a9615ed09 /modules/upscaler_utils.py
parenta84e842189f5599fd354147f72d1a9b9ed0716c8 (diff)
downloadstable-diffusion-webui-gfx803-5768afc776a66bb94e77a9c1daebeea58fa731d5.tar.gz
stable-diffusion-webui-gfx803-5768afc776a66bb94e77a9c1daebeea58fa731d5.tar.bz2
stable-diffusion-webui-gfx803-5768afc776a66bb94e77a9c1daebeea58fa731d5.zip
Add utility to inspect a model's parameters (to get dtype/device)
Diffstat (limited to 'modules/upscaler_utils.py')
-rw-r--r--modules/upscaler_utils.py5
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/upscaler_utils.py b/modules/upscaler_utils.py
index 8e413854..c60e3beb 100644
--- a/modules/upscaler_utils.py
+++ b/modules/upscaler_utils.py
@@ -7,6 +7,7 @@ import tqdm
from PIL import Image
from modules import images, shared
+from modules.torch_utils import get_param
logger = logging.getLogger(__name__)
@@ -17,8 +18,8 @@ def upscale_without_tiling(model, img: Image.Image):
img = np.ascontiguousarray(np.transpose(img, (2, 0, 1))) / 255
img = torch.from_numpy(img).float()
- model_weight = next(iter(model.model.parameters()))
- img = img.unsqueeze(0).to(device=model_weight.device, dtype=model_weight.dtype)
+ param = get_param(model)
+ img = img.unsqueeze(0).to(device=param.device, dtype=param.dtype)
with torch.no_grad():
output = model(img)