Darknet/YOLO v3.0-177-gfa2353b
Object Detection Framework
 
Loading...
Searching...
No Matches
Darknet::CfgAndState Class Referencefinal

#include "darknet_cfg_and_state.hpp"

Collaboration diagram for Darknet::CfgAndState:

Public Member Functions

 CfgAndState ()
 Constructor.
 
 ~CfgAndState ()
 Destructor.
 
void del_thread_name ()
 Alias for del_thread_name(). Uses the ID of the current running thread.
 
void del_thread_name (const std::thread &t)
 Alias for del_thread_name().
 
void del_thread_name (const std::thread::id &tid)
 Delete the thread name from the map. Does nothing if this thread wasn't given a name.
 
const ArgsAndParmsget (const std::string &arg) const
 Get a CLI argument based on the name.
 
float get (const std::string &arg, const float f) const
 Get a float parameter. This provided default value will be used if this parameter does not exist.
 
int get (const std::string &arg, const int i) const
 Get an integer parameter. The provided default value will be used if this parameter does not exist.
 
float get_float (const std::string &arg) const
 Get a float parameter. This must exist, otherwise darknet_fatal_error() is called.
 
int get_int (const std::string &arg) const
 Get an integer parameter. This must exist, otherwise darknet_fatal_error() is called.
 
std::string get_thread_name ()
 Return a name for the current thread. Thread name must previous have been added using set_thread_name().
 
bool is_set (const std::string &arg, const bool default_value=false) const
 Determine if the user specified the given option, or if unspecified then use the default value.
 
CfgAndStateprocess_arguments (const VStr &v, Darknet::NetworkPtr ptr=nullptr)
 Process the given arguments.
 
CfgAndStateprocess_arguments (int argc, char **argp)
 Process argv[] from main() and store the results in argv and args.
 
CfgAndStatereset ()
 Clear out all settings and state to a known initial state.
 
void set_thread_name (const std::string &name)
 Alias for set_thread_name(). Uses the ID of the current running thread.
 
void set_thread_name (const std::thread &t, const std::string &name)
 Alias for set_thread_name().
 
void set_thread_name (const std::thread::id &tid, const std::string &name)
 Set a name to use for the given thread.
 

Static Public Member Functions

static CfgAndStateget ()
 Get a reference to the singleton used by Darknet.
 

Public Attributes

VStr additional_arguments
 Parameters that were unrecognized.
 
MArgsAndParms args
 A map of all arguments starting with argv[1].
 
VStr argv
 Every argument starting with argv[0], unmodified, and in the exact order they were specified.
 
std::filesystem::path cfg_filename
 
bool colour_is_enabled
 Determines if ANSI colour output will be used with the console output. Default is true.
 
std::string command
 
std::filesystem::path data_filename
 
VStr filenames
 
std::string function
 
int gpu_index
 The index of the GPU to use. -1 means no GPU is selected.
 
bool is_shown
 When -dont_show has been set, this value will be set to false.
 
bool is_trace
 Whether Darknet was started with the --trace flag.
 
bool is_verbose
 Whether Darknet was started with the --verbose flag.
 
std::atomic< bool > must_immediately_exit
 This bool gets set by darknet_fatal_error() when a thread terminates and Darknet must exit.
 
std::filesystem::path names_filename
 
std::filesystem::path weights_filename
 
std::mutex thread_names_mutex
 Name the threads that we create in case we have to report an error.
 
std::map< std::thread::id, std::string > thread_names
 Name the threads that we create in case we have to report an error.
 

Constructor & Destructor Documentation

◆ CfgAndState()

Darknet::CfgAndState::CfgAndState ( )

Constructor.

Here is the call graph for this function:

◆ ~CfgAndState()

Darknet::CfgAndState::~CfgAndState ( )

Destructor.

Member Function Documentation

◆ del_thread_name() [1/3]

void Darknet::CfgAndState::del_thread_name ( )
inline

Alias for del_thread_name(). Uses the ID of the current running thread.

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

◆ del_thread_name() [2/3]

void Darknet::CfgAndState::del_thread_name ( const std::thread &  t)
inline

Alias for del_thread_name().

Here is the call graph for this function:

◆ del_thread_name() [3/3]

void Darknet::CfgAndState::del_thread_name ( const std::thread::id &  tid)

Delete the thread name from the map. Does nothing if this thread wasn't given a name.

◆ get() [1/4]

Darknet::CfgAndState & Darknet::CfgAndState::get ( )
static

Get a reference to the singleton used by Darknet.

Here is the caller graph for this function:

◆ get() [2/4]

const Darknet::ArgsAndParms & Darknet::CfgAndState::get ( const std::string &  arg) const

Get a CLI argument based on the name.

For example, if you call it with "thresh" you'd get the threshold argument with the default value of 0.24 or whatever the user typed on the CLI.

Here is the call graph for this function:

◆ get() [3/4]

float Darknet::CfgAndState::get ( const std::string &  arg,
const float  f 
) const

Get a float parameter. This provided default value will be used if this parameter does not exist.

Here is the call graph for this function:

◆ get() [4/4]

int Darknet::CfgAndState::get ( const std::string &  arg,
const int  i 
) const

Get an integer parameter. The provided default value will be used if this parameter does not exist.

◆ get_float()

float Darknet::CfgAndState::get_float ( const std::string &  arg) const

Get a float parameter. This must exist, otherwise darknet_fatal_error() is called.

Here is the call graph for this function:

◆ get_int()

int Darknet::CfgAndState::get_int ( const std::string &  arg) const

Get an integer parameter. This must exist, otherwise darknet_fatal_error() is called.

◆ get_thread_name()

std::string Darknet::CfgAndState::get_thread_name ( )

Return a name for the current thread. Thread name must previous have been added using set_thread_name().

◆ is_set()

bool Darknet::CfgAndState::is_set ( const std::string &  arg,
const bool  default_value = false 
) const

Determine if the user specified the given option, or if unspecified then use the default value.

For example:

if (cfg.is_set("map"))
{
// do something when the user specified -map
}
Here is the call graph for this function:

◆ process_arguments() [1/2]

Darknet::CfgAndState & Darknet::CfgAndState::process_arguments ( const VStr v,
Darknet::NetworkPtr  ptr = nullptr 
)

Process the given arguments.

Todo:
need to fix things like the function "map" and the optional training parameter "-map" which would trigger this code
Here is the call graph for this function:

◆ process_arguments() [2/2]

Darknet::CfgAndState & Darknet::CfgAndState::process_arguments ( int  argc,
char **  argp 
)

Process argv[] from main() and store the results in argv and args.

◆ reset()

Darknet::CfgAndState & Darknet::CfgAndState::reset ( )

Clear out all settings and state to a known initial state.

Here is the caller graph for this function:

◆ set_thread_name() [1/3]

void Darknet::CfgAndState::set_thread_name ( const std::string &  name)
inline

Alias for set_thread_name(). Uses the ID of the current running thread.

Here is the call graph for this function:

◆ set_thread_name() [2/3]

void Darknet::CfgAndState::set_thread_name ( const std::thread &  t,
const std::string &  name 
)
inline

Alias for set_thread_name().

Here is the call graph for this function:

◆ set_thread_name() [3/3]

void Darknet::CfgAndState::set_thread_name ( const std::thread::id &  tid,
const std::string &  name 
)

Set a name to use for the given thread.

See also
del_thread_name()
Here is the caller graph for this function:

Member Data Documentation

◆ additional_arguments

VStr Darknet::CfgAndState::additional_arguments

Parameters that were unrecognized.

◆ args

MArgsAndParms Darknet::CfgAndState::args

A map of all arguments starting with argv[1].

Note this only has the arguments the user specified, not a collection of "all" possible arguments.

See also
Darknet::get_all_possible_arguments()

◆ argv

VStr Darknet::CfgAndState::argv

Every argument starting with argv[0], unmodified, and in the exact order they were specified.

◆ cfg_filename

std::filesystem::path Darknet::CfgAndState::cfg_filename

◆ colour_is_enabled

bool Darknet::CfgAndState::colour_is_enabled

Determines if ANSI colour output will be used with the console output. Default is true.

◆ command

std::string Darknet::CfgAndState::command

◆ data_filename

std::filesystem::path Darknet::CfgAndState::data_filename

◆ filenames

VStr Darknet::CfgAndState::filenames

◆ function

std::string Darknet::CfgAndState::function

◆ gpu_index

int Darknet::CfgAndState::gpu_index

The index of the GPU to use. -1 means no GPU is selected.

◆ is_shown

bool Darknet::CfgAndState::is_shown

When -dont_show has been set, this value will be set to false.

◆ is_trace

bool Darknet::CfgAndState::is_trace

Whether Darknet was started with the --trace flag.

This will also enable is_verbose. Default is false.

See also
Darknet::set_trace()
darknet_set_trace()
is_verbose

◆ is_verbose

bool Darknet::CfgAndState::is_verbose

Whether Darknet was started with the --verbose flag.

Default is false.

See also
Darknet::set_verbose()
darknet_set_verbose()
is_trace

◆ must_immediately_exit

std::atomic<bool> Darknet::CfgAndState::must_immediately_exit

This bool gets set by darknet_fatal_error() when a thread terminates and Darknet must exit.

This causes training to finish early, and also prevents Darknet from logging any more (misleading) errors that happen on additional threads.

◆ names_filename

std::filesystem::path Darknet::CfgAndState::names_filename

◆ thread_names

std::map<std::thread::id, std::string> Darknet::CfgAndState::thread_names

Name the threads that we create in case we have to report an error.

◆ thread_names_mutex

std::mutex Darknet::CfgAndState::thread_names_mutex

Name the threads that we create in case we have to report an error.

◆ weights_filename

std::filesystem::path Darknet::CfgAndState::weights_filename

The documentation for this class was generated from the following files: