Skip to content
Lightweight turnkey solution for AI
Branch: master
Clone or download
Latest commit 0106c54 Jan 7, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.vscode gitignore clean up Sep 12, 2018
__template-darknet19_448 darknet19 - add valid.bat Jul 30, 2018
__template-darknet53 Add __template-darknet53 Jul 27, 2018
__template-yolov2 scripts - move scripts to scripts/ Jun 19, 2018
__template_native_app Clean up premake5.lua and build.bat Jan 7, 2019
bin facenet-inference - remove dead codes Jul 28, 2018
darknet_vs sln update Jan 7, 2019
deep-dream Clean up premake5.lua and build.bat Jan 7, 2019
facenet-inference Clean up premake5.lua and build.bat Jan 7, 2019
feature-viz
include Move src/*.h to include/ Sep 12, 2018
modules Update darknet Jan 7, 2019
scripts Ease the usage of video2gif.bat Aug 12, 2018
src Clean up premake5.lua and build.bat Jan 7, 2019
.gitignore gitignore clean up Sep 12, 2018
.gitmodules modules - remove Augmentor Jul 27, 2018
LICENSE Initial commit Apr 21, 2018
README.md Upgrading to CUDA 10.0 Nov 26, 2018
build.bat Clean up premake5.lua and build.bat Jan 7, 2019
lightnet.code-workspace Add lightnet.code-workspace Sep 12, 2018

README.md

lightnet

lightnet is a turnkey solution to real world problems accelerated with deep learning AI technology, including but not limited to object detection, image classification and human pose estimation.

How to read the source code

This project is dependent on a few open-source projects:

  • modules/darknet - the main engine for training & inferencing.
  • modules/Yolo_mark - the toolkit to prepare training data for object detection.
  • modules/yolo2_light - lightweighted inferencing engine [optional].
  • modules/cvui - lightweighted GUI based purely on OpenCV.
  • moudles/pytorch-caffe-darknet-convert - DL framework model converter
  • modules/minitrace - library to generate tracing logs for Chrome "about:tracing"
  • modules/readerwriterqueue - single-producer, single-consumer lock-free queue for C++
  • modules/bhtsne - Barnes-Hut implementation of the t-SNE algorithm

How to build from Visual Studio 2015

Install NVIDIA SDK

Install OpenCV

Build it

Execute the batch file

build.bat

Object Detection - inference w/ pre-trained weights

First you need to download the weights. You can read more details on darknet website.

cfg weights
cfg/yolov2.cfg https://pjreddie.com/media/files/yolov2.weights
cfg/yolov2-tiny.cfg https://pjreddie.com/media/files/yolov2-tiny.weights
cfg/yolo9000.cfg http://pjreddie.com/media/files/yolo9000.weights
cfg/yolov3.cfg https://pjreddie.com/media/files/yolov3.weights
cfg/yolov3-tiny.cfg https://pjreddie.com/media/files/yolov3-tiny.weights

Syntax for object detection

darknet.exe detector demo <data> <cfg> <weights> -c <camera_idx> -i <gpu_idx>
darknet.exe detector demo <data> <cfg> <weights> <video_filename> -i <gpu_idx>
darknet.exe detector test <data> <cfg> <weights> <img_filename> -i <gpu_idx>

Default launch device combination is -i 0 -c 0.

Run yolov3

darknet.exe detector demo cfg/coco.data cfg/yolov3.cfg yolov3.weights

Run yolo9000 on camera #0

darknet.exe detector demo cfg/combine9k.data cfg/yolo9000.cfg yolo9000.weights

Run yolo9000 CPU on camera #0

darknet_no_gpu.exe detector demo cfg/combine9k.data cfg/yolo9000.cfg yolo9000.weights

Object Detection - label images manually

Object Detection - train yolo v2 network

  1. Fork __template-yolov2 to my-yolo-net

  2. Download pre-trained weights for the convolutional layers: http://pjreddie.com/media/files/darknet19_448.conv.23 to bin/darknet19_448.conv.23

  3. To training for your custom objects, you should change 2 lines in file obj.cfg:

  • change classes in obj.data#L1
  • set number of classes (objects) in obj.cfg#L230
  • set filter-value equal to (classes + 5)*5 in obj.cfg#L224
  1. Run my-yolo-net/train.cmd

Object Detection - train yolo v3 network

  1. Fork __template-yolov3 to my-yolo-net

  2. Download pre-trained weights for the convolutional layers: http://pjreddie.com/media/files/darknet53.conv.74 to bin/darknet53.conv.74

  3. Create file obj.cfg with the same content as in yolov3.cfg (or copy yolov3.cfg to obj.cfg) and:

  • change line batch to batch=64
  • change line subdivisions to subdivisions=8
  • change line classes=80 to your number of objects in each of 3 [yolo]-layers:
    • obj.cfg#L610
    • obj.cfg#L696
    • obj.cfg#L783
  • change [filters=255] to filters=(classes + 5)x3 in the 3 [convolutional] before each [yolo] layer
    • obj.cfg#L603
    • obj.cfg#L689
    • obj.cfg#L776

So if classes=1 then should be filters=18. If classes=2 then write filters=21.

(Do not write in the cfg-file: filters=(classes + 5)x3)

(Generally filters depends on the classes, coords and number of masks, i.e. filters=(classes + coords + 1)*<number of mask>, where mask is indices of anchors. If mask is absence, then filters=(classes + coords + 1)*num)

So for example, for 2 objects, your file obj.cfg should differ from yolov3.cfg in such lines in each of 3 [yolo]-layers:

[convolutional]
filters=21

[region]
classes=2

Image Classification - inference w/ pre-trained weights

Again, you need download weights first. You can read more details on darknet website.

cfg weights
cfg/alexnet.cfg https://pjreddie.com/media/files/alexnet.weights
cfg/vgg-16.cfg https://pjreddie.com/media/files/vgg-16.weights
cfg/extraction.cfg https://pjreddie.com/media/files/extraction.weights
cfg/darknet.cfg https://pjreddie.com/media/files/darknet.weights
cfg/darknet19.cfg https://pjreddie.com/media/files/darknet19.weights
cfg/darknet19_448.cfg https://pjreddie.com/media/files/darknet19_448.weights
cfg/resnet50.cfg https://pjreddie.com/media/files/resnet50.weights
cfg/resnet152.cfg https://pjreddie.com/media/files/resnet152.weights
cfg/densenet201.cfg https://pjreddie.com/media/files/densenet201.weights

Image Classification - train darknet19_448 network

  1. Fork __template-darknet19_448 to my-darknet19-net

  2. Download pre-trained weights for the convolutional layers: http://pjreddie.com/media/files/darknet19_448.conv.23 to bin/darknet19_448.conv.23

  3. Create file obj.cfg with the same content as in darknet19_448.cfg (or copy darknet19_448.cfg to obj.cfg) and:

  • set batch to 128 or 64 or 32 depends on your GPU memory in darknet19-classify.cfg#L4
  • change line to subdivisions=4
  • set filter-value equal to classes in darknet19-classify.cfg#L189

Human Pose Estimation - inference w/ pre-trained weights

This project lives in DancingGaga

For more details, please check the README there.

[Weight file] (darknet version openpose.weight)

https://drive.google.com/open?id=1BfY0Hx2d2nm3I4JFh0W1cK2aHD1FSGea

FAQ

How to fine tune a existing network?

https://github.com/pjreddie/darknet/wiki/YOLO:-Real-Time-Object-Detection

darknet.exe partial cfg/darknet19_448.cfg darknet19_448.weights darknet19_448.conv.23 23

Explanation of yolo training output

https://github.com/rafaelpadilla/darknet#faq_yolo

You can’t perform that action at this time.