yolov3

ultralyticsAGPL-3.0活跃维护

基于 PyTorch 的 YOLOv3 系列实现,覆盖训练、验证、推理全流程,并支持导出 ONNX、CoreML、TensorRT 等多种格式,方便做实时目标检测和边缘部署。

PyTorch implementation of YOLOv3, YOLOv3-SPP, and YOLOv3-tiny for real-time object detection with training, validation, inference, and multi-format export.

v9.6.0发布于 2021-11-14 21:26 UTC10,637star +5 / 7 天3,411fork同步于 2026-11-10 23:30 UTC

怎么上手

由 README 提炼,执行前请确认
git clone https://github.com/ultralytics/yolov3
cd yolov3
pip install -r requirements.txt
硬件要求按 README 说明

README 未说明具体显存要求;YOLOv3-tiny 面向 CPU 与边缘设备优化,训练时建议用硬件允许的最大 batch-size。

多卡 / 张量并行
下载:源码 zip·GitHub Releases(安装包)本站不镜像安装包

项目说明

由 README 自动翻译提炼

Ultralytics 出品的 YOLOv3 系列 PyTorch 实现,覆盖训练、验证、推理与多格式导出

基于 PyTorch 的 YOLOv3 系列实现,覆盖训练、验证、推理全流程,并支持导出 ONNX、CoreML、TensorRT 等多种格式,方便做实时目标检测和边缘部署。

核心能力

  • 提供 YOLOv3、YOLOv3-SPP、YOLOv3-tiny 三种模型
  • 用 Darknet-53 骨干加残差连接提取特征
  • 三尺度特征图预测,兼顾小中大目标
  • 每尺度三个 anchor,共九个先验框
  • 支持导出 TorchScript、ONNX、TensorRT 等格式

容易踩的坑

需要 Python>=3.8 和 PyTorch>=1.8 环境;预训练权重首次使用时自动下载,需联网;训练和验证会自动下载 COCO 数据集。

内容由模型根据 README 生成,可能不完整或不准确,以官方文档为准。看原文 README

最近发版

5 个版本v9.6.0
  1. v9.6.0v9.6.0 - YOLOv5 v6.0 release compatibility update for YOLOv3最新正式版2021-11-14 · 2021-11-14 21:26 UTC

    This release merges the most recent updates to YOLOv5 🚀 from the October 12th, 2021 YOLOv5 v6.0 release into this Ultralytics YOLOv3 repository. This is part of Ultralytics YOLOv3 maintenance and takes place on every major YOLOv5 release. Full details on the YOLOv5 v6.0 release are below.

    https://github.com/ultralytics/yolov5/releases/tag/v6.0

    This YOLOv5 v6.0 release incorporates many new features and bug fixes (465 PRs from 73 contributors) since our last release v5.0 in April, brings architecture tweaks, and also introduces new P5 and P6 'Nano' models: YOLOv5n and YOLOv5n6. Nano models maintain the YOLOv5s depth multiple of 0.33 but reduce the YOLOv5s width multiple from 0.50 to 0.25, resulting in ~75% fewer parameters, from 7.5M to 1.9M, ideal for mobile and CPU solutions.

    Example usage:

    python detect.py --weights yolov5n.pt --img 640    # Nano P5 model trained at --img 640 (28.4 [email protected]:0.95)
    python detect.py --weights yolov5n6.pt --img 1280  # Nano P6 model trained at --img 1280 (34.0 mAP0.5:0.95)
    

    Important Updates

    New Results

    • COCO AP val denotes [email protected]:0.95 metric measured on the 5000-image COCO val2017 dataset over various inference sizes from 256 to 1536.
    • GPU Speed measures average inference time per image on COCO val2017 dataset using a AWS p3.2xlarge V100 instance at batch-size 32.
    • EfficientDet data from google/automl at batch size 8.
    • Reproduce by `python val.py --task study --data coco.yaml
  2. v9.5.0v9.5.0 - YOLOv5 v5.0 release compatibility update for YOLOv32021-04-12 · 2021-04-12 16:01 UTC
    查看更新说明

    This YOLOv3 release merges the most recent updates to YOLOv5 featured in the April 11th, 2021 YOLOv5 v5.0 release into this repository. This is part of routine Ultralytics maintenance and takes place on every major YOLOv5 release. Full details on the YOLOv5 v5.0 release is below.

    https://github.com/ultralytics/yolov5/releases/tag/v5.0

    This release implements YOLOv5-P6 models and retrained YOLOv5-P5 models:

    • YOLOv5-P5 models (same architecture as v4.0 release): 3 output layers P3, P4, P5 at strides 8, 16, 32, trained at --img 640
    • YOLOv5-P6 models: 4 output layers P3, P4, P5, P6 at strides 8, 16, 32, 64 trained at --img 1280

    Example usage:

    # Command Line
    python detect.py --weights yolov5m.pt --img 640  # P5 model at 640
    python detect.py --weights yolov5m6.pt --img 640  # P6 model at 640
    python detect.py --weights yolov5m6.pt --img 1280  # P6 model at 1280
    
    # PyTorch Hub
    model = torch.hub.load('ultralytics/yolov5', 'yolov5m6')  #  P6 model
    results = model(imgs, size=1280)  # inference at 1280
    

    All model sizes YOLOv5s/m/l/x are now available in P5 and P6 architectures:

    python detect.py --weights yolov5s.pt  # P5 models
                               yolov5m.pt
                               yolov5l.pt
                               yolov5x.pt
                               yolov5s6.pt  # P6 models
                               yolov5m6.pt
                               yolov5l6.pt
                               yolov5x6.pt
    

    Notable Updates

    Updated Results

    P6 models include an extra P6/64 output layer for detection of larger objects, and benefit the most from training at higher resolution. For this reason we trained all P5 models at 640, and all P6 models at 1280.

    • GPU Speed measures end-to-end time per image averaged over 5000 COCO val2017 images using a V100 GPU with batch size 32, and includes image preprocessing, PyTorch FP16 inference, postprocessing and NMS.
    • EfficientDet data from [google/automl](https://github.com/go
  3. v9.1v9.1 - YOLOv5 Forward Compatibility Updates2021-01-13 · 2021-01-13 07:10 UTC
    查看更新说明

    This release is a minor update implementing numerous bug fixes, feature additions and performance improvements from https://github.com/ultralytics/yolov5 to this repo. Models remain unchanged from v9.0 release.

    Branch Notice

    The ultralytics/yolov3 repository is now divided into two branches:

    $ git clone https://github.com/ultralytics/yolov3  # master branch (default)
    
    $ git clone -b archive https://github.com/ultralytics/yolov3  # archive branch
    

    ** GPU Speed measures end-to-end time per image averaged over 5000 COCO val2017 images using a V100 GPU with batch size 32, and includes image preprocessing, PyTorch FP16 inference, postprocessing and NMS. EfficientDet data from google/automl at batch size 8.

    Pretrained Checkpoints

    ModelAPvalAPtestAP50SpeedGPUFPSGPUparamsFLOPS
    YOLOv343.343.363.04.8ms20861.9M156.4B
    YOLOv3-SPP44.344.364.64.9ms20463.0M157.0B
    YOLOv3-tiny17.634.934.91.7ms5888.9M13.3B

    ** APtest denotes COCO test-dev2017 server results, all other AP results denote val2017 accuracy.
    ** All AP numbers are for single-model single-scale without ensemble or TTA. Reproduce mAP by python test.py --data coco.yaml --img 640 --conf 0.001 --iou 0.65
    ** SpeedGPU averaged over 5000 COCO val2017 images using a GCP n1-standard-16 V100 instance, and includes image preprocessing, FP16 inference, postprocessing and NMS. NMS is 1-2ms/img. Reproduce speed by python test.py --data coco.yaml --img 640 --conf 0.25 --iou 0.45
    ** All checkpoints are trained to 300 epochs with default settings and hyperparameters (no autoaugmentation). ** Test Time Augmentation (TTA) runs at 3 image sizes. Reproduce TTA by python test.py --data coco.yaml --img 832 --iou 0.65 --augment

    Requirements

    Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

    $ pip install -r requirements.txt
    
  4. v9.0v9.0 - YOLOv5 Forward Compatibility Release2020-12-06 · 2020-12-06 17:04 UTC
    查看更新说明

    This release is a major update to the https://github.com/ultralytics/yolov3 repository that brings forward-compatibility with YOLOv5, and incorporates numerous bug fixes, feature additions and performance improvements from https://github.com/ultralytics/yolov5 to this repo.

    Branch Notice

    The ultralytics/yolov3 repository is now divided into two branches:

    $ git clone https://github.com/ultralytics/yolov3  # master branch (default)
    
    $ git clone -b archive https://github.com/ultralytics/yolov3  # archive branch
    

    ** GPU Speed measures end-to-end time per image averaged over 5000 COCO val2017 images using a V100 GPU with batch size 32, and includes image preprocessing, PyTorch FP16 inference, postprocessing and NMS. EfficientDet data from google/automl at batch size 8.

    Pretrained Checkpoints

    ModelAPvalAPtestAP50SpeedGPUFPSGPUparamsFLOPS
    YOLOv343.343.363.04.8ms20861.9M156.4B
    YOLOv3-SPP44.344.364.64.9ms20463.0M157.0B
    YOLOv3-tiny17.634.934.91.7ms5888.9M13.3B

    ** APtest denotes COCO test-dev2017 server results, all other AP results denote val2017 accuracy.
    ** All AP numbers are for single-model single-scale without ensemble or TTA. Reproduce mAP by python test.py --data coco.yaml --img 640 --conf 0.001 --iou 0.65
    ** SpeedGPU averaged over 5000 COCO val2017 images using a GCP n1-standard-16 V100 instance, and includes image preprocessing, FP16 inference, postprocessing and NMS. NMS is 1-2ms/img. Reproduce speed by python test.py --data coco.yaml --img 640 --conf 0.25 --iou 0.45
    ** All checkpoints are trained to 300 epochs with default settings and hyperparameters (no autoaugmentation). ** Test Time Augmentation (TTA) runs at 3 image sizes. Reproduce TTA by python test.py --data coco.yaml --img 832 --iou 0.65 --augment

    Requirements

    Python 3.8 or later with all requirements.txt dependencies installed, including torch>=1.7. To install run:

    $ pip install -r requirements.txt
    
  5. v8v8 - Final Darknet Compatible Release2020-11-18 · 2020-11-18 23:20 UTC
    查看更新说明

    This is the final release of the darknet-compatible version of the https://github.com/ultralytics/yolov3 repository. This release is backwards-compatible with darknet *.cfg files for model configuration.

    All pytorch (*.pt) and darknet (*.weights) models/backbones available are attached to this release in the Assets section below.

    Breaking Changes

    There are no breaking changes in this release.

    Bug Fixes

    • Various

    Added Functionality

    • Various

    Speed

    https://cloud.google.com/deep-learning-vm/
    Machine type: preemptible n1-standard-8 (8 vCPUs, 30 GB memory)
    CPU platform: Intel Skylake
    GPUs: K80 ($0.14/hr), T4 ($0.11/hr), V100 ($0.74/hr) CUDA with Nvidia Apex FP16/32
    HDD: 300 GB SSD Dataset: COCO train 2014 (117,263 images)
    Model: yolov3-spp.cfg
    Command: python3 train.py --data coco2017.data --img 416 --batch 32

    GPUn--batch-sizeimg/sepochtimeepochcost
    K80132 x 211175 min$0.41
    T41232 x 264 x 1416148 min32 min$0.09$0.11
    V1001232 x 264 x 112217816 min11 min$0.21$0.28
    2080Ti1232 x 264 x 18114024 min14 min--

    mAP

    SizeCOCO mAP@0.5...0.95COCO mAP@0.5
    YOLOv3-tinyYOLOv3YOLOv3-SPPYOLOv3-SPP-ultralytics32014.028.730.537.729.151.852.356.8
    YOLOv3-tinyYOLOv3YOLOv3-SPPYOLOv3-SPP-ultralytics41616.031.233.941.233.055.456.960.6
    YOLOv3-tinyYOLOv3YOLOv3-SPPYOLOv3-SPP-ultralytics51216.632.735.642.634.957.759.562.4
    YOLOv3-tinyYOLOv3YOLOv3-SPPYOLOv3-SPP-ultralytics60816.633.137.043.135.458.260.762.8

    TODO

    • NA

用户点评

登录用户的真实使用记录,可按版本和硬件筛选
共 0 条

    还没有人点评。第一个说出真实体验的人最有价值。

    README 原文

    未翻译

    中文 | 한국어 | 日本語 | Русский | Deutsch | Français | Español | Português | Türkçe | Tiếng Việt | العربية

    Ultralytics YOLOv3 is a PyTorch implementation of the YOLOv3 (You Only Look Once, version 3) real-time object detection model. YOLOv3 frames detection as a single regression problem, predicting bounding boxes and class probabilities directly from full images in one forward pass — making it fast, accurate, and straightforward to train and deploy.

    This repository packages the three classic YOLOv3 detection models — YOLOv3, YOLOv3-SPP, and YOLOv3-tiny — with training, validation, inference, and export tooling, and reuses shared utilities from the ultralytics package.

    Find detailed guidance in the Ultralytics YOLOv3 Docs. Get support via GitHub Issues, and join the conversation on Discord, Reddit, and the Ultralytics Forums.

    For commercial use, request an Enterprise License at Ultralytics Licensing.

    📚 Documentation

    See the Ultralytics YOLOv3 Docs for full documentation. The quickstart examples below cover installation, inference, and training with this repository.

    Clone the repository and install the dependencies from requirements.txt in a Python>=3.8.0 environment with PyTorch>=1.8.

    # Clone the YOLOv3 repository
    git clone https://github.com/ultralytics/yolov3
    
    # Navigate to the cloned directory
    cd yolov3
    
    # Install required packages
    pip install -r requirements.txt
    

    Load YOLOv3 directly through PyTorch Hub. Weights download automatically on first use.

    import torch
    
    # Load a YOLOv3 model (choices: 'yolov3', 'yolov3_spp', 'yolov3_tiny')
    model = torch.hub.load("ultralytics/yolov3", "yolov3", pretrained=True)
    
    # Run inference on an image (local file, URL, PIL image, OpenCV frame, or numpy array)
    results = model("https://ultralytics.com/images/zidane.jpg")
    
    # Inspect the results
    results.print()  # print detections to the console
    results.show()  # display the annotated image
    results.save()  # save the annotated image to runs/detect/exp
    

    detect.py runs inference on a wide range of sources, downloading models automatically and saving results to runs/detect.

    python detect.py --weights yolov3.pt --source 0                              # webcam
    python detect.py --weights yolov3.pt --source img.jpg                        # image
    python detect.py --weights yolov3.pt --source vid.mp4                        # video
    python detect.py --weights yolov3.pt --source screen                         # screenshot
    python detect.py --weights yolov3.pt --source path/                          # directory
    python detect.py --weights yolov3.pt --source 'path/*.jpg'                   # glob
    python detect.py --weights yolov3.pt --source 'rtsp://example.com/media.mp4' # RTSP, RTMP, HTTP stream
    

    Train YOLOv3 on the COCO dataset. Models and datasets download automatically. Use the largest --batch-size your hardware allows.

    # Train YOLOv3-tiny
    python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov3-tiny.yaml --batch-size 64
    
    # Train YOLOv3
    python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov3.yaml --batch-size 32
    
    # Train YOLOv3-SPP
    python train.py --data coco.yaml --epochs 300 --weights '' --cfg yolov3-spp.yaml --batch-size 16
    

    Validate accuracy with python val.py --weights yolov3.pt --data coco.yaml, and export to other formats (TorchScript, ONNX, OpenVINO, TensorRT, CoreML, and PaddlePaddle) with python export.py --weights yolov3.pt --include onnx.

    These guides cover the shared Ultralytics training framework and apply to YOLOv3:

    🧠 Architecture

    YOLOv3 builds detection on a few core ideas that make it both accurate and fast:

    • Darknet-53 backbone — a 53-layer convolutional feature extractor with residual (skip) connections, deeper and more accurate than the Darknet-19 backbone of YOLOv2 while staying efficient.
    • Multi-scale detection — predictions are made at three feature-map scales using a feature-pyramid-style design (upsampling and concatenating earlier feature maps), so the model detects small, medium, and large objects well.
    • Anchor boxes — boxes are predicted relative to dimension-cluster anchor priors, with three anchors per scale (nine total) and a sigmoid offset parameterization for stable training.
    • Independent class prediction — each class is scored with an independent logistic classifier rather than a softmax, so one box can carry multiple non-mutually-exclusive labels.

    The repository ships three variants of this architecture:

    • YOLOv3 — the full Darknet-53 model; the best balance of speed and accuracy.
    • YOLOv3-SPP — adds a Spatial Pyramid Pooling block that pools features at multiple kernel sizes for a larger effective receptive field and a small accuracy gain.
    • YOLOv3-tiny — a compact backbone with detection at two scales, optimized for CPU and edge devices where speed matters most.

    Models are defined declaratively in models/*.yaml and built by parse_model() in models/yolo.py, so the architecture can be inspected and modified without writing Python.

    🏋️ Pretrained Checkpoints

    All three models are trained on COCO (80 classes) and download automatically from the YOLOv3 release assets on first use.

    ModelDescription
    yolov3-tiny.ptLightweight two-scale model — the fastest option, ideal for CPU and edge devices.
    yolov3.ptThe original Darknet-53 model — a strong balance of speed and accuracy.
    yolov3-spp.ptAdds Spatial Pyramid Pooling for a larger receptive field and improved accuracy.

    🧩 Integrations

    Ultralytics integrates with leading AI platforms to extend dataset labeling, training, visualization, and model management. Explore how partners such as Weights & Biases, Comet ML, Roboflow, and Intel OpenVINO can streamline your workflow at Ultralytics Integrations.

    🤔 Why YOLOv3?

    YOLOv3 was a landmark in real-time object detection and remains a dependable, well-understood baseline:

    • Real-time single-stage detection — one forward pass produces all detections, with no separate region-proposal stage.
    • Strong across object sizes — multi-scale predictions handle small, medium, and large objects.
    • Multi-label friendly — independent logistic classifiers allow overlapping class labels.
    • Simple and portable — a fully-convolutional design that trains and exports cleanly to many deployment formats.

    For the broader family of Ultralytics YOLO models, see the Ultralytics repository.

    ☁️ Environments

    Get started quickly with pre-configured environments. Click an icon below for setup details.

    🤝 Contribute

    Contributions are welcome! Please see the Contributing Guide to get started, and share your feedback through the Ultralytics Survey. Thank you to all our contributors!

    Ultralytics open-source contributors

    📜 License

    Ultralytics offers two licensing options:

    • AGPL-3.0 License: An OSI-approved open-source license ideal for research and collaboration. See the LICENSE file for details.
    • Enterprise License: For commercial use, this license allows integration of Ultralytics software and models into commercial products without AGPL-3.0 obligations. Contact us via Ultralytics Licensing.

    📧 Contact

    For bug reports and feature requests, please use GitHub Issues. For questions and discussion, join our Discord, Reddit, and the Ultralytics Forums.