lllyasviel/Fooocus · error · RuntimeError
checkpoint url or path is invalid
Error message
checkpoint url or path is invalid
What it means
Identical guard to BLIP's generic loader, but in the NLVR (visual reasoning) model loader: load_checkpoint in blip_nlvr.py raises RuntimeError when url_or_filename is neither an http/https URL nor an existing local file. It means the NLVR pretrained weights location is invalid before any torch.load happens.
Source
Thrown at extras/BLIP/models/blip_nlvr.py:85
return prediction
def blip_nlvr(pretrained='',**kwargs):
model = BLIP_NLVR(**kwargs)
if pretrained:
model,msg = load_checkpoint(model,pretrained)
print("missing keys:")
print(msg.missing_keys)
return model
def load_checkpoint(model,url_or_filename):
if is_url(url_or_filename):
cached_file = download_cached_file(url_or_filename, check_hash=False, progress=True)
checkpoint = torch.load(cached_file, map_location='cpu', weights_only=True)
elif os.path.isfile(url_or_filename):
checkpoint = torch.load(url_or_filename, map_location='cpu', weights_only=True)
else:
raise RuntimeError('checkpoint url or path is invalid')
state_dict = checkpoint['model']
state_dict['visual_encoder.pos_embed'] = interpolate_pos_embed(state_dict['visual_encoder.pos_embed'],model.visual_encoder)
for key in list(state_dict.keys()):
if 'crossattention.self.' in key:
new_key0 = key.replace('self','self0')
new_key1 = key.replace('self','self1')
state_dict[new_key0] = state_dict[key]
state_dict[new_key1] = state_dict[key]
elif 'crossattention.output.dense.' in key:
new_key0 = key.replace('dense','dense0')
new_key1 = key.replace('dense','dense1')
state_dict[new_key0] = state_dict[key]
state_dict[new_key1] = state_dict[key]
msg = model.load_state_dict(state_dict,strict=False)
print('load checkpoint from %s'%url_or_filename) View on GitHub (pinned to ae05379cc9)
Solutions
- Confirm the NLVR checkpoint file exists and pass its absolute path
- Or pass the official release URL (https://storage.googleapis.com/salesforce-research-blip/...) so download_cached_file fetches it
- Fix the cwd: run scripts from the repository root or make the path absolute
- Check scheme of URL values in config — only http/https are accepted
Example fix
// before
model, _ = load_checkpoint_model(cfg, 'model_base_nlvr.pth')
// after
import os
ckpt = os.path.abspath('checkpoints/model_base_nlvr.pth')
if not os.path.isfile(ckpt):
ckpt = 'https://storage.googleapis.com/salesforce-research-blip/models/model_base_nlvr.pth'
load_checkpoint(model, ckpt) Defensive patterns
Strategy: validation
Validate before calling
import os
from urllib.parse import urlparse
def assert_checkpoint_usable(s):
ok = urlparse(s).scheme in ('http', 'https') or os.path.isfile(os.path.expanduser(s))
assert ok, f'NLVR checkpoint missing or bad URL: {s!r}' Try / catch
try:
load_checkpoint(model, ckpt)
except RuntimeError as e:
if 'checkpoint url or path is invalid' in str(e):
# fall back to official release URL
load_checkpoint(model, RELEASE_URL)
else:
raise Prevention
- Download NLVR weights in a documented setup script
- Store checkpoint paths in one config location and validate them at startup
- Run scripts from the repo root or use absolute paths
When it happens
Trigger: Calling blip_nlvr.load_checkpoint with a wrong/missing path to NLVR weights (e.g. 'checkpoints/model_base_nlvr.pth' not downloaded), a non-http(s) URI, or a relative path resolved from the wrong working directory.
Common situations: Running NLVR evaluation without first downloading model_base_nlvr.pth from the BLIP release; moving the repo or running from another directory so relative paths break; config files pointing to stale checkpoint names.
Related errors
- checkpoint url or path is invalid
- The hidden size (%d) is not a multiple of the number of atte
- Wrong shape for input_ids (shape {}) or attention_mask (shap
- You cannot specify both input_ids and inputs_embeds at the s
- You have to specify either input_ids or inputs_embeds or enc
AI-assisted analysis of lllyasviel/Fooocus@ae05379cc9 (2026-08-15).
Data as JSON: /api/errors/70b8e5f6c6260277.
Report an issue: GitHub.