{"record":{"id":"73d127cd6ffbd144","repo":"tensorflow/models","slug":"checkpoint-at-checkpoint-path-is-missing-mode","errorCode":null,"errorMessage":"Checkpoint at '{checkpoint_path}' is missing 'model_state_dict'. Was it produced by our training scripts?","messagePattern":"Checkpoint at '(.+?)' is missing 'model_state_dict'\\. Was it produced by our training scripts\\?","errorType":"exception","errorClass":"KeyError","httpStatus":null,"severity":"error","filePath":"official/projects/waste_identification_ml/Deploy/pet_grading_cloud_deployment/pet_grade_classifier.py","lineNumber":276,"sourceCode":"    \"\"\"Reads and validates the model state dict from a checkpoint.\n\n    Args:\n        checkpoint_path: Path to the checkpoint file.\n        device: Torch device to map the loaded parameters to.\n\n    Returns:\n        The state dict containing model weights.\n\n    Raises:\n        KeyError: If 'model_state_dict' or 'head.weight' is missing.\n    \"\"\"\n    checkpoint = torch.load(\n        checkpoint_path,\n        map_location=device,\n        weights_only=False,\n    )\n    if \"model_state_dict\" not in checkpoint:\n      raise KeyError(\n          f\"Checkpoint at '{checkpoint_path}' is missing \"\n          \"'model_state_dict'. Was it produced by our training scripts?\"\n      )\n    state_dict = checkpoint[\"model_state_dict\"]\n    if \"head.weight\" not in state_dict:\n      raise KeyError(\n          \"Checkpoint state dict is missing 'head.weight'; cannot infer \"\n          \"pooling. Was the checkpoint produced by our Dinov3Classification?\"\n      )\n    return state_dict\n\n  @staticmethod\n  def _detect_pooling(\n      state_dict: dict[str, Any],\n      dinov3_repo_dir: str,\n      model_name: str,\n  ) -> str:\n    \"\"\"Infers the pooling strategy from the shape of the saved head's weights.","sourceCodeStart":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/waste_identification_ml/Deploy/pet_grading_cloud_deployment/pet_grade_classifier.py#L258-L294","documentation":"Error \"Checkpoint at '{checkpoint_path}' is missing 'model_state_dict'. Was it produced by our training scripts?\" thrown in tensorflow/models.","triggerScenarios":"Thrown at official/projects/waste_identification_ml/Deploy/pet_grading_cloud_deployment/pet_grade_classifier.py:276 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e006f5f0d534913e49c1f1dae87364039fa607e2","analyzedAt":"2026-08-24T14:09:15.576Z","schemaVersion":2},"datasetVersion":"2026-08-24T17:17:21.512Z"}