mirror of https://github.com/davisking/dlib.git
Add progress information to console_progress_indicator (#2411)
* add progress information (current/total and percent) * print a new line instead of overwritting with spaces * check if target_val is an integer with std::trunc
This commit is contained in:
parent
74653b4f26
commit
fe0957303f
|
@ -30,7 +30,8 @@ namespace dlib
|
|||
}
|
||||
|
||||
The above code will print a message to the console each iteration
|
||||
which shows how much time is remaining until the loop terminates.
|
||||
which shows the current progress and how much time is remaining until
|
||||
the loop terminates.
|
||||
!*/
|
||||
|
||||
public:
|
||||
|
@ -72,8 +73,8 @@ namespace dlib
|
|||
/*!
|
||||
ensures
|
||||
- print_status() assumes it is called with values which are linearly
|
||||
approaching target(). It will attempt to predict how much time is
|
||||
remaining until cur becomes equal to target().
|
||||
approaching target(). It will display the current progress and attempt
|
||||
to predict how much time is remaining until cur becomes equal to target().
|
||||
- prints a status message to out which indicates how much more time is
|
||||
left until cur is equal to target()
|
||||
- if (always_print) then
|
||||
|
@ -156,6 +157,15 @@ namespace dlib
|
|||
out.setf(std::ios::fixed,std::ios::floatfield);
|
||||
std::streamsize ss;
|
||||
|
||||
if (std::trunc(target_val) == target_val)
|
||||
ss = out.precision(0);
|
||||
else
|
||||
ss = out.precision(2);
|
||||
|
||||
out << "Progress: " << cur << "/" << target_val;
|
||||
ss = out.precision(2);
|
||||
out << " (" << cur / target_val * 100. << "%). ";
|
||||
|
||||
if (seconds < 60)
|
||||
{
|
||||
ss = out.precision(0);
|
||||
|
|
|
@ -346,7 +346,7 @@ namespace dlib
|
|||
}
|
||||
|
||||
if (_verbose)
|
||||
std::cout << "Training complete " << std::endl;
|
||||
std::cout << "\nTraining complete" << std::endl;
|
||||
|
||||
return shape_predictor(initial_shape, forests, pixel_coordinates);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue