Replace empty_cache with torch_gc

This commit is contained in:
Disty0
2023-07-12 12:45:21 +03:00
parent 562ca33275
commit 2bce86a50a
5 changed files with 7 additions and 20 deletions
@@ -88,7 +88,7 @@ class UpscalerScuNET(modules.upscaler.Upscaler):
def do_upscale(self, img: PIL.Image.Image, selected_file):
torch.cuda.empty_cache()
devices.torch_gc()
model = self.load_model(selected_file)
if model is None:
@@ -112,7 +112,7 @@ class UpscalerScuNET(modules.upscaler.Upscaler):
torch_output = torch_output[:, :h * 1, :w * 1] # remove padding, if any
np_output: np.ndarray = torch_output.float().cpu().clamp_(0, 1).numpy()
del torch_img, torch_output
torch.cuda.empty_cache()
devices.torch_gc()
output = np_output.transpose((1, 2, 0)) # CHW to HWC
output = output[:, :, ::-1] # BGR to RGB