#machine-learning #deep-learning #neural-networks #yolo #darknet

darknet

A Rust wrapper for Darknet, an open source neural network framework written in C and CUDA

9 releases

0.3.2 Jan 13, 2021
0.3.1 Jan 13, 2021
0.3.0 Jul 22, 2020
0.2.2 Jul 11, 2020
0.1.4 Mar 31, 2020

#23 in Machine learning

46 downloads per month

MIT license

7.5MB
37K SLoC

C 29K SLoC // 0.1% comments C++ 2.5K SLoC // 0.1% comments Python 2K SLoC // 0.2% comments Visual Studio Project 1.5K SLoC Rust 1K SLoC // 0.0% comments PowerShell 217 SLoC // 0.1% comments Batch 195 SLoC // 0.0% comments Shell 181 SLoC // 0.2% comments Visual Studio Solution 140 SLoC C# 72 SLoC // 0.0% comments

darknet-rust: A Rust bindings for AlexeyAB's Darknet

The crate is a Rust wrapper for AlexeyAB's Darknet.

It provides the following features:

  • Provide both training and inference capabilities.
  • Load config files and model weights from upstream without modifications.
  • Safe type wrappers for C API. It includes network, detection and layer types.

Minimal rustc version: 1.43.0

Version 0.3 changes:

  • Error handling with anyhow

Examples

The tiny_yolov3_inference example automatically downloads the YOLOv3 tiny weights, and produces inference results in output directory.

cargo run --release --example tiny_yolov3_inference

The run_inference example is an utility program that you can test a combination of model configs and weights on image files. For example, you can test the YOLOv4 mode.

cargo run --release --example run_inference -- \
    --label-file darknet/data/coco.names \
    --model-cfg darknet/cfg/yolov4.cfg \
    --weights yolov4.weights \
    darknet/data/*.jpg

Read the example code in examples/ to understand the actual usage. More model configs and weights can be found here: (https://pjreddie.com/darknet/yolo/).

Usage

Add our crate to your Cargo.toml. You may take a look at the API documentation.

darknet = "^0.3.0"

We suggest earlier users update to newer version from 0.1. There are several memory leakage and several bugs fixed.

Cargo Features

  • enable-cuda: Enable CUDA (expects CUDA 10.x and cuDNN 7.x).
  • enable-opencv: Enable OpenCV.
  • enable-cudnn: Enable cuDNN.
  • runtime: Link to darknet dynamic library. For example, libdark.so on Linux.
  • buildtime-bindgen: Generate bindings from darknet headers.
  • dylib: Build dynamic library instead of static.

License

The crate is licensed under MIT.

Credits

Huge thanks to jerry73204

Dependencies

~13MB
~148K SLoC