Commit 652a7bbf authored by AUTOMATIC1111's avatar AUTOMATIC1111 Committed by GitHub

Merge pull request #14809 from Cyberbeing/fix_upscaler_autocast_nans

Fix potential autocast NaNs in image upscale
parents 1b0931fd 74b214a9
...@@ -6,7 +6,7 @@ import torch ...@@ -6,7 +6,7 @@ import torch
import tqdm import tqdm
from PIL import Image from PIL import Image
from modules import images, shared, torch_utils from modules import devices, images, shared, torch_utils
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)
...@@ -44,6 +44,7 @@ def upscale_pil_patch(model, img: Image.Image) -> Image.Image: ...@@ -44,6 +44,7 @@ def upscale_pil_patch(model, img: Image.Image) -> Image.Image:
with torch.no_grad(): with torch.no_grad():
tensor = pil_image_to_torch_bgr(img).unsqueeze(0) # add batch dimension tensor = pil_image_to_torch_bgr(img).unsqueeze(0) # add batch dimension
tensor = tensor.to(device=param.device, dtype=param.dtype) tensor = tensor.to(device=param.device, dtype=param.dtype)
with devices.without_autocast():
return torch_bgr_to_pil_image(model(tensor)) return torch_bgr_to_pil_image(model(tensor))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment