1 // waifu2x implemented with ncnn library
2 
3 #ifndef WAIFU2X_H
4 #define WAIFU2X_H
5 
6 #include <string>
7 
8 // ncnn
9 #include "net.h"
10 #include "gpu.h"
11 #include "layer.h"
12 
13 class Waifu2x
14 {
15 public:
16     Waifu2x(int gpuid, bool tta_mode = false, int num_threads = 1);
17     ~Waifu2x();
18 
19 #if _WIN32
20     int load(const std::wstring& parampath, const std::wstring& modelpath);
21 #else
22     int load(const std::string& parampath, const std::string& modelpath);
23 #endif
24 
25     int process(const ncnn::Mat& inimage, ncnn::Mat& outimage) const;
26 
27     int process_cpu(const ncnn::Mat& inimage, ncnn::Mat& outimage) const;
28 
29 public:
30     // waifu2x parameters
31     int noise;
32     int scale;
33     int tilesize;
34     int prepadding;
35 
36 private:
37     ncnn::VulkanDevice* vkdev;
38     ncnn::Net net;
39     ncnn::Pipeline* waifu2x_preproc;
40     ncnn::Pipeline* waifu2x_postproc;
41     ncnn::Layer* bicubic_2x;
42     bool tta_mode;
43 };
44 
45 #endif // WAIFU2X_H
46