tensorflow/models · error · ClassifierError

Failed to load state dict into model: {error}

Error message

Failed to load state dict into model: {error}

What it means

Error "Failed to load state dict into model: {error}" thrown in tensorflow/models.

Source

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

    # DINOv3 Vision Transformers store token embedding dimension in
    # norm.normalized_shape[0].
    hidden_size = backbone_model.norm.normalized_shape[0]

    pooling = _infer_pooling_from_state_dict(
        saved_state_dict=saved_state_dict, hidden_size=hidden_size
    )

    model = Dinov3ClassificationModule(
        backbone_model=backbone_model,
        hidden_size=hidden_size,
        number_of_classes=len(class_names),
        pooling=pooling,
    ).to(resolved_device)

    try:
      model.load_state_dict(saved_state_dict)
    except RuntimeError as error:
      raise ClassifierError(
          f"Failed to load state dict into model: {error}"
      ) from error

    model.eval()
    return cls(
        model=model,
        class_names=class_names,
        image_transform=_build_image_transform(config),
        device=resolved_device,
    )

  @torch.no_grad()
  def predict_batch(self, images: Sequence[Image.Image]) -> list[Prediction]:
    """Classifies a batch of PIL images in a single forward pass.

    Args:
      images: Sequence of PIL images to classify.

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:351 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/93788091839b187c. Report an issue: GitHub.