AUTOMATIC1111/stable-diffusion-webui · error · FileNotFoundError
Model file {path} not found
Error message
Model file {path} not found What it means
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'.
Source
Thrown at modules/hat_model.py:38
self.scalers.append(scaler_data)
def do_upscale(self, img, selected_model):
try:
model = self.load_model(selected_model)
except Exception as e:
print(f"Unable to load HAT model {selected_model}: {e}", file=sys.stderr)
return img
model.to(devices.device_esrgan) # TODO: should probably be device_hat
return upscale_with_model(
model,
img,
tile_size=opts.ESRGAN_tile, # TODO: should probably be HAT_tile
tile_overlap=opts.ESRGAN_tile_overlap, # TODO: should probably be HAT_tile_overlap
)
def load_model(self, path: str):
if not os.path.isfile(path):
raise FileNotFoundError(f"Model file {path} not found")
return modelloader.load_spandrel_model(
path,
device=devices.device_esrgan, # TODO: should probably be device_hat
expected_architecture='HAT',
)
View on GitHub (pinned to 82a973c043)
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.
Example fix
import os
# before
model = hat.load_model('/stable-diffusion-webui/models/HAT/HAT_SRx4.pth') # FileNotFoundError if absent
# after
path = '/stable-diffusion-webui/models/HAT/HAT_SRx4.pth'
if not os.path.isfile(path):
raise SystemExit(f'Please place the HAT model at {path}')
model = hat.load_model(path) Defensive patterns
Strategy: validation
Validate before calling
import os
def load_hat_safe(path):
if not os.path.isfile(path):
raise SystemExit(f'HAT model missing at {path}; download it first')
from modules.hat_model import HatModel
return HatModel().load_model(path) Try / catch
try:
model = hat.load_model(path)
except FileNotFoundError as e:
# path is in the message; prompt user or re-download
raise SystemExit(f'{e}; place the HAT weights under models/HAT and retry') Prevention
- Validate os.path.isfile on user-supplied upscaler paths before loading.
- Refresh the upscaler model list after deleting/moving .pth files.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- RealESRGAN data missing: {scaler.local_data_path}
- DAT data missing: {scaler.local_data_path}
- Unable to find model info: {path}
- No GFPGAN model found
- Could not find checkpoint with name {p.refiner_checkpoint}
AI-assisted analysis of AUTOMATIC1111/stable-diffusion-webui@82a973c043 (2026-08-14).
Data as JSON: /api/errors/68cb3a12771db583.
Report an issue: GitHub.