tensorflow/models · error · ValueError

repo_dir must be a non-empty path.

Error message

repo_dir must be a non-empty path.

What it means

Guard in load_model rejecting a repo_dir whose string form is '' or '.'. torch.hub.load requires a real path to the cloned Facebook DINOv3 repository; '.' would make hub try to import the pipeline's own working directory as the model repo, producing confusing downstream failures, so the guard blocks it early. Indicates the repo path was never configured, or Path('') was passed (pathlib normalizes it to '.').

Solutions

  1. Clone the DINOv3 repository and point repo_dir at its absolute path
  2. Ensure the repo-directory config value is set and not an empty string (Path('') becomes '.')
  3. Pass an explicit absolute path to avoid cwd-relative '.' resolution
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at official/projects/waste_identification_ml/fine_tuning/Dinov3_image_classifier/models.py:94 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/fb9c9331362d4538. Report an issue: GitHub.

Appendix: source

Thrown at official/projects/waste_identification_ml/fine_tuning/Dinov3_image_classifier/models.py:94

) -> nn.Module:
  """Loads a DINOv3 backbone via torch.hub from a local repository.

  Args:
    model_name: Name of the DINOv3 model variant (e.g., 'dinov3_vits16').
    repo_dir: Path to the cloned Facebook DINOv3 repository.
    weights: Optional path to a pretrained weights file. If None, the model is
      loaded with random weights.

  Returns:
    The DINOv3 backbone model.

  Raises:
    ValueError: If `model_name` or `repo_dir` is falsy (empty or None).
  """
  if not model_name:
    raise ValueError("model_name must be a non-empty string.")
  if str(repo_dir) in ("", "."):
    raise ValueError("repo_dir must be a non-empty path.")

  if weights is not None:
    _LOGGER.info("Loading pretrained backbone weights from: %s", weights)
    return torch.hub.load(
        str(repo_dir),
        model_name,
        source="local",
        weights=str(weights),
    )

  _LOGGER.info("No pretrained weights path given. Loading with random weights.")
  return torch.hub.load(str(repo_dir), model_name, source="local")


class Dinov3Classification(nn.Module):
  """DINOv3 backbone with a linear classification head.

  The feature vector fed to the classification head is controlled by the

View on GitHub (pinned to e006f5f0d5)