{"id":7877,"library":"yolov5","title":"YOLOv5 Object Detector (Pip Package)","description":"YOLOv5 is a family of object detection architectures and models pretrained on the COCO dataset, known for its balance of speed and accuracy. This `yolov5` pip package by @fcakyon provides an easily installable and programmatic interface for the original Ultralytics YOLOv5 implementation. The current version is 7.0.14, with frequent minor updates aligning with upstream changes and bug fixes.","status":"active","version":"7.0.14","language":"en","source_language":"en","source_url":"https://github.com/fcakyon/yolov5-pip","tags":["computer-vision","object-detection","yolo","machine-learning","deep-learning"],"install":[{"cmd":"pip install yolov5","lang":"bash","label":"Stable Release"},{"cmd":"pip install yolov5[all]  # Includes all optional dependencies for full functionality","lang":"bash","label":"Full Installation"}],"dependencies":[{"reason":"Used for model download and integration; specific versions can cause import errors.","package":"huggingface_hub","optional":false},{"reason":"For experiment tracking integration.","package":"neptune","optional":true},{"reason":"For direct integration with Roboflow datasets and services.","package":"roboflow","optional":true}],"imports":[{"note":"The primary interface is a class, not direct functions on the module.","wrong":"import yolov5","symbol":"YOLOv5","correct":"from yolov5 import YOLOv5"}],"quickstart":{"code":"from yolov5 import YOLOv5\nimport os\n\n# Load a pretrained YOLOv5 model\n# Options: yolov5s, yolov5m, yolov5l, yolov5x\nmodel = YOLOv5(model_path=\"yolov5s.pt\", device=\"cpu\") # Use device=\"cuda:0\" for GPU\n\n# Set model parameters\nmodel.conf = 0.25  # NMS confidence threshold\nmodel.iou = 0.45   # NMS IoU threshold\nmodel.max_det = 1000 # Maximum number of detections per image\n\n# Perform inference on an image (e.g., from a URL or local path)\n# Example image from COCO dataset\nimg_path = \"https://ultralytics.com/images/zidane.jpg\"\nresults = model(img_path, size=640)\n\n# Process and display results\npredictions = results.pred[0]\nboxes = predictions[:, :4]\nscores = predictions[:, 4]\ncategories = predictions[:, 5]\n\nprint(f\"Detected {len(boxes)} objects:\")\nfor i in range(len(boxes)):\n    print(f\"  Box: {boxes[i].tolist()}, Score: {scores[i]:.2f}, Category: {int(categories[i])}\")\n\n# Optional: Save results to a directory\n# results.save(save_dir=\"./results\")","lang":"python","description":"This quickstart demonstrates how to load a pretrained YOLOv5 model, set inference parameters, and perform object detection on an image. The `YOLOv5` class manages model loading and inference, providing easy access to prediction results."},"warnings":[{"fix":"Ensure your `huggingface_hub` package is within the compatible range (e.g., `pip install huggingface-hub<0.16`). If you experience `ImportError` related to `log_metrics_to_hubble`, this is likely the cause.","message":"Version 7.0.14 introduced an upper limit for `huggingface_hub` (<0.16.0) to prevent import errors caused by recent changes in the library.","severity":"breaking","affected_versions":"7.0.14 onwards (fix for previous versions)"},{"fix":"Always refer to the `fcakyon/yolov5-pip` GitHub README for the correct programmatic usage, particularly the `YOLOv5` class interface. Do not mix with direct script calls from the original Ultralytics repo or the `ultralytics` package for YOLOv8.","message":"This `yolov5` pip package is a wrapper around the original Ultralytics YOLOv5 repository. While it provides the same models, its programmatic API (`from yolov5 import YOLOv5`) differs from directly cloning and running the Ultralytics repository scripts or using the newer `ultralytics` pip package (YOLOv8, YOLOv5, etc.).","severity":"gotcha","affected_versions":"All versions"},{"fix":"Ensure a clean installation in a dedicated virtual environment (`python -m venv .venv && source .venv/bin/activate && pip install yolov5`). Update to the latest version (`pip install --upgrade yolov5`) as these issues are often patched.","message":"Occasional `ModuleNotFoundError` errors for internal modules like `yolov5.utils.general` have been reported, often related to packaging or environment issues.","severity":"gotcha","affected_versions":"Prior to 7.0.13, intermittent in some environments."},{"fix":"Install `roboflow` as an optional dependency and provide the `--roboflow_token` argument when using CLI commands for Roboflow datasets.","message":"Roboflow integration requires the `roboflow` package to be installed (e.g., `pip install yolov5[roboflow]` or `pip install roboflow>=0.2.27`) and typically a Roboflow API token.","severity":"gotcha","affected_versions":"All versions with Roboflow integration (7.0.8+)"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"First, try updating the package (`pip install --upgrade yolov5`). If the problem persists, try a clean reinstallation in a fresh virtual environment. This specific issue was addressed in version 7.0.13.","cause":"This error often occurs due to issues with package installation, corrupted environment, or internal pathing conflicts, particularly in older versions.","error":"ModuleNotFoundError: No module named 'yolov5.utils.general'"},{"fix":"Downgrade `huggingface_hub` to a compatible version. For `yolov5` 7.0.14+, this typically means `pip install huggingface-hub<0.16.0`. Check the `yolov5` release notes for the exact compatible range.","cause":"Your `huggingface_hub` library version is too new and introduces breaking changes that conflict with the `yolov5` package's expected API.","error":"ImportError: cannot import name 'log_metrics_to_hubble' from 'huggingface_hub'"},{"fix":"Use the class-based API: `from yolov5 import YOLOv5` and then instantiate the model with `model = YOLOv5(model_path='yolov5s.pt', device='cpu')`.","cause":"You are attempting to use the `load()` function, which is a common pattern in the original Ultralytics YOLOv5 repository scripts or some other machine learning libraries, but not directly exposed by the `fcakyon/yolov5-pip` package's top-level module.","error":"AttributeError: module 'yolov5' has no attribute 'load'"},{"fix":"Ensure you have CUDA drivers and the appropriate CUDA Toolkit installed for your system. Reinstall PyTorch with CUDA support, matching your CUDA Toolkit version (e.g., `pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118`). Verify with `import torch; print(torch.cuda.is_available())`.","cause":"PyTorch is unable to detect a CUDA-enabled GPU, or CUDA drivers/toolkit are not correctly installed or configured for your PyTorch installation.","error":"torch.cuda.is_available() returned False, but cuda is selected. Check your CUDA installation."}]}