"""Print the class names of a YOLO .pt model file. Useful after downloading a Roboflow / Hugging Face / custom-trained model — run this to see what class names it exposes, then update ``VEHICLE_CLASS_NAMES`` / ``PERSON_CLASS_NAMES`` in `.env` to include any names you want counted. Usage: .venv/bin/python -m scripts.inspect_model models/your-model.pt """ from __future__ import annotations import sys from pathlib import Path from ultralytics import YOLO def main() -> None: if len(sys.argv) < 2: print("usage: python -m scripts.inspect_model ", file=sys.stderr) sys.exit(1) path = sys.argv[1] if not Path(path).exists() and not path.startswith(("yolov", "yolo")): print(f"file not found: {path}", file=sys.stderr) sys.exit(2) m = YOLO(path) names = dict(getattr(m, "names", {}) or {}) print(f"model: {path}") print(f"classes: {len(names)}") print() print(f"{'id':>4} name") print(f"{'-'*4} {'-'*30}") for cid in sorted(names): print(f"{cid:>4} {names[cid]}") if __name__ == "__main__": main()