You may have already seen the article here in the Magazine about upscaling bitmap images with better quality. That article covered a few utilities to achieve good results, but there’s always room for enhancement. Meet Waifu2x, a sophisticated tool that uses deep convolutional neural networks, or machine learning for short. Therefore it benefits from trained model data sets. Read on to see how well it performs to upscale your images, and how to get the same benefits even without an Nvidia card.
Here are some examples. First, a character that will be familiar to Fedora fans:
Here’s another example:
Because Waifu2x performs the calculations using Nvidia CUDA computing platform, it requires an Nvidia graphics card. This article, however, covers a more portable version called Waifu2x-converter-cpp that runs everywhere.
Waifu2x-converter-cpp doesn’t require a dedicated Nvidia GPU. Instead, it leverages the OpenCV and OpenCL libraries. Although the overall performance is slower compared to the original code, it’s portable and more people are able to use it. And of course it runs on Fedora!
Follow the directions below to give it a spin.
Installing Waifu2x-converter-cpp in Fedora
To build the application from source, first install build dependencies:
sudo dnf install -y gcc-c++ cmake opencv-devel opencl-utils-devel
Then grab the source code, build it and install the files:
git clone https://github.com/DeadSix27/waifu2x-converter-cpp.git cd waifu2x-converter-cpp/build cmake -DLIB_SUFFIX=64 ../ make sudo make install
Tell the dynamic library linker to index the directory with locally installed libraries:
sudo ldconfig /usr/local/lib64
Now everything is ready for upscaling. The example command for processing an image is as follows:
waifu2x-converter-cpp --scale_ratio 2 -i /path/to/input_file -o /path/to/output_file
Don’t miss this very helpful command for extras, such as switching OpenCL on/off, playing with noise level, and so on:
Using a graphical front-end for Waifu2x
Another step forward is to install Qtwaifu2x, a graphical tool that lets you escape Fedora terminal and process images with comfort and convenience.
Installing Qtwaifu2x in Fedora
First, install the main build dependency:
sudo dnf install -y qt5-qtbase-devel
Then get the code and build it:
git clone https://github.com/cmdrkotori/qtwaifu2x.git cd qtwaifu2x qmake-qt5 && make
To run the application from the current directory:
The main window has quite a few options, but it’s usually enough to provide the input file and hit the Start button.
Brew yourself a cup of tea and come back in a while to enjoy the perfectly upscaled image!
BEWARE! Waifu2x-converter-cpp and the other front ends like Qtwaifu2x yields very poor results compared to the original Waifu2x (based on Torch7) available here: https://github.com/nagadomi/waifu2x
Do not use these frontends if you are looking for quality! Use the original (good luck compiling it!) or do not use anything at all!
Paul W. Frields
@Nupao: I think the point the article makes is that Waifu2x has a hardware dependency on the Nvidia GPU. So this w-c-c option may be useful or appropriate for those without that hardware.
"FeRD" (Frank Dana)
@Paul: I agree that’s a reason to provide the information on waifu2x-converter-cpp (nagadomi links to w2x-c-c in the README for Waifu2x, as well). But while I don’t share Nupao’s “Waifu2x original or nothing at all” stance, I do feel like it should’ve at least been MENTIONED that W2x-c-c isn’t the same as Waifu2x, and in fact isn’t even written by its author. Especially if there’s a quality tradeoff for using it. Some of us DO have Nvidia GPUs, and therefore the ability to use Waifu2x. In theory, anyway. (See below.) Yet there wasn’t even a link to the original Waifu2x provided for the curious, until Nupao commented.
I actually didn’t have that bad a time building Torch (the main prerequisite for Waifu2x), thanks to Nvidia’s CUDA 9.2 repos and negativo17’s cuda-gcc compiler package. (GCC 7.3, since CUDA doesn’t support Fedora’s GCC 8.) There was one hitch, which nagadomi mentions in the README (it’s issue #222 in the Waifu2x repo).
Alas, my first attempt at running it on my lowly GeForce GT 710 GPU almost instantly ran out of memory. (Not too surprising, since it’s also my display card and 600MB of its total 1GB graphics RAM is occupied even BEFORE I try running Waifu2x. Clearly a 1GB card is not sufficient.) So I guess I’m stuck with W2x-c-c until a better GPU comes my way.
It would be great of you provided comparison between Waifu2x and Waifu2x-converter-cpp. Definitely, there should be difference, although I’m sure it will not be so eye-catching as you suggest. For instance, you can process a sample image in Waifu2x-converter-cpp and with the publicly available Waifu2x online service and see both variants.
Furthermore, using frontends doesn’t affect quality in any way. Qtwaifu2x is just a front end to the command-line app. It can also be used with the original Torch7-based Waifu2x that you mentioned above.
Here’s a comparison from an image with dark tones.
You lose data if you use waifu-converter-cpp.
Using frontends doesn’t affect quality as long as the original waifu2x is used, not a re-implementation, indeed.
"FeRD" (Frank Dana)
If you can detect visible differences in those images, you have far better eyes than I. To my eyes, not only are the differences not significant, they are nearly imperceptible.
Can this help upscaling my waifu? I’ve been trying to upscale it for ages.
"FeRD" (Frank Dana)
Alas, Waifu2x can only scale up your waifu. Nothing can make it upscale.
Why don’t you package the software in a Copr (and then submit it to Fedora review) instead of giving instructions for compiling it manually?
I’m not really good (yet) in packaging software. I appreciate if someone could make a copr repo with the apps from the article.
I’ll have a look.