def METHOD_NAME(self, img, model_file):
    use_compile = hasattr(opts, 'SWIN_torch_compile') and opts.SWIN_torch_compile \
        and int(torch.__version__.split('.')[0]) >= 2 and platform.system() != "Windows"
    current_config = (model_file, opts.SWIN_tile)
    if use_compile and self._cached_model_config == current_config:
        model = self._cached_model
    else:
        self._cached_model = None
        try:
            model = self.load_model(model_file)
        except Exception as e:
            print(f"Failed loading SwinIR model {model_file}: {e}", file=sys.stderr)
            return img
        model = model.to(device_swinir, dtype=devices.dtype)
        if use_compile:
            model = torch.compile(model)
            self._cached_model = model
            self._cached_model_config = current_config
    img = upscale(img, model)
    devices.torch_gc()
    return img