diff options
author | AUTOMATIC1111 <16777216c@gmail.com> | 2024-01-31 19:41:22 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-01-31 19:41:22 +0000 |
commit | 652a7bbf809d8885b3ba6d42321d5828f66ac4c6 (patch) | |
tree | 53ec9e3b048d204c4ec1ae6e1768b9128601a5c4 /modules/upscaler_utils.py | |
parent | 1b0931fd92a13869818a198c2e63af8f9f04ad5b (diff) | |
parent | 74b214a92a2959948dcd05a78b7380e046163871 (diff) | |
download | stable-diffusion-webui-gfx803-652a7bbf809d8885b3ba6d42321d5828f66ac4c6.tar.gz stable-diffusion-webui-gfx803-652a7bbf809d8885b3ba6d42321d5828f66ac4c6.tar.bz2 stable-diffusion-webui-gfx803-652a7bbf809d8885b3ba6d42321d5828f66ac4c6.zip |
Merge pull request #14809 from Cyberbeing/fix_upscaler_autocast_nans
Fix potential autocast NaNs in image upscale
Diffstat (limited to 'modules/upscaler_utils.py')
-rw-r--r-- | modules/upscaler_utils.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/modules/upscaler_utils.py b/modules/upscaler_utils.py index afed8b40..b5e5a80c 100644 --- a/modules/upscaler_utils.py +++ b/modules/upscaler_utils.py @@ -6,7 +6,7 @@ import torch import tqdm from PIL import Image -from modules import images, shared, torch_utils +from modules import devices, images, shared, torch_utils logger = logging.getLogger(__name__) @@ -44,7 +44,8 @@ def upscale_pil_patch(model, img: Image.Image) -> Image.Image: with torch.no_grad(): tensor = pil_image_to_torch_bgr(img).unsqueeze(0) # add batch dimension tensor = tensor.to(device=param.device, dtype=param.dtype) - return torch_bgr_to_pil_image(model(tensor)) + with devices.without_autocast(): + return torch_bgr_to_pil_image(model(tensor)) def upscale_with_model( |