#include "darknet_cfg_and_state.hpp"
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 ArgsAndParms & | get (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. | |
CfgAndState & | process_arguments (const VStr &v, Darknet::NetworkPtr ptr=nullptr) |
Process the given arguments. | |
CfgAndState & | process_arguments (int argc, char **argp) |
Process argv [] from main() and store the results in argv and args . | |
CfgAndState & | reset () |
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 CfgAndState & | get () |
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. | |
Darknet::CfgAndState::CfgAndState | ( | ) |
Constructor.
Darknet::CfgAndState::~CfgAndState | ( | ) |
Destructor.
|
inline |
Alias for del_thread_name(). Uses the ID of the current running thread.
|
inline |
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.
|
static |
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.
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.
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.
float Darknet::CfgAndState::get_float | ( | const std::string & | arg | ) | const |
Get a float parameter. This must exist, otherwise darknet_fatal_error() is called.
int Darknet::CfgAndState::get_int | ( | const std::string & | arg | ) | const |
Get an integer parameter. This must exist, otherwise darknet_fatal_error() is called.
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().
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:
Darknet::CfgAndState & Darknet::CfgAndState::process_arguments | ( | const VStr & | v, |
Darknet::NetworkPtr | ptr = nullptr |
||
) |
Process the given arguments.
Darknet::CfgAndState & Darknet::CfgAndState::process_arguments | ( | int | argc, |
char ** | argp | ||
) |
Process argv
[] from main()
and store the results in argv
and args
.
Darknet::CfgAndState & Darknet::CfgAndState::reset | ( | ) |
Clear out all settings and state to a known initial state.
|
inline |
Alias for set_thread_name(). Uses the ID of the current running thread.
|
inline |
void Darknet::CfgAndState::set_thread_name | ( | const std::thread::id & | tid, |
const std::string & | name | ||
) |
Set a name to use for the given thread.
VStr Darknet::CfgAndState::additional_arguments |
Parameters that were unrecognized.
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.
VStr Darknet::CfgAndState::argv |
Every argument starting with argv
[0], unmodified, and in the exact order they were specified.
std::filesystem::path Darknet::CfgAndState::cfg_filename |
bool Darknet::CfgAndState::colour_is_enabled |
Determines if ANSI colour output will be used with the console output. Default is true
.
std::string Darknet::CfgAndState::command |
std::filesystem::path Darknet::CfgAndState::data_filename |
VStr Darknet::CfgAndState::filenames |
std::string Darknet::CfgAndState::function |
int Darknet::CfgAndState::gpu_index |
The index of the GPU to use. -1
means no GPU is selected.
bool Darknet::CfgAndState::is_shown |
When -dont_show
has been set, this value will be set to false
.
bool Darknet::CfgAndState::is_trace |
Whether Darknet was started with the --trace
flag.
This will also enable is_verbose. Default is false
.
bool Darknet::CfgAndState::is_verbose |
Whether Darknet was started with the --verbose
flag.
Default is false
.
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.
std::filesystem::path Darknet::CfgAndState::names_filename |
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.
std::mutex Darknet::CfgAndState::thread_names_mutex |
Name the threads that we create in case we have to report an error.
std::filesystem::path Darknet::CfgAndState::weights_filename |