Beatmup
cnn.h
Go to the documentation of this file.
1
/*
2
Beatmup image and signal processing library
3
Copyright (C) 2020, lnstadrum
4
5
This program is free software: you can redistribute it and/or modify
6
it under the terms of the GNU General Public License as published by
7
the Free Software Foundation, either version 3 of the License, or
8
(at your option) any later version.
9
10
This program is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
GNU General Public License for more details.
14
15
You should have received a copy of the GNU General Public License
16
along with this program. If not, see <http://www.gnu.org/licenses/>.
17
*/
18
19
#pragma once
20
#include "../cnn_interface.h"
21
22
namespace
Beatmup
{
23
24
/**
25
x2 image upsampler using a convolutional neural network.
26
Implements a neural net inference using OpenGL ES 2.0-conformant shaders.
27
Used by Bitmap::Resampler. Only usable inside an AbstractTask, not intended to be directly used by the application.
28
*/
29
class
GLES20X2UpsamplingNetwork
:
public
X2UpsamplingNetwork
{
30
private
:
31
class
Layer
{
32
public
:
33
typedef
InternalBitmap
*
Storage
;
34
private
:
35
ImageShader
shader
;
36
Storage
&
output
;
37
public
:
38
Layer
(
GL::RecycleBin
& recycleBin,
GraphicPipeline
& gpu,
Storage
& outputStorage,
const
char
* sourceCode);
39
40
void
process
(
Context
&
ctx
,
GraphicPipeline
& gpu,
GL::TextureHandler
& input);
41
void
process
(
Context
&
ctx
,
GraphicPipeline
& gpu,
Layer
** inputs,
int
inputsCount);
42
43
InternalBitmap
&
getOutput
() {
44
return
*
output
;
45
}
46
};
47
48
static
const
int
49
L1_SIZE
= 12,
50
L2_SIZE
= 8,
51
L3_SIZE
= 6,
52
L4_SIZE
= 4,
53
STORAGE_SIZE
= 14;
// min number of recyclable textures to cover the entire dataflow during the inference
54
55
InternalBitmap
*
storage
[
STORAGE_SIZE
];
56
57
Layer
58
*
layer1
[
L1_SIZE
],
59
*
layer2
[
L2_SIZE
],
60
*
layer3
[
L3_SIZE
],
61
*
layer4
[
L4_SIZE
],
62
*
layer5
;
63
64
ImageShader
demux
;
65
66
Layer::Storage
&
nextStorage
(
int
& i) {
return
storage
[i++ %
STORAGE_SIZE
]; }
67
68
public
:
69
GLES20X2UpsamplingNetwork
(
GL::RecycleBin
& recycleBin,
GraphicPipeline
& gpu);
70
~GLES20X2UpsamplingNetwork
();
71
72
void
process
(
GraphicPipeline
& gpu,
GL::TextureHandler
& input,
AbstractBitmap
& output);
73
bool
usesEs31Backend
()
const
{
return
false
; }
74
};
75
76
}
Beatmup::AbstractBitmap
A very basic class for any image.
Definition:
abstract_bitmap.h:87
Beatmup::Context
Basic class: task and memory management, any kind of static data.
Definition:
context.h:59
Beatmup::GLES20X2UpsamplingNetwork::Layer
Definition:
cnn.h:31
Beatmup::GLES20X2UpsamplingNetwork::Layer::output
Storage & output
Definition:
cnn.h:36
Beatmup::GLES20X2UpsamplingNetwork::Layer::Layer
Layer(GL::RecycleBin &recycleBin, GraphicPipeline &gpu, Storage &outputStorage, const char *sourceCode)
Definition:
cnn.cpp:29
Beatmup::GLES20X2UpsamplingNetwork::Layer::getOutput
InternalBitmap & getOutput()
Definition:
cnn.h:43
Beatmup::GLES20X2UpsamplingNetwork::Layer::process
void process(Context &ctx, GraphicPipeline &gpu, GL::TextureHandler &input)
Definition:
cnn.cpp:36
Beatmup::GLES20X2UpsamplingNetwork::Layer::shader
ImageShader shader
Definition:
cnn.h:35
Beatmup::GLES20X2UpsamplingNetwork::Layer::Storage
InternalBitmap * Storage
Definition:
cnn.h:33
Beatmup::GLES20X2UpsamplingNetwork
x2 image upsampler using a convolutional neural network.
Definition:
cnn.h:29
Beatmup::GLES20X2UpsamplingNetwork::GLES20X2UpsamplingNetwork
GLES20X2UpsamplingNetwork(GL::RecycleBin &recycleBin, GraphicPipeline &gpu)
Definition:
cnn.cpp:163
Beatmup::GLES20X2UpsamplingNetwork::L1_SIZE
static const int L1_SIZE
Definition:
cnn.h:49
Beatmup::GLES20X2UpsamplingNetwork::~GLES20X2UpsamplingNetwork
~GLES20X2UpsamplingNetwork()
Definition:
cnn.cpp:306
Beatmup::GLES20X2UpsamplingNetwork::process
void process(GraphicPipeline &gpu, GL::TextureHandler &input, AbstractBitmap &output)
Definition:
cnn.cpp:87
Beatmup::GLES20X2UpsamplingNetwork::layer1
Layer * layer1[L1_SIZE]
Definition:
cnn.h:58
Beatmup::GLES20X2UpsamplingNetwork::usesEs31Backend
bool usesEs31Backend() const
Definition:
cnn.h:73
Beatmup::GLES20X2UpsamplingNetwork::storage
InternalBitmap * storage[STORAGE_SIZE]
Definition:
cnn.h:55
Beatmup::GLES20X2UpsamplingNetwork::L2_SIZE
static const int L2_SIZE
Definition:
cnn.h:50
Beatmup::GLES20X2UpsamplingNetwork::STORAGE_SIZE
static const int STORAGE_SIZE
Definition:
cnn.h:53
Beatmup::GLES20X2UpsamplingNetwork::L4_SIZE
static const int L4_SIZE
Definition:
cnn.h:52
Beatmup::GLES20X2UpsamplingNetwork::layer3
Layer * layer3[L3_SIZE]
Definition:
cnn.h:60
Beatmup::GLES20X2UpsamplingNetwork::layer2
Layer * layer2[L2_SIZE]
Definition:
cnn.h:59
Beatmup::GLES20X2UpsamplingNetwork::layer4
Layer * layer4[L4_SIZE]
Definition:
cnn.h:61
Beatmup::GLES20X2UpsamplingNetwork::L3_SIZE
static const int L3_SIZE
Definition:
cnn.h:51
Beatmup::GLES20X2UpsamplingNetwork::nextStorage
Layer::Storage & nextStorage(int &i)
Definition:
cnn.h:66
Beatmup::GLES20X2UpsamplingNetwork::demux
ImageShader demux
Definition:
cnn.h:64
Beatmup::GLES20X2UpsamplingNetwork::layer5
Layer * layer5
Definition:
cnn.h:62
Beatmup::GL::RecycleBin
Stores references to GPU resources that will not be used anymore and needed to be recycled in a threa...
Definition:
recycle_bin.h:34
Beatmup::GL::TextureHandler
Definition:
texture_handler.h:37
Beatmup::GraphicPipeline
Internal low-level GPU control API.
Definition:
pipeline.h:33
Beatmup::ImageShader
A GLSL program to process images.
Definition:
image_shader.h:34
Beatmup::InternalBitmap
Bitmap whose memory is managed by the Beatmup engine.
Definition:
internal_bitmap.h:35
Beatmup::X2UpsamplingNetwork
Interface of x2 image upsampling using a convolutional neural network on GPU.
Definition:
cnn_interface.h:29
Beatmup
Definition:
basic_types.h:22
ctx
Beatmup::Context * ctx
Definition:
wrapper_core.cpp:80
core
bitmap
resampler_cnn_x2
gles20
cnn.h
Generated on Tue Nov 21 2023 13:54:26 for Beatmup by
1.9.1