mirror of
https://github.com/vladmandic/automatic
synced 2026-09-19 09:14:35 +02:00
Replace empty_cache with torch_gc
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user