Repository navigation
Title: Multiple issues preventing custom RealESRGAN models from working #1483
Description
I am very sorry but I didn't write this bug report- just the other one. There were just too many hurdles to jump for me to remember everything clearly so I have automated this. Again, very sorry! Video2x is excellent and I hope this information helps the project along.
Environment: Video2X 6.4.0, built from source
Kubuntu 26.04, AMD Ryzen 9 9950X, AMD RX 9070
ncnn 20260503 (system), Boost 1.90.0, Clang 22.1.2
Bug 1: validators.cpp rejects any custom model name
validate_realesrgan_model_name() uses a hardcoded whitelist with no filesystem fallback, unlike validate_anime4k_shader_name() which correctly falls back to checking if the file exists. Any custom model name triggers "the argument for option 'realesrgan-model' is invalid" before the program even starts.
Fix: Mirror the anime4k validator pattern:
cppconst fsutils::StringType model_dir =
STR("/usr/local/share/video2x/models/realesrgan/");
const fsutils::StringType param_path =
model_dir + model_name + STR("-x4.param");
if (valid_realesrgan_models.count(model_name) == 0 &&
!std::filesystem::exists(param_path)) {
throw ...
}
Bug 2: filter_realesrgan.cpp appends -xN suffix but validator checks without it
filter_realesrgan.cpp constructs the filename as modelname-x4.param but the validator checks for modelname.param — these are inconsistent, making it impossible for the validator's filesystem fallback to ever succeed even after fixing Bug 1.
Fix: The validator must check for modelname-x4.param to match what the loader actually looks for.
Bug 3: RealESRGAN loader expects input blob named data but ONNX-converted models use input
Models converted from ONNX via onnx2ncnn produce param files with input blob named input. The realesrgan loader hardcodes data causing a crash: find_blob_index_by_name data failed. There is no documentation about this requirement anywhere.
Fix: Either make the loader try both names, or document the requirement and provide a conversion script that renames the blob. One-liner fix for converted models:
bashsed -i 's/0 1 input$/0 1 data/' model.param
sed -i 's/1 1 input /1 1 data /' model.param
Bug 4: Boost SONAME hardcoded to 1.86.0 regardless of system Boost version
Already reported separately — binary always links against libboost_program_options.so.1.86.0 even when built against 1.90.0. Workaround: patchelf --replace-needed.
Bug 5: librife_ncnn_vulkan uses removed ncnn API
third_party/librife_ncnn_vulkan/src/warp.cpp calls opt.use_shader_pack8 which was removed from ncnn's API. Build fails without patching.
Fix:
bashsed -i 's/.use_shader_pack8.$/// &/'
third_party/librife_ncnn_vulkan/src/warp.cpp
Summary: A user wanting to add a custom ONNX model must: fix the build (Bug 5), patch the validator twice (Bugs 1+2), rename the input blob (Bug 3), and patch the binary post-install (Bug 4). None of this is documented. The custom model workflow is effectively broken out of the box.
Suggested priority: Bugs 1+2+3 are the most impactful as they completely block custom model usage which is a core advertised feature.
Activity