Skip to content

Commit

Permalink
1.5 Release
Browse files Browse the repository at this point in the history
解决realsr2倍放大带alpha通道的png时,处理结果为空白的问题
  • Loading branch information
tumuyan committed Mar 4, 2022
1 parent cc16c1d commit f50afe4
Show file tree
Hide file tree
Showing 3 changed files with 54 additions and 2 deletions.
50 changes: 50 additions & 0 deletions RealSR-NCNN-Android-CLI/app/src/main/jni/realsr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ RealSR::RealSR(int gpuid, bool _tta_mode)

realsr_preproc = 0;
realsr_postproc = 0;
bicubic_2x = 0;
bicubic_3x = 0;
bicubic_4x = 0;
tta_mode = _tta_mode;
}
Expand All @@ -71,6 +73,12 @@ RealSR::~RealSR()
delete realsr_postproc;
}

bicubic_2x->destroy_pipeline(net.opt);
delete bicubic_2x;

bicubic_3x->destroy_pipeline(net.opt);
delete bicubic_3x;

bicubic_4x->destroy_pipeline(net.opt);
delete bicubic_4x;
}
Expand Down Expand Up @@ -158,6 +166,32 @@ int RealSR::load(const std::string& parampath, const std::string& modelpath)
}
}

// bicubic 2x/3x/4x for alpha channel
{
bicubic_2x = ncnn::create_layer("Interp");
bicubic_2x->vkdev = net.vulkan_device();

ncnn::ParamDict pd;
pd.set(0, 3);// bicubic
pd.set(1, 2.f);
pd.set(2, 2.f);
bicubic_2x->load_param(pd);

bicubic_2x->create_pipeline(net.opt);
}
{
bicubic_3x = ncnn::create_layer("Interp");
bicubic_3x->vkdev = net.vulkan_device();

ncnn::ParamDict pd;
pd.set(0, 3);// bicubic
pd.set(1, 3.f);
pd.set(2, 3.f);
bicubic_3x->load_param(pd);

bicubic_3x->create_pipeline(net.opt);
}

// bicubic 4x for alpha channel
{
bicubic_4x = ncnn::create_layer("Interp");
Expand Down Expand Up @@ -351,6 +385,14 @@ int RealSR::process(const ncnn::Mat& inimage, ncnn::Mat& outimage) const
{
out_alpha_tile_gpu = in_alpha_tile_gpu;
}
if (scale == 2)
{
bicubic_2x->forward(in_alpha_tile_gpu, out_alpha_tile_gpu, cmd, opt);
}
if (scale == 3)
{
bicubic_3x->forward(in_alpha_tile_gpu, out_alpha_tile_gpu, cmd, opt);
}
if (scale == 4)
{
bicubic_4x->forward(in_alpha_tile_gpu, out_alpha_tile_gpu, cmd, opt);
Expand Down Expand Up @@ -462,6 +504,14 @@ int RealSR::process(const ncnn::Mat& inimage, ncnn::Mat& outimage) const
{
out_alpha_tile_gpu = in_alpha_tile_gpu;
}
if (scale == 2)
{
bicubic_2x->forward(in_alpha_tile_gpu, out_alpha_tile_gpu, cmd, opt);
}
if (scale == 3)
{
bicubic_3x->forward(in_alpha_tile_gpu, out_alpha_tile_gpu, cmd, opt);
}
if (scale == 4)
{
bicubic_4x->forward(in_alpha_tile_gpu, out_alpha_tile_gpu, cmd, opt);
Expand Down
2 changes: 2 additions & 0 deletions RealSR-NCNN-Android-CLI/app/src/main/jni/realsr.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class RealSR
ncnn::Net net;
ncnn::Pipeline* realsr_preproc;
ncnn::Pipeline* realsr_postproc;
ncnn::Layer* bicubic_2x;
ncnn::Layer* bicubic_3x;
ncnn::Layer* bicubic_4x;
bool tta_mode;
};
Expand Down
4 changes: 2 additions & 2 deletions RealSR-NCNN-Android-GUI/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ android {
applicationId "com.tumuyan.ncnn.realsr"
minSdk 24
targetSdk 28
versionCode 9
versionName "1.4.3"
versionCode 10
versionName "1.5"

testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Expand Down

0 comments on commit f50afe4

Please # to comment.