A Rust wrapper for Darknet, an open source neural network framework written in C and CUDA.
Currently lacks training functionality as it usually done in python. (PRs are welcome)
Features:
Put 'data' directory with your project if you plan to use Detections::draw_on_image method.
Example:
use darknet::{load_labels, Image, Network};
use std::fs;
fn main() {
let object_labels = load_labels("./darknet/data/coco.names").unwrap();
let mut net = Network::load(
"./darknet/cfg/yolov3-tiny.cfg",
Some("./yolov3-tiny.weights"),
false,
object_labels.clone(),
)
.unwrap();
let mut img = Image::open("./darknet/data/person.jpg").unwrap();
let detections = net.predict(&mut img, 0.45, 0.3);
println!("Found: {:?}", detections.get_labels());
fs::create_dir("./result");
for (label, obj) in detections.crop_from(&img) {
obj.save(&format!("./result/{}.jpg", label)).unwrap();
}
detections.draw_on_image(&mut img);
img.show("IMG");
}
You can download .weights files here: (https://pjreddie.com/darknet/yolo/)