Run testsBuild StatusBuild statusBuild StatusCodecov

Wrapper for https://github.com/AlexeyAB/darknet based on pre-build binaries.

Current support:

- i686-linux-gnu
- x86_64-linux-gnu
- aarch64-linux-gnu
- armv7l-linux-gnueabihf
- powerpc64le-linux-gnu
- i686-linux-musl
- x86_64-linux-musl
- aarch64-linux-musl
- armv7l-linux-musleabihf
- x86_64-apple-darwin14
- x86_64-unknown-freebsd11.1
- i686-w64-mingw32
- x86_64-w64-mingw32


Requires julia 1.3+. Install with Pkg, just like any other registered Julia package:

pkg> add Darknet  # Press ']' to enter the Pkg REPL mode.


using Darknet, Images
d = "/path/to/weights_and_config_files/"
weightsfile = "yolov3-tiny.weights"
cfgfile = "yolov3-tiny.cfg"
datafile = "coco.data"

imagefile = "/path/to/images/test.jpg"

net = Darknet.load_network(joinpath(d,cfgfile), joinpath(d,weightsfile),1)
meta = Darknet.get_metadata(joinpath(d,datafile));

Reading in an image from file:

# Read image using Darknet method
img = load(imagefile)  #Image for plotting in julia purposes only (below)
img_d = Darknet.load_image_color(imagefile,0,0);  #Darknet native way to read in image from file. Produces an image type with pointers

or from an array in julia memory:

# Send image via an image in julia memory
img = convert(Array{Float32}, load(imagefile)) #Read in array via a julia method
img_d = Darknet.array_to_image(img) #Darknet image type with pointers to source data

or for looping through images from julia, avoid reallocation due to permuted dims:

img = convert(Array{Float32}, load(imagefile)) #Read in array via a julia method

# Darknet flips the first 2 dims of an image (cols,rows,colorchannels)
# so preallocate a permuted dims array to prevent reallocation in 
if size(img,3) > 1 #if more than 1 color channel 
    img_permuted = Array{Float32}(undef,size(img,2),size(img,1),size(img,3)) 
    img_permuted = Array{Float32}(undef,size(img,2),size(img,1)) 

img_d = Darknet.array_to_image(img,img_permuted) #Darknet image type with pointers to source data

Run detection

results = Darknet.detect(net,meta,img_d,thresh=0.1,nms=0.3)

Preview result using Makie:

using Makie, GeometryTypes
scene = Scene(resolution = size(img'))
image!(scene,img',scale_plot = false)

for res in results
    bbox = res[3]