Darknet/YOLO  v2.0-219-g5d379a6
Object Detection Framework
darknet.h File Reference
Include dependency graph for darknet.h:
This graph shows which files directly or indirectly include this file:

Classes

struct  metadata
 
struct  tree
 
struct  contrastive_params
 
struct  update_args
 
struct  layer
 
struct  network
 
struct  network_state
 
struct  image
 
struct  box
 
struct  boxabs
 
struct  dxrep
 
struct  ious
 
struct  detection
 
struct  det_num_pair
 
struct  matrix
 
struct  data
 
struct  load_args
 Used when a secondary thread is created to load things, such as images. More...
 
struct  box_label
 

Macros

#define SECRET_NUM   -1234
 

Typedefs

typedef struct network network
 
typedef struct network_state network_state
 
typedef struct layer layer
 
typedef struct image image
 
typedef struct detection detection
 
typedef struct load_args load_args
 Used when a secondary thread is created to load things, such as images. More...
 
typedef struct data data
 
typedef struct metadata metadata
 
typedef struct tree tree
 
typedef struct contrastive_params contrastive_params
 
typedef struct update_args update_args
 
typedef struct box box
 
typedef struct boxabs boxabs
 
typedef struct dxrep dxrep
 
typedef struct ious ious
 
typedef struct det_num_pair det_num_pair
 
typedef struct det_num_pairpdet_num_pair
 
typedef struct matrix matrix
 
typedef struct box_label box_label
 

Enumerations

enum  UNUSED_ENUM_TYPE { UNUSED_DEF_VAL }
 
enum  ACTIVATION {
  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
}
 
enum  IOU_LOSS {
  IOU ,
  GIOU ,
  MSE ,
  DIOU ,
  CIOU
}
 
enum  NMS_KIND {
  DEFAULT_NMS ,
  GREEDY_NMS ,
  DIOU_NMS ,
  CORNERS_NMS
}
 
enum  YOLO_POINT {
  YOLO_CENTER = 1 << 0 ,
  YOLO_LEFT_TOP = 1 << 1 ,
  YOLO_RIGHT_BOTTOM = 1 << 2
}
 
enum  WEIGHTS_TYPE_T {
  NO_WEIGHTS ,
  PER_FEATURE ,
  PER_CHANNEL
}
 
enum  WEIGHTS_NORMALIZATION_T {
  NO_NORMALIZATION ,
  RELU_NORMALIZATION ,
  SOFTMAX_NORMALIZATION
}
 
enum  IMTYPE {
  PNG ,
  BMP ,
  TGA ,
  JPG
}
 
enum  BINARY_ACTIVATION {
  MULT ,
  ADD ,
  SUB ,
  DIV
}
 
enum  LAYER_TYPE {
  CONVOLUTIONAL ,
  DECONVOLUTIONAL ,
  CONNECTED ,
  MAXPOOL ,
  LOCAL_AVGPOOL ,
  SOFTMAX ,
  DETECTION ,
  DROPOUT ,
  CROP ,
  ROUTE ,
  COST ,
  NORMALIZATION ,
  AVGPOOL ,
  LOCAL ,
  SHORTCUT ,
  SCALE_CHANNELS ,
  SAM ,
  ACTIVE ,
  RNN ,
  GRU ,
  LSTM ,
  CONV_LSTM ,
  HISTORY ,
  CRNN ,
  BATCHNORM ,
  NETWORK ,
  XNOR ,
  REGION ,
  YOLO ,
  GAUSSIAN_YOLO ,
  ISEG ,
  REORG ,
  REORG_OLD ,
  UPSAMPLE ,
  LOGXENT ,
  L2NORM ,
  EMPTY ,
  BLANK ,
  CONTRASTIVE ,
  IMPLICIT
}
 
enum  COST_TYPE {
  SSE ,
  MASKED ,
  L1 ,
  SEG ,
  SMOOTH ,
  WGAN
}
 
enum  learning_rate_policy {
  CONSTANT ,
  STEP ,
  EXP ,
  POLY ,
  STEPS ,
  SIG ,
  RANDOM ,
  SGDR
}
 
enum  data_type {
  CLASSIFICATION_DATA ,
  DETECTION_DATA ,
  REGION_DATA ,
  IMAGE_DATA ,
  COMPARE_DATA ,
  WRITING_DATA ,
  TAG_DATA ,
  OLD_CLASSIFICATION_DATA ,
  SUPER_DATA ,
  LETTERBOX_DATA
}
 Things that we can do on a secondary thread. More...
 

Functions

networkload_network (char *cfg, char *weights, int clear)
 
networkload_network_custom (char *cfg, char *weights, int clear, int batch)
 
void free_network (network net)
 
void free_network_ptr (network *net)
 
load_args get_base_args (network *net)
 
void do_nms_sort (detection *dets, int total, int classes, float thresh)
 
void do_nms_obj (detection *dets, int total, int classes, float thresh)
 
void diounms_sort (detection *dets, int total, int classes, float thresh, NMS_KIND nms_kind, float beta1)
 
float * network_predict (network net, float *input)
 
float * network_predict_ptr (network *net, float *input)
 
detectionget_network_boxes (network *net, int w, int h, float thresh, float hier, int *map, int relative, int *num, int letter)
 
det_num_pairnetwork_predict_batch (network *net, image im, int batch_size, int w, int h, float thresh, float hier, int *map, int relative, int letter)
 
void free_detections (detection *dets, int n)
 
void free_batch_detections (det_num_pair *det_num_pairs, int n)
 
void fuse_conv_batchnorm (network net)
 
void calculate_binary_weights (network net)
 
char * detection_to_json (detection *dets, int nboxes, int classes, char **names, long long int frame_id, char *filename)
 
layerget_network_layer (network *net, int i)
 
detectionmake_network_boxes (network *net, float thresh, int *num)
 
void reset_rnn (network *net)
 
float * network_predict_image (network *net, image im)
 
float * network_predict_image_letterbox (network *net, image im)
 
float validate_detector_map (char *datacfg, char *cfgfile, char *weightfile, float thresh_calc_avg_iou, const float iou_thresh, const int map_points, int letter_box, network *existing_net)
 
void train_detector (char *datacfg, char *cfgfile, char *weightfile, int *gpus, int ngpus, int clear, int dont_show, int calc_map, float thresh, float iou_thresh, int mjpeg_port, int show_imgs, int benchmark_layers, char *chart_path)
 
void test_detector (char *datacfg, char *cfgfile, char *weightfile, char *filename, float thresh, float hier_thresh, int dont_show, int ext_output, int save_labels, char *outfile, int letter_box, int benchmark_layers)
 
int network_width (network *net)
 
int network_height (network *net)
 
void optimize_picture (network *net, image orig, int max_layer, float scale, float rate, float thresh, int norm)
 
void make_image_red (image im)
 
image make_attention_image (int img_size, float *original_delta_cpu, float *original_input_cpu, int w, int h, int c, float alpha)
 
image resize_image (image im, int w, int h)
 
void quantize_image (image im)
 
void copy_image_from_bytes (image im, char *pdata)
 
image letterbox_image (image im, int w, int h)
 
void rgbgr_image (image im)
 
image make_image (int w, int h, int c)
 
image load_image (char *filename, int w, int h, int c)
 
void free_image (image m)
 
image crop_image (image im, int dx, int dy, int w, int h)
 
image resize_min (image im, int min)
 
void free_layer_custom (layer l, int keep_cudnn_desc)
 
void free_layer (layer l)
 
void cuda_pull_array (float *x_gpu, float *x, size_t n)
 
void cuda_pull_array_async (float *x_gpu, float *x, size_t n)
 
void cuda_set_device (int n)
 
void * cuda_get_context ()
 
void free_ptrs (void **ptrs, int n)
 
void top_k (float *a, int n, int k, int *index)
 
treeread_tree (char *filename)
 
metadata get_metadata (char *file)
 
void delete_json_sender ()
 
void send_json_custom (char const *send_buf, int port, int timeout)
 
double get_time_point ()
 
void start_timer ()
 
void stop_timer ()
 
double get_time ()
 
void stop_timer_and_show ()
 
void stop_timer_and_show_name (char *name)
 
void show_total_time ()
 
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)
 
int fill_remaining_id (detection *new_dets, int new_dets_num, int new_track_id, float thresh)
 
void init_cpu ()
 

Macro Definition Documentation

◆ SECRET_NUM

#define SECRET_NUM   -1234
Todo:
what is this?

Typedef Documentation

◆ network

typedef struct network network

◆ network_state

typedef struct network_state network_state

◆ layer

typedef struct layer layer

◆ image

typedef struct image image

◆ detection

typedef struct detection detection

◆ load_args

typedef struct load_args load_args

Used when a secondary thread is created to load things, such as images.

See also
load_image()
data_type

◆ data

typedef struct data data

◆ metadata

typedef struct metadata metadata

◆ tree

typedef struct tree tree

◆ contrastive_params

◆ update_args

typedef struct update_args update_args

◆ box

typedef struct box box

◆ boxabs

typedef struct boxabs boxabs

◆ dxrep

typedef struct dxrep dxrep

◆ ious

typedef struct ious ious

◆ det_num_pair

typedef struct det_num_pair det_num_pair

◆ pdet_num_pair

typedef struct det_num_pair * pdet_num_pair

◆ matrix

typedef struct matrix matrix

◆ box_label

typedef struct box_label box_label

Enumeration Type Documentation

◆ UNUSED_ENUM_TYPE

Enumerator
UNUSED_DEF_VAL 

◆ ACTIVATION

enum ACTIVATION
Enumerator
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 

◆ IOU_LOSS

enum IOU_LOSS
Enumerator
IOU 
GIOU 
MSE 
DIOU 
CIOU 

◆ NMS_KIND

enum NMS_KIND
Enumerator
DEFAULT_NMS 
GREEDY_NMS 
DIOU_NMS 
CORNERS_NMS 

◆ YOLO_POINT

enum YOLO_POINT
Enumerator
YOLO_CENTER 
YOLO_LEFT_TOP 
YOLO_RIGHT_BOTTOM 

◆ WEIGHTS_TYPE_T

Enumerator
NO_WEIGHTS 
PER_FEATURE 
PER_CHANNEL 

◆ WEIGHTS_NORMALIZATION_T

Enumerator
NO_NORMALIZATION 
RELU_NORMALIZATION 
SOFTMAX_NORMALIZATION 

◆ IMTYPE

enum IMTYPE
Enumerator
PNG 
BMP 
TGA 
JPG 

◆ BINARY_ACTIVATION

Enumerator
MULT 
ADD 
SUB 
DIV 

◆ LAYER_TYPE

enum LAYER_TYPE
Enumerator
CONVOLUTIONAL 
DECONVOLUTIONAL 
CONNECTED 
MAXPOOL 
LOCAL_AVGPOOL 
SOFTMAX 
DETECTION 
DROPOUT 
CROP 
ROUTE 
COST 
NORMALIZATION 
AVGPOOL 
LOCAL 
SHORTCUT 
SCALE_CHANNELS 
SAM 
ACTIVE 
RNN 
GRU 
LSTM 
CONV_LSTM 
HISTORY 
CRNN 
BATCHNORM 
NETWORK 
XNOR 
REGION 
YOLO 
GAUSSIAN_YOLO 
ISEG 
REORG 
REORG_OLD 
UPSAMPLE 
LOGXENT 
L2NORM 
EMPTY 
BLANK 
CONTRASTIVE 
IMPLICIT 

◆ COST_TYPE

enum COST_TYPE
Enumerator
SSE 
MASKED 
L1 
SEG 
SMOOTH 
WGAN 

◆ learning_rate_policy

Enumerator
CONSTANT 
STEP 
EXP 
POLY 
STEPS 
SIG 
RANDOM 
SGDR 

◆ data_type

enum data_type

Things that we can do on a secondary thread.

See also
load_thread()
load_args::type
Enumerator
CLASSIFICATION_DATA 
DETECTION_DATA 
REGION_DATA 
IMAGE_DATA 

causes load_image() and resize_image() to be called

COMPARE_DATA 
WRITING_DATA 
TAG_DATA 
OLD_CLASSIFICATION_DATA 
SUPER_DATA 
LETTERBOX_DATA 

Function Documentation

◆ load_network()

network* load_network ( char *  cfg,
char *  weights,
int  clear 
)
Here is the call graph for this function:

◆ load_network_custom()

network* load_network_custom ( char *  cfg,
char *  weights,
int  clear,
int  batch 
)
Here is the call graph for this function:

◆ free_network()

void free_network ( network  net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_network_ptr()

void free_network_ptr ( network net)
Here is the call graph for this function:

◆ get_base_args()

load_args get_base_args ( network net)

◆ do_nms_sort()

void do_nms_sort ( detection dets,
int  total,
int  classes,
float  thresh 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ do_nms_obj()

void do_nms_obj ( detection dets,
int  total,
int  classes,
float  thresh 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ diounms_sort()

void diounms_sort ( detection dets,
int  total,
int  classes,
float  thresh,
NMS_KIND  nms_kind,
float  beta1 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ network_predict()

float* network_predict ( network  net,
float *  input 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ network_predict_ptr()

float* network_predict_ptr ( network net,
float *  input 
)
Here is the call graph for this function:

◆ get_network_boxes()

detection* get_network_boxes ( network net,
int  w,
int  h,
float  thresh,
float  hier,
int *  map,
int  relative,
int *  num,
int  letter 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ network_predict_batch()

det_num_pair* network_predict_batch ( network net,
image  im,
int  batch_size,
int  w,
int  h,
float  thresh,
float  hier,
int *  map,
int  relative,
int  letter 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_detections()

void free_detections ( detection dets,
int  n 
)
Here is the caller graph for this function:

◆ free_batch_detections()

void free_batch_detections ( det_num_pair det_num_pairs,
int  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuse_conv_batchnorm()

void fuse_conv_batchnorm ( network  net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ calculate_binary_weights()

void calculate_binary_weights ( network  net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ detection_to_json()

char* detection_to_json ( detection dets,
int  nboxes,
int  classes,
char **  names,
long long int  frame_id,
char *  filename 
)
Here is the caller graph for this function:

◆ get_network_layer()

layer* get_network_layer ( network net,
int  i 
)

◆ make_network_boxes()

detection* make_network_boxes ( network net,
float  thresh,
int *  num 
)
See also
make_network_boxes_batch()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_rnn()

void reset_rnn ( network net)
Here is the call graph for this function:

◆ network_predict_image()

float* network_predict_image ( network net,
image  im 
)
Here is the call graph for this function:

◆ network_predict_image_letterbox()

float* network_predict_image_letterbox ( network net,
image  im 
)
Here is the call graph for this function:

◆ validate_detector_map()

float validate_detector_map ( char *  datacfg,
char *  cfgfile,
char *  weightfile,
float  thresh_calc_avg_iou,
const float  iou_thresh,
const int  map_points,
int  letter_box,
network existing_net 
)
Todo:
how many cores do we have available?
Todo:
I think this is TP + FN (where the object actually exists, and we either found it, or missed it)
Todo:
would we save anything if net was passed in by reference?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ train_detector()

void train_detector ( char *  datacfg,
char *  cfgfile,
char *  weightfile,
int *  gpus,
int  ngpus,
int  clear,
int  dont_show,
int  calc_map,
float  thresh,
float  iou_thresh,
int  mjpeg_port,
int  show_imgs,
int  benchmark_layers,
char *  chart_path 
)
Todo:
copy the weights...?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ test_detector()

void test_detector ( char *  datacfg,
char *  cfgfile,
char *  weightfile,
char *  filename,
float  thresh,
float  hier_thresh,
int  dont_show,
int  ext_output,
int  save_labels,
char *  outfile,
int  letter_box,
int  benchmark_layers 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ network_width()

int network_width ( network net)

◆ network_height()

int network_height ( network net)

◆ optimize_picture()

void optimize_picture ( network net,
image  orig,
int  max_layer,
float  scale,
float  rate,
float  thresh,
int  norm 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_image_red()

void make_image_red ( image  im)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_attention_image()

image make_attention_image ( int  img_size,
float *  original_delta_cpu,
float *  original_input_cpu,
int  w,
int  h,
int  c,
float  alpha 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize_image()

image resize_image ( image  im,
int  w,
int  h 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ quantize_image()

void quantize_image ( image  im)
Here is the caller graph for this function:

◆ copy_image_from_bytes()

void copy_image_from_bytes ( image  im,
char *  pdata 
)

◆ letterbox_image()

image letterbox_image ( image  im,
int  w,
int  h 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ rgbgr_image()

void rgbgr_image ( image  im)
Here is the caller graph for this function:

◆ make_image()

image make_image ( int  w,
int  h,
int  c 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ load_image()

image load_image ( char *  filename,
int  w,
int  h,
int  c 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_image()

void free_image ( image  m)
Here is the caller graph for this function:

◆ crop_image()

image crop_image ( image  im,
int  dx,
int  dy,
int  w,
int  h 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ resize_min()

image resize_min ( image  im,
int  min 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_layer_custom()

void free_layer_custom ( layer  l,
int  keep_cudnn_desc 
)
Todo:
2023-06-26 For now I'd rather ignore this warning than to try and mess with this old code and risk breaking things.
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_layer()

void free_layer ( layer  l)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cuda_pull_array()

void cuda_pull_array ( float *  x_gpu,
float *  x,
size_t  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cuda_pull_array_async()

void cuda_pull_array_async ( float *  x_gpu,
float *  x,
size_t  n 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ cuda_set_device()

void cuda_set_device ( int  n)
Here is the caller graph for this function:

◆ cuda_get_context()

void* cuda_get_context ( )
Here is the caller graph for this function:

◆ free_ptrs()

void free_ptrs ( void **  ptrs,
int  n 
)
Here is the caller graph for this function:

◆ top_k()

void top_k ( float *  a,
int  n,
int  k,
int *  index 
)
Here is the caller graph for this function:

◆ read_tree()

tree* read_tree ( char *  filename)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_metadata()

metadata get_metadata ( char *  file)
Here is the call graph for this function:

◆ delete_json_sender()

void delete_json_sender ( )

◆ send_json_custom()

void send_json_custom ( char const *  send_buf,
int  port,
int  timeout 
)
Here is the call graph for this function:

◆ get_time_point()

double get_time_point ( )
Here is the caller graph for this function:

◆ start_timer()

void start_timer ( )

◆ stop_timer()

void stop_timer ( )

◆ get_time()

double get_time ( )

◆ stop_timer_and_show()

void stop_timer_and_show ( )
Here is the caller graph for this function:

◆ stop_timer_and_show_name()

void stop_timer_and_show_name ( char *  name)
Here is the call graph for this function:

◆ show_total_time()

void show_total_time ( )

◆ set_track_id()

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 
)
Here is the caller graph for this function:

◆ fill_remaining_id()

int fill_remaining_id ( detection new_dets,
int  new_dets_num,
int  new_track_id,
float  thresh 
)

◆ init_cpu()

void init_cpu ( )
Here is the call graph for this function:
Here is the caller graph for this function: