Darknet/YOLO v3.0-177-gfa2353b
Object Detection Framework
 
Loading...
Searching...
No Matches
darknet_network.cpp File Reference
Include dependency graph for darknet_network.cpp:

Functions

void backward_network (Darknet::Network &net, Darknet::NetworkState state)
 
void calculate_binary_weights (DarknetNetworkPtr ptr)
 This is part of the original C API.
 
void copy_cudnn_descriptors (const Darknet::Layer &src, Darknet::Layer *dst)
 
void copy_weights_net (const Darknet::Network &net_train, Darknet::Network *net_map)
 
void custom_get_region_detections (const Darknet::Layer &l, int w, int h, int net_w, int net_h, float thresh, int *map, float hier, int relative, Darknet::Detection *dets, int letter)
 
void ema_apply (Darknet::Network &net)
 
void ema_update (Darknet::Network &net, float ema_alpha)
 
void fill_network_boxes (Darknet::Network *net, int w, int h, float thresh, float hier, int *map, int relative, Darknet::Detection *dets, int letter)
 
void fill_network_boxes_batch (Darknet::Network *net, int w, int h, float thresh, float hier, int *map, int relative, Darknet::Detection *dets, int letter, int batch)
 
static void fill_network_boxes_v3 (Darknet::Network *net, int w, int h, float thresh, float hier, int *map, int relative, Darknet::Detection *dets, int letter, Darknet::Output_Object_Cache &cache)
 
void forward_blank_layer (Darknet::Layer &l, Darknet::NetworkState state)
 
void forward_network (Darknet::Network &net, Darknet::NetworkState state)
 
void free_batch_detections (det_num_pair *det_num_pairs, int n)
 
void free_detections (detection *dets, int n)
 This is part of the original C API. Do not use in new code.
 
void free_network (Darknet::Network &net)
 Free all memory allocations for the given neural network.
 
void free_network_ptr (DarknetNetworkPtr ptr)
 This is part of the original C API.
 
void free_network_recurrent_state (Darknet::Network &net)
 
void fuse_conv_batchnorm (Darknet::Network &net)
 
int get_current_batch (const Darknet::Network &net)
 
int64_t get_current_iteration (const Darknet::Network &net)
 
float get_current_rate (const Darknet::Network &net)
 
float get_current_seq_subdivisions (const Darknet::Network &net)
 
detectionget_network_boxes (DarknetNetworkPtr ptr, int w, int h, float thresh, float hier, int *map, int relative, int *num, int letter)
 This is part of the original C API.
 
float get_network_cost (const Darknet::Network &net)
 
Darknet::Image get_network_image (Darknet::Network &net)
 
Darknet::Image get_network_image_layer (Darknet::Network &net, int i)
 
int get_network_input_size (Darknet::Network &net)
 
float * get_network_output (Darknet::Network &net)
 
int get_network_output_size (Darknet::Network &net)
 
int get_sequence_value (const Darknet::Network &net)
 
int is_ema_initialized (const Darknet::Network &net)
 
static float lrelu (float src)
 
Darknet::Network make_network (int n)
 Think of this as the constructor for the Darknet::Network object.
 
detectionmake_network_boxes (DarknetNetworkPtr ptr, float thresh, int *num)
 This is part of the original C API.
 
Darknet::Detectionmake_network_boxes_batch (Darknet::Network *net, float thresh, int *num, int batch)
 
Darknet::Detectionmake_network_boxes_v3 (Darknet::Network *net, const float thresh, int *num, Darknet::Output_Object_Cache &cache)
 
int network_height (Darknet::Network *net)
 
float * network_predict (Darknet::Network &net, float *input)
 
det_num_pairnetwork_predict_batch (Darknet::Network *net, Darknet::Image im, int batch_size, int w, int h, float thresh, float hier, int *map, int relative, int letter)
 
matrix network_predict_data (Darknet::Network &net, data test)
 
matrix network_predict_data_multi (Darknet::Network &net, data test, int n)
 
float * network_predict_image (DarknetNetworkPtr ptr, const DarknetImage im)
 This is part of the original C API.
 
float * network_predict_image_letterbox (DarknetNetworkPtr ptr, DarknetImage im)
 This is part of the original C API.
 
float * network_predict_ptr (DarknetNetworkPtr ptr, float *input)
 This is part of the original C API.
 
int network_width (Darknet::Network *net)
 
int num_detections (Darknet::Network *net, float thresh)
 
int num_detections_batch (Darknet::Network *net, float thresh, int batch)
 
int num_detections_v3 (Darknet::Network *net, float thresh, Darknet::Output_Object_Cache &cache)
 
int recalculate_workspace_size (Darknet::Network *net)
 
void reject_similar_weights (Darknet::Network &net, float sim_threshold)
 
void reset_network_state (Darknet::Network *net, int b)
 
void reset_rnn (DarknetNetworkPtr ptr)
 This is part of the original C API.
 
int resize_network (Darknet::Network *net, int w, int h)
 
void restore_network_recurrent_state (Darknet::Network &net)
 
void set_batch_network (Darknet::Network *net, int b)
 
float train_network (Darknet::Network &net, data d)
 
float train_network_batch (Darknet::Network net, data d, int n)
 
float train_network_datum (Darknet::Network &net, float *x, float *y)
 
float train_network_waitkey (Darknet::Network &net, data d, int wait_key)
 
void update_network (Darknet::Network &net)
 
void visualize_network (Darknet::Network &net)
 

Function Documentation

◆ backward_network()

void backward_network ( Darknet::Network net,
Darknet::NetworkState  state 
)
Here is the caller graph for this function:

◆ calculate_binary_weights()

void calculate_binary_weights ( DarknetNetworkPtr  ptr)

This is part of the original C API.

Do not use in new code.

See also
darknet_load_neural_network()
Darknet::load_neural_network()

If you were previously using calculate_binary_weights() from within C code, it used to pass the network by value. Starting with Darknet V3 in 2024-08-16, the network is now passed in as a pointer.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ copy_cudnn_descriptors()

void copy_cudnn_descriptors ( const Darknet::Layer src,
Darknet::Layer dst 
)
Here is the caller graph for this function:

◆ copy_weights_net()

void copy_weights_net ( const Darknet::Network net_train,
Darknet::Network net_map 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ custom_get_region_detections()

void custom_get_region_detections ( const Darknet::Layer l,
int  w,
int  h,
int  net_w,
int  net_h,
float  thresh,
int *  map,
float  hier,
int  relative,
Darknet::Detection dets,
int  letter 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ema_apply()

void ema_apply ( Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ ema_update()

void ema_update ( Darknet::Network net,
float  ema_alpha 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_network_boxes()

void fill_network_boxes ( Darknet::Network net,
int  w,
int  h,
float  thresh,
float  hier,
int *  map,
int  relative,
Darknet::Detection dets,
int  letter 
)
Todo:
V3 JAZZ: most of the time is spent in this function
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_network_boxes_batch()

void fill_network_boxes_batch ( Darknet::Network net,
int  w,
int  h,
float  thresh,
float  hier,
int *  map,
int  relative,
Darknet::Detection dets,
int  letter,
int  batch 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fill_network_boxes_v3()

static void fill_network_boxes_v3 ( Darknet::Network net,
int  w,
int  h,
float  thresh,
float  hier,
int *  map,
int  relative,
Darknet::Detection dets,
int  letter,
Darknet::Output_Object_Cache cache 
)
inlinestatic
Todo:
This assumes that "GAUSSIAN_YOLO", "REGION", and "DETECTION" layers don't exist, which is wrong. But they only exist in much older configurations which are hopefully not used anymore? Should we deprecate these?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ forward_blank_layer()

void forward_blank_layer ( Darknet::Layer l,
Darknet::NetworkState  state 
)
Here is the caller graph for this function:

◆ forward_network()

void forward_network ( Darknet::Network net,
Darknet::NetworkState  state 
)
Here is the call graph for this function:
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:

◆ free_detections()

void free_detections ( detection dets,
int  n 
)

This is part of the original C API. Do not use in new code.

Here is the caller graph for this function:

◆ free_network()

void free_network ( Darknet::Network net)

Free all memory allocations for the given neural network.

All of these functions perform the exact same task, so use the one that makes the most sense given your application. Some of these are C++ calls, some are C, some pass the network by refrence, some pass a pointer to the neural network.

See also
darknet_free_neural_network()
Darknet::free_neural_network()
free_network_ptr()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_network_ptr()

void free_network_ptr ( DarknetNetworkPtr  ptr)

This is part of the original C API.

Do not use in new code.

See also
darknet_free_neural_network()
Darknet::free_neural_network()

If you were previously using free_network() from within C code, please use free_network_ptr() instead by passing in the address of the network structure (pointer to the network).

Note
See the additional comments in free_network().
Here is the call graph for this function:
Here is the caller graph for this function:

◆ free_network_recurrent_state()

void free_network_recurrent_state ( Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ fuse_conv_batchnorm()

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

◆ get_current_batch()

int get_current_batch ( const Darknet::Network net)
Here is the caller graph for this function:

◆ get_current_iteration()

int64_t get_current_iteration ( const Darknet::Network net)
Here is the caller graph for this function:

◆ get_current_rate()

float get_current_rate ( const Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_current_seq_subdivisions()

float get_current_seq_subdivisions ( const Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_network_boxes()

detection * get_network_boxes ( DarknetNetworkPtr  ptr,
int  w,
int  h,
float  thresh,
float  hier,
int *  map,
int  relative,
int *  num,
int  letter 
)

This is part of the original C API.

Do not use in new code.

You must call free_detections() to free up memory once done with the detections.

See also
Darknet::predict()
free_detections()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_network_cost()

float get_network_cost ( const Darknet::Network net)
Here is the caller graph for this function:

◆ get_network_image()

Darknet::Image get_network_image ( Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_network_image_layer()

Darknet::Image get_network_image_layer ( Darknet::Network net,
int  i 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_network_input_size()

int get_network_input_size ( Darknet::Network net)
Here is the caller graph for this function:

◆ get_network_output()

float * get_network_output ( Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_network_output_size()

int get_network_output_size ( Darknet::Network net)
Here is the caller graph for this function:

◆ get_sequence_value()

int get_sequence_value ( const Darknet::Network net)
Here is the caller graph for this function:

◆ is_ema_initialized()

int is_ema_initialized ( const Darknet::Network net)
Here is the caller graph for this function:

◆ lrelu()

static float lrelu ( float  src)
static

◆ make_network()

Darknet::Network make_network ( int  n)

Think of this as the constructor for the Darknet::Network object.

Parameters
[in]nThe number of network layers to initialize.
Here is the caller graph for this function:

◆ make_network_boxes()

detection * make_network_boxes ( DarknetNetworkPtr  ptr,
float  thresh,
int *  num 
)

This is part of the original C API.

See also
make_network_boxes_batch()
Todo:
V3 JAZZ: this is where we spend all our time
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_network_boxes_batch()

Darknet::Detection * make_network_boxes_batch ( Darknet::Network net,
float  thresh,
int *  num,
int  batch 
)
See also
make_network_boxes()
Here is the call graph for this function:
Here is the caller graph for this function:

◆ make_network_boxes_v3()

Darknet::Detection * make_network_boxes_v3 ( Darknet::Network net,
const float  thresh,
int *  num,
Darknet::Output_Object_Cache cache 
)
Todo:
Is anything but YOLO still used as an output layer in a modern .cfg file? Should these be removed?
Todo:
V3 JAZZ: 97% of this function is spent in this next line
Here is the call graph for this function:
Here is the caller graph for this function:

◆ network_height()

int network_height ( Darknet::Network net)
Here is the caller graph for this function:

◆ network_predict()

float * network_predict ( Darknet::Network net,
float *  input 
)
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 ( Darknet::Network net,
Darknet::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:

◆ network_predict_data()

matrix network_predict_data ( Darknet::Network net,
data  test 
)
Here is the call graph for this function:

◆ network_predict_data_multi()

matrix network_predict_data_multi ( Darknet::Network net,
data  test,
int  n 
)
Here is the call graph for this function:

◆ network_predict_image()

float * network_predict_image ( DarknetNetworkPtr  ptr,
const DarknetImage  im 
)

This is part of the original C API.

Do not use in new code.

See also
network_predict_ptr()
Darknet::predict()
Here is the call graph for this function:

◆ network_predict_image_letterbox()

float * network_predict_image_letterbox ( DarknetNetworkPtr  ptr,
DarknetImage  im 
)

This is part of the original C API.

Here is the call graph for this function:

◆ network_predict_ptr()

float * network_predict_ptr ( DarknetNetworkPtr  ptr,
float *  input 
)

This is part of the original C API.

Do not use in new code.

See also
network_predict_image()
Darknet::predict()

If you were previously using network_predict() from within C code, please use network_predict_ptr() instead by passing in the address of the network structure (pointer to the network).

Here is the call graph for this function:

◆ network_width()

int network_width ( Darknet::Network net)
Here is the caller graph for this function:

◆ num_detections()

int num_detections ( Darknet::Network net,
float  thresh 
)
Todo:
V3 JAZZ: this is where we spend all our time
Here is the call graph for this function:
Here is the caller graph for this function:

◆ num_detections_batch()

int num_detections_batch ( Darknet::Network net,
float  thresh,
int  batch 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ num_detections_v3()

int num_detections_v3 ( Darknet::Network net,
float  thresh,
Darknet::Output_Object_Cache cache 
)
Todo:
V3 JAZZ: this is where we spend all our time
Todo:
Is this still used in a modern .cfg file? Should it be removed?
Todo:
Is this still used in a modern .cfg file? Should it be removed?
Here is the call graph for this function:
Here is the caller graph for this function:

◆ recalculate_workspace_size()

int recalculate_workspace_size ( Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reject_similar_weights()

void reject_similar_weights ( Darknet::Network net,
float  sim_threshold 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_network_state()

void reset_network_state ( Darknet::Network net,
int  b 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ reset_rnn()

void reset_rnn ( DarknetNetworkPtr  ptr)

This is part of the original C API.

Here is the call graph for this function:

◆ resize_network()

int resize_network ( Darknet::Network net,
int  w,
int  h 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ restore_network_recurrent_state()

void restore_network_recurrent_state ( Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ set_batch_network()

void set_batch_network ( Darknet::Network net,
int  b 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ train_network()

float train_network ( Darknet::Network net,
data  d 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ train_network_batch()

float train_network_batch ( Darknet::Network  net,
data  d,
int  n 
)
Here is the call graph for this function:

◆ train_network_datum()

float train_network_datum ( Darknet::Network net,
float *  x,
float *  y 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ train_network_waitkey()

float train_network_waitkey ( Darknet::Network net,
data  d,
int  wait_key 
)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_network()

void update_network ( Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ visualize_network()

void visualize_network ( Darknet::Network net)
Here is the call graph for this function:
Here is the caller graph for this function: