generated from arrufat/cpp-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
detector.h
58 lines (49 loc) · 1.46 KB
/
detector.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#ifndef detector_h_INCLUDED
#define detector_h_INCLUDED
#include <dlib/dnn.h>
#include <dlib/base64.h>
#include <dlib/compress_stream.h>
// HOW TO GENERATE THE COMPRESSED STREAM:
/*
dlib::deserialize(model_path) >> net;
std::ostringstream sout;
std::istringstream sin;
dlib::base64 base64_coder;
dlib::compress_stream::kernel_2a compressor;
// put the data into ostream sout
dlib::serialize(net, sout);
// put the data into istream sin
sin.str(sout.str());
sout.str("");
// compress the data
compressor.compress(sin, sout);
sin.clear();
sin.str(sout.str());
sout.str("");
// encode the data into base64
base64_coder.encode(sin, sout);
// print the data on the terminal
std::cout << sout.str() << std::endl;
*/
namespace detector
{
using namespace dlib;
template <long num_filters, int stride, template <typename> class BN, typename SUBNET>
using rcon3 = relu<BN<con<num_filters, 3, 3, stride, stride, SUBNET>>>;
// clang-format off
template <template <typename> class BN>
using net_type = loss_mmod<con<1, 3, 3, 1, 1,
rcon3<55, 1, BN,
rcon3<55, 1, BN,
rcon3<55, 1, BN,
rcon3<32, 2, BN,
rcon3<32, 2, BN,
rcon3<16, 2, BN,
input_rgb_image_pyramid<pyramid_down<6>>
>>>>>>>>;
// clang-format on
using train = net_type<bn_con>;
using infer = net_type<affine>;
const std::string load();
} // namespace detector
#endif // detector_h_INCLUDED