tensorflow/models · error · ClassifierError

Checkpoint state dict is missing required key 'head.weight'.

Error message

Checkpoint state dict is missing required key 'head.weight'.

What it means

Error "Checkpoint state dict is missing required key 'head.weight'." thrown in tensorflow/models.

Source

Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/dinov3_classifier.py:162

    checkpoint_path: Filesystem path to the checkpoint.
    device: Target device for `map_location`.

  Returns:
    The `model_state_dict` mapping from parameter name to tensor.

  Raises:
    ClassifierError: If the checkpoint is missing required keys.
  """
  checkpoint = torch.load(
      checkpoint_path, map_location=device, weights_only=True
  )
  if "model_state_dict" not in checkpoint:
    raise ClassifierError(
        "Checkpoint is missing required key 'model_state_dict'."
    )
  saved_state_dict = checkpoint["model_state_dict"]
  if "head.weight" not in saved_state_dict:
    raise ClassifierError(
        "Checkpoint state dict is missing required key 'head.weight'."
    )
  return saved_state_dict


def _build_image_transform(config: config_loader.DINOv3Config) -> v2.Compose:
  """Builds the preprocessing pipeline used to feed PIL images to the model.

  Args:
    config: DINOv3 model configuration providing image size and normalization
      statistics.

  Returns:
    A torchvision v2.Compose pipeline.
  """
  return v2.Compose([
      v2.ToImage(),
      v2.Resize(

View on GitHub (pinned to e006f5f0d5)

When it happens

Trigger: Thrown at official/projects/waste_identification_ml/model_inference_with_tracking/sam3_dinov3_tracking_pipeline/dinov3_classifier.py:162 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of tensorflow/models@e006f5f0d5 (2026-08-24). Data as JSON: /api/errors/c00736b445fbaaff. Report an issue: GitHub.