Skip to main content

darknet2any

Introduction

darknet2any helps you convert darknet trained models into most modern formats including tflite, keras, onnx, and trt. It also includes sample prediction implementations for some of these model formats so you can make your own translations.

Installation

PyPi Project Page

### nvidia cuda install
pipx install "darknet2any[tensorrt]"

### tflite/litert install
pipx install "darknet2any[litert]"

### cpu only install
pipx install "darknet2any[cpu]"

### intel arc gpu install
pipx install "darknet2any[vino]"

### basic amd install
pipx install "darknet2any[rocm]"

### full amd install with migraphx (mxr) support on Ubuntu
git clone https://github.com/jredmondson/darknet2any.git
darknet2any/scripts/install_amd.sh

### macos install requires brew and creative PATH setting and avoiding zsh file globbing
### additionally, you have to tie pipx to this specific version. Mac. Fun.
brew install python@3.10
export PATH="/opt/homebrew/opt/python@3.10/libexec/bin:$PATH"
/opt/homebrew/opt/python@3.10/libexec/bin/python -m pip install pipx
pipx install "darknet2any[cpu]"

Tool Listing

  • darknet2onnx: converts from darknet to onnx
  • darknet2torch: converts from darknet to torch
  • darknet2visual: visualizes all layers within darknet models
  • onnx2tf: external tool for converting from onnx to tensorflow formats
  • onnx2trt: converts from onnx to tensorrt engines
  • predict_darknet: predicts a directory of images with darknet weights
  • predict_onnx: predicts a directory of images with onnx session
  • predict_tflite: predicts a directory of images with tflite model
  • predict_trt: predicts a directory of images with trt engine

Usage

Converting darknet to other formats

In general, any modern script has -h built in from the command line. If you run into any problems, try passing in -h, e.g.,

darknet2onnx -h

To generate all kinds of fun formats, try:

darknet2onnx -i example.weights
onnx2tf -i example.onnx -o .  -otfv1pb -okv3 -oh5
onnx2trt -i example.onnx

The generated formats will include:

  • onnx (op11 is default atm)
  • tensorrt (pretty much most optimal format on any CUDA)
  • TF v1 (.pb) format
  • Keras v3
  • Keras v5
  • TF lite

See onnx2tf cli options for some of the extensive options available for quant options like int8, uint8, float32, etc.

Batch conversion of weights to onnx to trt

darknet2onnx --input-dir {dir_with_weights_files}
onnx2trt --input-dir {dir_with_weights_files} --fp16

Running your trt model on image directories

predict_trt -i example.trt --image-dir ~/Pictures

This will by default create labeled images in the local labeled_images directory. Check it out to see how accurate your model is.

darknet2visualize

This script visualizes each layer of a yolo cnn, provided some example input image to help you see how the layers of the cnn convolve toward the boxes.

Recommended usage

darknet2visual -i {weight_path}/example.weights -o {output_image_path} --image {image_path}/my_image.jpg

The above would load the darknet weights at {weight_path}/example.weights, read the image at {image_path}/my_image.jpg and save every layer of the cnn's outputs to {output_image_path}/{image_name}_layer_{layer_id}.png. You can start from the minimum layer (0) by default or you can specify a starting layer such as 35 with -l {starting_layer_id}.

Operating Systems Supported

  • Ubuntu: all tools are supported
  • Mac: all tools are supported
  • Windows: everything but predict_tflite is supported

Bugs/Issues

Feel free to make an issue on this repo if you have trouble

Project Sponsorship

Additional Help with Darknet/Yolo/onnx2tf.

Metadata

Release files for darknet2any 0.7.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for darknet2any 0.7.6
File Size Uploaded Provenance Actions
darknet2any-0.7.6.tar.gz 43.4 kB With provenance Details for darknet2any-0.7.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for darknet2any 0.7.6
File Interpreter ABI Platform Actions
darknet2any-0.7.6-py3-none-any.whl Python 3 none any Details for darknet2any-0.7.6-py3-none-any.whl

Total release size: 102.0 kB

Release files / darknet2any-0.7.6.tar.gz

Download URL darknet2any-0.7.6.tar.gz
Size 43.4 kB
Tags Source
SHA-256 checksum
How to use checksums
b4d0a50974c3b5dcbe706f05e159f9585fd9e8e98599edcbc1905ed9335b166b
BLAKE2b-256 checksum
How to use checksums
d4f45faba924ec78b8831ad1cc69766c3393f42c496dd04b11e0a16344c66a31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 12, 2026.

Transparency log

Release files / darknet2any-0.7.6-py3-none-any.whl

Download URL darknet2any-0.7.6-py3-none-any.whl
Size 58.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
be5d2ffd96eca73edc0f503b80f998502d7e073268a455dc12dc6da95b6d5797
BLAKE2b-256 checksum
How to use checksums
6df3d06ef58f7c7e8edca047aead3690250c3ad2e377ea8576c30738e39d6d7d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 12, 2026.

Transparency log

Security for darknet2any 0.7.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for darknet2any-0.7.6.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 12, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page