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:
Adrià Arrufat 2021-08-06 20:32:53 +09:00 committed by GitHub
parent 74653b4f26
commit fe0957303f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 4 deletions

View File

@ -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);

View File

@ -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);
}