← all repositories
Tianxiaomo/pytorch-YOLOv4

YOLOv4 breaks out of Darknet into PyTorch

This repo re-implements YOLOv4 in PyTorch and paves an export road to ONNX and TensorRT, so you can leave Darknet behind.

4.5k stars Python Computer VisionML Frameworks
pytorch-YOLOv4
Not currently ranked — collecting fresh signals.
star history

What it does

This is a minimal PyTorch re-implementation of the YOLOv4 object detector. It handles training—with Mosaic augmentation—and inference, and it bundles tools to port original Darknet weights into PyTorch, then export them to ONNX and TensorRT. You can also feed it non-square input resolutions, provided they follow the 96-pixel stride formula starting at 320.

The interesting bit

The real value is the conversion fidelity. The README shows COCO benchmarks where this PyTorch port lands within a hair’s breadth of the original Darknet model—0.466 AP versus 0.471 at 416×416—and the TensorRT exports actually edge it out at 0.472. That means you are not sacrificing accuracy to escape the Darknet ecosystem.

Key highlights

  • Near-parity COCO accuracy: PyTorch AP 0.466 vs Darknet 0.471 at 416×416; TensorRT FP32 hits 0.472.
  • Full conversion chain: Darknet weights → PyTorch → ONNX → TensorRT, plus an ONNX-to-TensorFlow path.
  • Supports non-square inference sizes via a 96-pixel stride formula starting at 320.
  • Training includes Mosaic augmentation.
  • Dynamic or static batch-size ONNX exports.

Caveats

  • Post-processing NMS is still required after inference, including for TensorRT outputs.
  • The TensorRT demo script only handles batch size 1 or dynamic ranges including 1 without modification.
  • The ONNX-to-TensorFlow path is reported to be brittle with standard package installs and requires manual source compilation.

Verdict

Worth a look if you need YOLOv4 inside the PyTorch or ONNX deployment stack. Skip it if you are already comfortable in Darknet or need a turn-key pipeline with built-in NMS.

Frequently asked

What is Tianxiaomo/pytorch-YOLOv4?
This repo re-implements YOLOv4 in PyTorch and paves an export road to ONNX and TensorRT, so you can leave Darknet behind.
Is pytorch-YOLOv4 open source?
Yes — Tianxiaomo/pytorch-YOLOv4 is open source, released under the Apache-2.0 license.
What language is pytorch-YOLOv4 written in?
Tianxiaomo/pytorch-YOLOv4 is primarily written in Python.
How popular is pytorch-YOLOv4?
Tianxiaomo/pytorch-YOLOv4 has 4.5k stars on GitHub.
Where can I find pytorch-YOLOv4?
Tianxiaomo/pytorch-YOLOv4 is on GitHub at https://github.com/Tianxiaomo/pytorch-YOLOv4.

heatdrop uses Google Analytics to see which pages get read — nothing else. Your call. How we handle data.