fix(realesrgan): fixed RealESRGAN model name variable

Signed-off-by: k4yt3x <i@k4yt3x.com>
This commit is contained in:
k4yt3x 2024-11-02 00:00:00 +00:00
parent 406a97f360
commit bb74144070
No known key found for this signature in database
2 changed files with 11 additions and 7 deletions

View File

@ -56,7 +56,7 @@ struct RealESRGANConfig {
bool tta_mode; bool tta_mode;
int scaling_factor; int scaling_factor;
#ifdef _WIN32 #ifdef _WIN32
const wchar_t *model_path; const wchar_t *model_name;
#else #else
const char *model_name; const char *model_name;
#endif #endif

View File

@ -80,8 +80,12 @@ struct Arguments {
int out_height = 0; int out_height = 0;
// RealESRGAN options // RealESRGAN options
#ifdef _WIN32
std::wstring model_name;
#else
std::string model_name;
#endif
int gpuid = 0; int gpuid = 0;
std::filesystem::path model_path;
int scaling_factor = 0; int scaling_factor = 0;
}; };
@ -362,9 +366,9 @@ int main(int argc, char **argv) {
if (vm.count("model")) { if (vm.count("model")) {
#ifdef _WIN32 #ifdef _WIN32
arguments.model_path = std::filesystem::path(vm["model"].as<std::wstring>()); arguments.model_name = std::filesystem::path(vm["model"].as<std::wstring>());
#else #else
arguments.model_path = vm["model"].as<std::string>(); arguments.model_name = vm["model"].as<std::string>();
#endif #endif
if (!is_valid_realesrgan_model(vm["model"].as<std::string>())) { if (!is_valid_realesrgan_model(vm["model"].as<std::string>())) {
spdlog::error( spdlog::error(
@ -401,7 +405,7 @@ int main(int argc, char **argv) {
#else #else
} else if (arguments.filter_type == "realesrgan") { } else if (arguments.filter_type == "realesrgan") {
#endif #endif
if (arguments.scaling_factor == 0 || arguments.model_path.empty()) { if (arguments.scaling_factor == 0 || arguments.model_name.empty()) {
spdlog::error("Error: For realesrgan, scaling factor (-r) and model (-m) are required." spdlog::error("Error: For realesrgan, scaling factor (-r) and model (-m) are required."
); );
return 1; return 1;
@ -500,9 +504,9 @@ int main(int argc, char **argv) {
filter_config.config.realesrgan.tta_mode = false; filter_config.config.realesrgan.tta_mode = false;
filter_config.config.realesrgan.scaling_factor = arguments.scaling_factor; filter_config.config.realesrgan.scaling_factor = arguments.scaling_factor;
#ifdef _WIN32 #ifdef _WIN32
filter_config.config.realesrgan.model_name = arguments.model_path.c_str(); filter_config.config.realesrgan.model_name = arguments.model_name.c_str();
#else #else
filter_config.config.realesrgan.model_name = arguments.model_path.c_str(); filter_config.config.realesrgan.model_name = arguments.model_name.c_str();
filter_config.config.realesrgan.model_name = "realesr-animevideov4"; filter_config.config.realesrgan.model_name = "realesr-animevideov4";
#endif #endif
} }