Forráskód Böngészése

fix image upscale on cpu

for some reason upscale using cpu will fail with
RuntimeError: Inplace update to inference tensor outside InferenceMode
switch from no_grad to inference_mode seems to have fixed it
w-e-w 1 éve
szülő
commit
8e0881d9ab
1 módosított fájl, 1 hozzáadás és 1 törlés
  1. 1 1
      modules/upscaler_utils.py

+ 1 - 1
modules/upscaler_utils.py

@@ -41,7 +41,7 @@ def upscale_pil_patch(model, img: Image.Image) -> Image.Image:
     """
     """
     param = torch_utils.get_param(model)
     param = torch_utils.get_param(model)
 
 
-    with torch.no_grad():
+    with torch.inference_mode():
         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():
         with devices.without_autocast():