Skip to content

Commit

Permalink
Update Darknet code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nuzhny007 committed Sep 15, 2020
1 parent e8662c0 commit dea9a72
Show file tree
Hide file tree
Showing 50 changed files with 3,139 additions and 566 deletions.
74 changes: 69 additions & 5 deletions src/Detector/darknet/include/darknet.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ typedef struct tree {

// activations.h
typedef enum {
LOGISTIC, RELU, RELU6, RELIE, LINEAR, RAMP, TANH, PLSE, LEAKY, ELU, LOGGY, STAIR, HARDTAN, LHTAN, SELU, GELU, SWISH, MISH, NORM_CHAN, NORM_CHAN_SOFTMAX, NORM_CHAN_SOFTMAX_MAXVAL
LOGISTIC, RELU, RELU6, RELIE, LINEAR, RAMP, TANH, PLSE, REVLEAKY, LEAKY, ELU, LOGGY, STAIR, HARDTAN, LHTAN, SELU, GELU, SWISH, MISH, HARD_MISH, NORM_CHAN, NORM_CHAN_SOFTMAX, NORM_CHAN_SOFTMAX_MAXVAL
}ACTIVATION;

// parser.h
Expand Down Expand Up @@ -142,6 +142,16 @@ typedef enum{
MULT, ADD, SUB, DIV
} BINARY_ACTIVATION;

// blas.h
typedef struct contrastive_params {
float sim;
float exp_sim;
float P;
int i, j;
int time_step_i, time_step_j;
} contrastive_params;


// layer.h
typedef enum {
CONVOLUTIONAL,
Expand All @@ -166,6 +176,7 @@ typedef enum {
GRU,
LSTM,
CONV_LSTM,
HISTORY,
CRNN,
BATCHNORM,
NETWORK,
Expand All @@ -180,7 +191,8 @@ typedef enum {
LOGXENT,
L2NORM,
EMPTY,
BLANK
BLANK,
CONTRASTIVE
} LAYER_TYPE;

// layer.h
Expand All @@ -205,6 +217,7 @@ typedef struct update_args {
struct layer {
LAYER_TYPE type;
ACTIVATION activation;
ACTIVATION lstm_activation;
COST_TYPE cost_type;
void(*forward) (struct layer, struct network_state);
void(*backward) (struct layer, struct network_state);
Expand All @@ -223,6 +236,7 @@ struct layer {
int flipped;
int inputs;
int outputs;
float mean_alpha;
int nweights;
int nbiases;
int extra;
Expand All @@ -231,6 +245,7 @@ struct layer {
int out_h, out_w, out_c;
int n;
int max_boxes;
int truth_size;
int groups;
int group_id;
int size;
Expand All @@ -241,8 +256,10 @@ struct layer {
int dilation;
int antialiasing;
int maxpool_depth;
int maxpool_zero_nonmax;
int out_channels;
int reverse;
float reverse;
int coordconv;
int flatten;
int spatial;
int pad;
Expand All @@ -257,18 +274,23 @@ struct layer {
int keep_delta_gpu;
int optimized_memory;
int steps;
int history_size;
int bottleneck;
float time_normalizer;
int state_constrain;
int hidden;
int truth;
float smooth;
float dot;
int deform;
int grad_centr;
int sway;
int rotate;
int stretch;
int stretch_sway;
float angle;
float jitter;
float resize;
float saturation;
float exposure;
float shift;
Expand All @@ -281,6 +303,15 @@ struct layer {
int noloss;
int softmax;
int classes;
int detection;
int embedding_layer_id;
float *embedding_output;
int embedding_size;
float sim_thresh;
int track_history_size;
int dets_for_track;
int dets_for_show;
float track_ciou_norm;
int coords;
int background;
int rescore;
Expand Down Expand Up @@ -351,12 +382,17 @@ struct layer {
float **layers_output;
float **layers_delta;
WEIGHTS_TYPE_T weights_type;
WEIGHTS_NORMALIZATION_T weights_normalizion;
WEIGHTS_NORMALIZATION_T weights_normalization;
int * map;
int * counts;
float ** sums;
float * rand;
float * cost;
int *labels;
float *cos_sim;
float *exp_cos_sim;
float *p_constrastive;
contrastive_params *contrast_p_gpu;
float * state;
float * prev_state;
float * forgot_state;
Expand All @@ -380,10 +416,13 @@ struct layer {
float *weight_updates;

float scale_x_y;
int objectness_smooth;
float max_delta;
float uc_normalizer;
float iou_normalizer;
float obj_normalizer;
float cls_normalizer;
float delta_normalizer;
IOU_LOSS iou_loss;
IOU_LOSS iou_thresh_kind;
NMS_KIND nms_kind;
Expand Down Expand Up @@ -514,6 +553,8 @@ struct layer {
float *r_gpu;
float *h_gpu;
float *stored_h_gpu;
float *bottelneck_hi_gpu;
float *bottelneck_delta_gpu;

float *temp_gpu;
float *temp2_gpu;
Expand Down Expand Up @@ -594,9 +635,11 @@ struct layer {

float * input_antialiasing_gpu;
float * output_gpu;
float * output_avg_gpu;
float * activation_input_gpu;
float * loss_gpu;
float * delta_gpu;
float * cos_sim_gpu;
float * rand_gpu;
float * drop_blocks_scale;
float * drop_blocks_scale_gpu;
Expand Down Expand Up @@ -659,6 +702,8 @@ typedef struct network {
float *output;
learning_rate_policy policy;
int benchmark_layers;
int *total_bbox;
int *rewritten_bbox;

float learning_rate;
float learning_rate_min;
Expand Down Expand Up @@ -706,7 +751,12 @@ typedef struct network {
int attention;
int adversarial;
float adversarial_lr;
float max_chart_loss;
int letter_box;
int mosaic_bound;
int contrastive;
int contrastive_jit_flip;
int unsupervised;
float angle;
float aspect;
float exposure;
Expand Down Expand Up @@ -828,6 +878,10 @@ typedef struct detection{
int sort_class;
float *uc; // Gaussian_YOLOv3 - tx,ty,tw,th uncertainty
int points; // bit-0 - center, bit-1 - top-left-corner, bit-2 - bottom-right-corner
float *embeddings; // embeddings for tracking
int embedding_size;
float sim;
int track_id;
} detection;

// network.c -batch inference
Expand Down Expand Up @@ -873,6 +927,7 @@ typedef struct load_args {
int nh;
int nw;
int num_boxes;
int truth_size;
int min, max, size;
int classes;
int background;
Expand All @@ -883,9 +938,13 @@ typedef struct load_args {
int track;
int augment_speed;
int letter_box;
int mosaic_bound;
int show_imgs;
int dontuse_opencv;
int contrastive;
int contrastive_jit_flip;
float jitter;
float resize;
int flip;
int gaussian_noise;
int blur;
Expand All @@ -906,6 +965,7 @@ typedef struct load_args {
// data.h
typedef struct box_label {
int id;
int track_id;
float x, y, w, h;
float left, right, top, bottom;
} box_label;
Expand All @@ -923,7 +983,6 @@ typedef struct box_label {
// node *front;
// node *back;
//} list;

// -----------------------------------------------------


Expand All @@ -932,6 +991,7 @@ LIB_API network *load_network(char *cfg, char *weights, int clear);
LIB_API network *load_network_custom(char *cfg, char *weights, int clear, int batch);
LIB_API network *load_network(char *cfg, char *weights, int clear);
LIB_API void free_network(network net);
LIB_API void free_network_ptr(network* net);

// network.c
LIB_API load_args get_base_args(network *net);
Expand Down Expand Up @@ -1019,6 +1079,10 @@ void stop_timer_and_show();
void stop_timer_and_show_name(char *name);
void show_total_time();

LIB_API void set_track_id(detection *new_dets, int new_dets_num, float thresh, float sim_thresh, float track_ciou_norm, int deque_size, int dets_for_track, int dets_for_show);
LIB_API int fill_remaining_id(detection *new_dets, int new_dets_num, int new_track_id, float thresh);


// gemm.h
LIB_API void init_cpu();

Expand Down
3 changes: 1 addition & 2 deletions src/Detector/darknet/include/yolo_v2_class.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -851,8 +851,7 @@ class track_kalman_t


track_kalman_t(int _max_objects = 1000, int _min_frames = 3, float _max_dist = 40, cv::Size _img_size = cv::Size(10000, 10000)) :
max_objects(_max_objects), min_frames(_min_frames), max_dist(_max_dist), img_size(_img_size),
track_id_counter(0)
track_id_counter(0), max_objects(_max_objects), min_frames(_min_frames), max_dist(_max_dist), img_size(_img_size)
{
kalman_vec.resize(max_objects);
track_id_state_id_time.resize(max_objects);
Expand Down
Loading

0 comments on commit dea9a72

Please sign in to comment.