nihui / realsr-ncnn-vulkan

RealSR super resolution implemented with ncnn library
MIT License
1.11k stars 113 forks source link

added the quiet (-q) param to suppress progress output #41

Open k4yt3x opened 2 years ago

k4yt3x commented 2 years ago

Motivation

Currently, the progress output is embedded in the RealSR object, and cannot be controlled. This creates problems especially when the program is used as a library as it will spam lots of messages onto the screen. While it is possible to suppress the messages by suppressing STDERR entirely, it will also suppress error messages, which is undesirable.

image

Behavior Before the Update

Before any changes are made, realsr-ncnn-vulkan will print the progress of the current task:

image

Proposed Changes

I am proposing to add a new param -q (quiet) to suppress the progress output. From a consistency standpoint, I'd rather make the output suppressed by default. However, I'd like to not alter the program's default behavior in this PR and leave the choice to @nihui.

Behavior After the Update

A new parameter quiet is added to the RealSR class to control the suppression of progress output. This can also be controlled with the new -q argument in the command line argument parser.

RealSR(int gpuid, bool tta_mode = false, int num_threads = 1, bool quiet = false);

After adding the -q param, the progress output can be suppressed like such:

image

Remarks

I've never written any serious C++ before, so my apologies if I've made any mistakes in the changes.