{"record":{"id":"68cb3a12771db583","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"model-file-path-not-found","errorCode":null,"errorMessage":"Model file {path} not found","messagePattern":"Model file (.+?) not found","errorType":"exception","errorClass":"FileNotFoundError","httpStatus":null,"severity":"error","filePath":"modules/hat_model.py","lineNumber":38,"sourceCode":"            self.scalers.append(scaler_data)\r\n\r\n    def do_upscale(self, img, selected_model):\r\n        try:\r\n            model = self.load_model(selected_model)\r\n        except Exception as e:\r\n            print(f\"Unable to load HAT model {selected_model}: {e}\", file=sys.stderr)\r\n            return img\r\n        model.to(devices.device_esrgan)  # TODO: should probably be device_hat\r\n        return upscale_with_model(\r\n            model,\r\n            img,\r\n            tile_size=opts.ESRGAN_tile,  # TODO: should probably be HAT_tile\r\n            tile_overlap=opts.ESRGAN_tile_overlap,  # TODO: should probably be HAT_tile_overlap\r\n        )\r\n\r\n    def load_model(self, path: str):\r\n        if not os.path.isfile(path):\r\n            raise FileNotFoundError(f\"Model file {path} not found\")\r\n        return modelloader.load_spandrel_model(\r\n            path,\r\n            device=devices.device_esrgan,  # TODO: should probably be device_hat\r\n            expected_architecture='HAT',\r\n        )\r\n","sourceCodeStart":20,"sourceCodeEnd":44,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/hat_model.py#L20-L44","documentation":"HatModel.load_model refuses to proceed when the requested HAT upscaler path is not a regular file on disk, raising FileNotFoundError with the offending path. This is a pre-load sanity check before handing the file to modelloader.load_spandrel with expected_architecture='HAT'.","triggerScenarios":"Selecting a HAT upscaler entry whose recorded path does not exist — e.g. the models/HAT directory entry points at a deleted/moved file, or a custom path string is passed to load_model that was never validated.","commonSituations":"User deleted or moved .pth files under models/HAT while the UI list still cached the old entry; file is on an unmounted drive; typo in a manually configured model path.","solutions":["Restore the HAT .pth file at the exact path shown in the error message (typically under models/HAT).","Hit refresh on the upscaler list so stale entries pointing at missing files are dropped.","Re-download the HAT model from its source into models/HAT if you no longer have it."],"exampleFix":"import os\n\n# before\nmodel = hat.load_model('/stable-diffusion-webui/models/HAT/HAT_SRx4.pth')  # FileNotFoundError if absent\n\n# after\npath = '/stable-diffusion-webui/models/HAT/HAT_SRx4.pth'\nif not os.path.isfile(path):\n    raise SystemExit(f'Please place the HAT model at {path}')\nmodel = hat.load_model(path)","handlingStrategy":"validation","validationCode":"import os\n\ndef load_hat_safe(path):\n    if not os.path.isfile(path):\n        raise SystemExit(f'HAT model missing at {path}; download it first')\n    from modules.hat_model import HatModel\n    return HatModel().load_model(path)","typeGuard":null,"tryCatchPattern":"try:\n    model = hat.load_model(path)\nexcept FileNotFoundError as e:\n    # path is in the message; prompt user or re-download\n    raise SystemExit(f'{e}; place the HAT weights under models/HAT and retry')","preventionTips":["Validate os.path.isfile on user-supplied upscaler paths before loading.","Refresh the upscaler model list after deleting/moving .pth files."],"tags":["hat","upscaler","model-files","file-not-found"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}