Skip to main content

TensorFlow 2.x implementation of YOLOv4

Project description


A TensorFlow 2.0 implementation of YOLOv4: Optimal Speed and Accuracy of Object Detection

Python Versions Tensorflow Versions Code style: black Python package Open In Colab

This implementation runs (for now) inference with the original Darknet weights from AlexeyAB. See the roadmap section to see what's next.


To install this package, you can run:

pip install
pip install tensorflow
# Check that tf2_yolov4 is installed properly
python -c "from tf2_yolov4.model import YOLOv4; print(YOLOv4)"


  • MacOs >= 10.15 since tensorflow-addons is not available for older release of MacOs
  • Python >= 3.6
  • Compatible versions between TensorFlow and TensorFlow Addons: check the compatibility matrix

Examples in Colab

Pretrained weights

To load the Darknet weights trained on COCO, you have to:

  • get the weights (yolov4.weights) from AlexeyAB/darknet
  • run convert-darknet-weights PATH_TO/yolov4.weights

TF weights should be saved as yolov4.h5. For more information about the conversion script, run convert-darknet-weights --help.


  • <input type="checkbox" checked="" disabled="" /> Inference
    • <input type="checkbox" checked="" disabled="" /> CSPDarknet53 backbone with Mish activations
      • <input type="checkbox" checked="" disabled="" /> SPP Neck
      • <input type="checkbox" checked="" disabled="" /> YOLOv3 Head
      • <input type="checkbox" checked="" disabled="" /> Load Darknet Weights
      • <input type="checkbox" checked="" disabled="" /> Image loading and preprocessing
      • <input type="checkbox" checked="" disabled="" /> YOLOv3 box postprocessing
      • <input type="checkbox" checked="" disabled="" /> Handling non-square images
  • <input type="checkbox" disabled="" /> Training
    • <input type="checkbox" disabled="" /> Training loop with YOLOv3 loss
      • <input type="checkbox" disabled="" /> CIoU loss
      • <input type="checkbox" disabled="" /> Cross mini-Batch Normalization
      • <input type="checkbox" disabled="" /> Self-adversarial Training
      • <input type="checkbox" disabled="" /> Mosaic Data Augmentation
      • <input type="checkbox" disabled="" /> DropBlock
  • <input type="checkbox" disabled="" /> Enhancements
    • <input type="checkbox" disabled="" /> Automatic download of pretrained weights (like Keras applications)


Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for tf2-yolov4, version 0.1.0
Filename, size File type Python version Upload date Hashes
Filename, size tf2_yolov4-0.1.0-py3-none-any.whl (17.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size tf2_yolov4-0.1.0.tar.gz (12.0 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page