{"record":{"id":"ea647035fa1ab74b","repo":"lllyasviel/Fooocus","slug":"checkpoint-url-or-path-is-invalid","errorCode":null,"errorMessage":"checkpoint url or path is invalid","messagePattern":"checkpoint url or path is invalid","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"extras/BLIP/models/blip.py","lineNumber":223,"sourceCode":"        vision_width = 1024\n        visual_encoder = VisionTransformer(img_size=image_size, patch_size=16, embed_dim=vision_width, depth=24, \n                                           num_heads=16, use_grad_checkpointing=use_grad_checkpointing, ckpt_layer=ckpt_layer,\n                                           drop_path_rate=0.1 or drop_path_rate\n                                          )   \n    return visual_encoder, vision_width\n\ndef is_url(url_or_filename):\n    parsed = urlparse(url_or_filename)\n    return parsed.scheme in (\"http\", \"https\")\n\ndef load_checkpoint(model,url_or_filename):\n    if is_url(url_or_filename):\n        cached_file = download_cached_file(url_or_filename, check_hash=False, progress=True)\n        checkpoint = torch.load(cached_file, map_location='cpu', weights_only=True) \n    elif os.path.isfile(url_or_filename):        \n        checkpoint = torch.load(url_or_filename, map_location='cpu', weights_only=True) \n    else:\n        raise RuntimeError('checkpoint url or path is invalid')\n        \n    state_dict = checkpoint['model']\n    \n    state_dict['visual_encoder.pos_embed'] = interpolate_pos_embed(state_dict['visual_encoder.pos_embed'],model.visual_encoder) \n    if 'visual_encoder_m.pos_embed' in model.state_dict().keys():\n        state_dict['visual_encoder_m.pos_embed'] = interpolate_pos_embed(state_dict['visual_encoder_m.pos_embed'],\n                                                                         model.visual_encoder_m)    \n    for key in model.state_dict().keys():\n        if key in state_dict.keys():\n            if state_dict[key].shape!=model.state_dict()[key].shape:\n                del state_dict[key]\n    \n    msg = model.load_state_dict(state_dict,strict=False)\n    print('load checkpoint from %s'%url_or_filename)  \n    return model,msg\n    \n","sourceCodeStart":205,"sourceCodeEnd":240,"githubUrl":"https://github.com/lllyasviel/Fooocus/blob/ae05379cc97bc4361ec8b4ec90193dab21be763f/extras/BLIP/models/blip.py#L205-L240","documentation":"Raised by BLIP's load_checkpoint when the url_or_filename argument is neither an http/https URL (checked via urlparse scheme) nor an existing local file (os.path.isfile). It is the final else branch after both checkpoint-loading routes fail, so it always means the checkpoint location string is wrong or the file is missing at that path.","triggerScenarios":"Calling load_checkpoint(model, path) with a misspelled relative path, a path relative to a different working directory, a file:// or s3:// style URL (scheme is not http/https), an ftp URL, or a local path that was never downloaded/moved. Also triggered by passing None or an empty string.","commonSituations":"Running BLIP training/eval scripts from a different cwd so relative checkpoint paths break; copying configs that reference pretrained weights like 'checkpoints/model_base_capfilt_large.pth' that were never downloaded; typos in the checkpoint filename; using an environment without internet so the cached download directory never got populated.","solutions":["Verify the file exists at the exact path passed: os.path.isfile(your_path); if not, correct the path or use an absolute path via os.path.abspath / pathlib.Path(...).resolve()","If passing a URL, ensure it starts with http:// or https:// (the is_url helper only accepts those schemes) and that the URL is reachable","Download the pretrained checkpoint manually (e.g. from the BLIP release URLs) into your checkpoints directory and pass that local path","Check for leading/trailing whitespace, quotes, or 'file://' prefixes in the config value that supplies url_or_filename"],"exampleFix":"// before\nload_checkpoint(model, 'checkpoints/base_caption.pth')  # file not there\n\n// after\nfrom pathlib import Path\nckpt = Path('checkpoints/base_caption.pth').resolve()\nassert ckpt.is_file(), f'checkpoint not found: {ckpt}'\nload_checkpoint(model, str(ckpt))","handlingStrategy":"validation","validationCode":"from pathlib import Path\nfrom urllib.parse import urlparse\n\ndef valid_checkpoint_target(s):\n    if not isinstance(s, str) or not s.strip():\n        return False\n    if urlparse(s).scheme in ('http', 'https'):\n        return True\n    return Path(s).expanduser().is_file()","typeGuard":"def is_loadable_checkpoint(s: str) -> bool:\n    return valid_checkpoint_target(s)","tryCatchPattern":"try:\n    load_checkpoint(model, ckpt)\nexcept RuntimeError as e:\n    if 'checkpoint url or path is invalid' in str(e):\n        raise FileNotFoundError(f'checkpoint not found: {ckpt!r}') from e\n    raise","preventionTips":["Resolve checkpoint paths to absolute paths at config-load time","Fail fast with a clear message if neither a URL nor an existing file is configured","Pre-download weights in a setup step instead of relying on runtime URL fetch"],"tags":["blip","checkpoint","file-not-found","config"],"backgroundTag":null,"analyzedSha":"ae05379cc97bc4361ec8b4ec90193dab21be763f","analyzedAt":"2026-08-15T04:23:59.533Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}