Darknet Source Learning

Source: Internet
Author: User

Darknet is a lightweight, fully C-and Cuda-based, open-source deep learning framework with the main features of easy installation, no dependencies (OpenCV can be used), very good portability, and support for CPU and GPU two computing methods.
1. Test source code (generalization process)
(1) Test image
A (forecast): load_network (NETWORK.C)---> network_predict (NETWORK.C)---> forward_network (NETWORK.C)---> Forward_ Yolo_layer (YOLO_LAYER.C)----> calc_network_cost (NETWORK.C)
B (post-processing): get_network_boxes (NETWORK.C)---> make_network_boxes (NETWORK.C)---> fill_network_boxes (NETWORK.C)--- > get_yolo_detections (YOLO_LAYER.C)
Do_nms_sort (BOX.C)---> draw_detections (image.c)---> save_image (image.c)
(2) Thresh effect in test process
In the A:get_yolo_detections interface:

for (n = 0; n < L.N; ++n) {
int obj_index = Entry_index (l, 0, n*l.w*l.h + i, 4);
float objectness = Predictions[obj_index];
if (objectness <= thresh) continue;
int box_index = Entry_index (l, 0, n*l.w*l.h + i, 0);
Dets[count].bbox = Get_yolo_box (predictions, l.biases, L.mask[n], Box_index, col, Row, L.W, L.h, NETW, Neth, l.w*l.h);
dets[count].objectness = objectness;
dets[count].classes = l.classes;
for (j = 0; j < l.classes; ++j) {
int class_index = Entry_index (l, 0, n*l.w*l.h + I, 4 + 1 + j);
float prob = Objectness*predictions[class_index];
DETS[COUNT].PROB[J] = (Prob > Thresh)? prob:0;

In the B:draw_detections interface:
int left = (b.x-b.w/2.) * IM.W;
int right = (b.x + B.W/2.) * IM.W;
int top = (b.y-b.h/2.) * IM.H;
int bot = (b.y + B.H/2.) * IM.H;

2. Train source code (training process)
(1) Parse, create, and configure each layer of net according to the configuration file (take the convolutional layer as an example), and configure the other parameters of net
Load_network (NETWORK.C)---> parse_network_cfg (PARSER.C)--->parse_convolutional (parser.c)--->make_ Convolutional_layer (CONVOLUTIONAL_LAYER.C);
Note: In the process of make_convolutional_layer, special attention should be paid to the configuration of the following function pointers, respectively, to determine the forward loss function, the inverse error function, the update function (to update the parameters)
void (*forward) (struct layer, struct network); ---> l.forward = forward_convolutional_layer;
void (*backward) (struct layer, struct network); ---> l.backward = backward_convolutional_layer;
void (*update) (struct layer, update_args); ---> l.update = update_convolutional_layer;

Parse_network_cfg (the concept processing configuration file for section list node)
Summary: The process finally gets a NET Framework created from the configuration file, with only the data being poured into

(2) Loading data
Load_thread (DATA.C)--->load_data_detection (DATA.C)--->fill_truth_detection (data.c read the label data for the image other datasets can also be modified here And then change the path)

(3) Start training
Train_network (NETWORK.C)---> train_network_datum (NETWORK.C network training \ Forward loss \ reverse error \ Last update network parameters)--->forward_network ( NETWORK.C)---> backward_network (NETWORK.C)---> Update_network (network.c) (Forward backward Update is processed using the corresponding layer's function respectively)

Darknet Source Learning

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.