{"record":{"id":"dd41478c837c0edc","repo":"AUTOMATIC1111/stable-diffusion-webui","slug":"no-gfpgan-model-found","errorCode":null,"errorMessage":"No GFPGAN model found","messagePattern":"No GFPGAN model found","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"modules/gfpgan_model.py","lineNumber":44,"sourceCode":"\r\n    def get_device(self):\r\n        return devices.device_gfpgan\r\n\r\n    def load_net(self) -> torch.Module:\r\n        for model_path in modelloader.load_models(\r\n            model_path=self.model_path,\r\n            model_url=model_url,\r\n            command_path=self.model_path,\r\n            download_name=model_download_name,\r\n            ext_filter=['.pth'],\r\n        ):\r\n            if 'GFPGAN' in os.path.basename(model_path):\r\n                return modelloader.load_spandrel_model(\r\n                    model_path,\r\n                    device=self.get_device(),\r\n                    expected_architecture='GFPGAN',\r\n                ).model\r\n        raise ValueError(\"No GFPGAN model found\")\r\n\r\n    def restore(self, np_image):\r\n        def restore_face(cropped_face_t):\r\n            assert self.net is not None\r\n            return self.net(cropped_face_t, return_rgb=False)[0]\r\n\r\n        return self.restore_with_helper(np_image, restore_face)\r\n\r\n\r\ndef gfpgan_fix_faces(np_image):\r\n    if gfpgan_face_restorer:\r\n        return gfpgan_face_restorer.restore(np_image)\r\n    logger.warning(\"GFPGAN face restorer not set up\")\r\n    return np_image\r\n\r\n\r\ndef setup_model(dirname: str) -> None:\r\n    global gfpgan_face_restorer\r","sourceCodeStart":26,"sourceCodeEnd":62,"githubUrl":"https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/82a973c04367123ae98bd9abdf80d9eda9b910e2/modules/gfpgan_model.py#L26-L62","documentation":"Raised by gfpgan_model.load_model after it iterated every candidate .pth file (found via modelloader with ext_filter ['.pth']) in the GFPGAN model directory and none had 'GFPGAN' in the filename basename, or none existed at all. It means no GFPGAN face-restoration weights are available where the loader expects them.","triggerScenarios":"Enabling CodeFormer/GFPGAN face restore (restore_faces) with the GFPGAN restorer selected, while the models/GFPGAN directory is empty or contains no file whose basename contains 'GFPGAN' with a .pth extension.","commonSituations":"Fresh install where the automatic download failed or was skipped, the model file was renamed (e.g. to GFPGANv1.4.pth.backup), or it was placed in the wrong directory.","solutions":["Put a valid GFPGAN weight file (e.g. GFPGANv1.4.pth) into the model directory shown by the loader (typically <webui-root>/models/GFPGAN) keeping 'GFPGAN' in the filename and a .pth extension.","Or let the UI download it: open the Extras/face-restore tab and trigger the model download so modelloader fetches it from the registered model_url.","Alternatively switch face restorer to CodeFormer if GFPGAN weights are unavailable."],"exampleFix":"# before: file renamed so basename check fails\nmodels/GFPGAN/gfpgan_v14.pth\n\n# after: keep 'GFPGAN' and .pth in the name\nmodels/GFPGAN/GFPGANv1.4.pth","handlingStrategy":"validation","validationCode":"import os, glob\n\ndef gfpgan_available(model_dir):\n    return any('GFPGAN' in os.path.basename(p)\n               for p in glob.glob(os.path.join(model_dir, '**', '*.pth'), recursive=True))\n\nif shared.opts.face_restoration_model == 'GFPGAN' and not gfpgan_available('models/GFPGAN'):\n    print('GFPGAN weights missing; face restore will fail')","typeGuard":null,"tryCatchPattern":"try:\n    restorer = gfpgan_model.GfpganRestorer(...)\nexcept ValueError as e:\n    if 'No GFPGAN model found' in str(e):\n        download_gfpgan_weights()  # then retry once\n    else:\n        raise","preventionTips":["Keep GFPGAN weights at models/GFPGAN/GFPGANv1.4.pth with 'GFPGAN' in the basename.","Check file presence at startup in unattended deployments before enabling restore_faces."],"tags":["gfpgan","face-restoration","model-files","stable-diffusion"],"backgroundTag":null,"analyzedSha":"82a973c04367123ae98bd9abdf80d9eda9b910e2","analyzedAt":"2026-08-14T16:46:43.225Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}