{"record":{"id":"b7bd08fa5bcf0e98","repo":"tensorflow/models","slug":"model-name-must-be-a-non-empty-string","errorCode":null,"errorMessage":"model_name must be a non-empty string.","messagePattern":"model_name must be a non-empty string\\.","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"official/projects/waste_identification_ml/fine_tuning/Dinov3_image_classifier/models.py","lineNumber":92,"sourceCode":"    repo_dir: pathlib.Path,\n    weights: pathlib.Path | None = None,\n) -> nn.Module:\n  \"\"\"Loads a DINOv3 backbone via torch.hub from a local repository.\n\n  Args:\n    model_name: Name of the DINOv3 model variant (e.g., 'dinov3_vits16').\n    repo_dir: Path to the cloned Facebook DINOv3 repository.\n    weights: Optional path to a pretrained weights file. If None, the model is\n      loaded with random weights.\n\n  Returns:\n    The DINOv3 backbone model.\n\n  Raises:\n    ValueError: If `model_name` or `repo_dir` is falsy (empty or None).\n  \"\"\"\n  if not model_name:\n    raise ValueError(\"model_name must be a non-empty string.\")\n  if str(repo_dir) in (\"\", \".\"):\n    raise ValueError(\"repo_dir must be a non-empty path.\")\n\n  if weights is not None:\n    _LOGGER.info(\"Loading pretrained backbone weights from: %s\", weights)\n    return torch.hub.load(\n        str(repo_dir),\n        model_name,\n        source=\"local\",\n        weights=str(weights),\n    )\n\n  _LOGGER.info(\"No pretrained weights path given. Loading with random weights.\")\n  return torch.hub.load(str(repo_dir), model_name, source=\"local\")\n\n\nclass Dinov3Classification(nn.Module):\n  \"\"\"DINOv3 backbone with a linear classification head.","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/tensorflow/models/blob/e006f5f0d534913e49c1f1dae87364039fa607e2/official/projects/waste_identification_ml/fine_tuning/Dinov3_image_classifier/models.py#L74-L110","documentation":"Falsy-check guard in load_model: model_name is empty or None, so torch.hub has no hub entry point to instantiate from the local DINOv3 repository. The function loads backbones by variant name (e.g. 'dinov3_vits16'); a missing name makes the hub lookup impossible, so it fails before any I/O. Usually a config omission or the caller (load_all_models) passing the wrong variable from its loop.","triggerScenarios":"Thrown at official/projects/waste_identification_ml/fine_tuning/Dinov3_image_classifier/models.py:92 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Set model_name to a valid DINOv3 variant such as 'dinov3_vits16' or 'dinov3_vitl16'","Check that load_all_models passes the model-name key from its config/loop correctly","Add the missing field to the model configuration YAML or CLI flags"],"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"}