{"record":{"id":"32e28355153e383b","repo":"tensorflow/models","slug":"variables-to-load-is-empty","errorCode":null,"errorMessage":"Variables to load is empty.","messagePattern":"Variables to load is empty\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/legacy/detection/modeling/checkpoint_utils.py","lineNumber":139,"sourceCode":"  \"\"\"\n\n  def _restore_checkpoint_fn(keras_model):\n    \"\"\"Loads pretrained model through scaffold function.\"\"\"\n    if not checkpoint_path:\n      logging.info('checkpoint_path is empty')\n      return\n    var_prefix = prefix\n    if prefix and not prefix.endswith('/'):\n      var_prefix += '/'\n    var_to_shape_map = _get_checkpoint_map(checkpoint_path)\n    assert var_to_shape_map, 'var_to_shape_map should not be empty'\n    vars_to_load = _build_assignment_map(\n        keras_model,\n        prefix=var_prefix,\n        skip_variables_regex=skip_regex,\n        var_to_shape_map=var_to_shape_map)\n    if not vars_to_load:\n      raise ValueError('Variables to load is empty.')\n    tf.compat.v1.train.init_from_checkpoint(checkpoint_path, vars_to_load)\n\n  return _restore_checkpoint_fn\n","sourceCodeStart":121,"sourceCodeEnd":143,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/legacy/detection/modeling/checkpoint_utils.py#L121-L143","documentation":"Sanity check inside the checkpoint-restore scaffold function: after building the assignment map from the model variables and the checkpoint's var_to_shape_map, no variables remained to load. This means none of the model's variable names matched the checkpoint entries under the given prefix/skip regex.","triggerScenarios":"Thrown at official/legacy/detection/modeling/checkpoint_utils.py:139 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the checkpoint path points to a compatible pretrained checkpoint","Check that the prefix matches the variable naming in the checkpoint (e.g. the backbone prefix)","Relax or remove skip_variables_regex if it is excluding all variables","Confirm the model was built before restore is attempted so variables exist"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}