1 /*M///////////////////////////////////////////////////////////////////////////////////////
2 //
3 // IMPORTANT: READ BEFORE DOWNLOADING, COPYING, INSTALLING OR USING.
4 //
5 // By downloading, copying, installing or using the software you agree to this license.
6 // If you do not agree to this license, do not download, install,
7 // copy or use the software.
8 //
9 //
10 // License Agreement
11 // For Open Source Computer Vision Library
12 //
13 // Copyright (C) 2013, OpenCV Foundation, all rights reserved.
14 // Third party copyrights are property of their respective owners.
15 //
16 // Redistribution and use in source and binary forms, with or without modification,
17 // are permitted provided that the following conditions are met:
18 //
19 // * Redistribution's of source code must retain the above copyright notice,
20 // this list of conditions and the following disclaimer.
21 //
22 // * Redistribution's in binary form must reproduce the above copyright notice,
23 // this list of conditions and the following disclaimer in the documentation
24 // and/or other materials provided with the distribution.
25 //
26 // * The name of the copyright holders may not be used to endorse or promote products
27 // derived from this software without specific prior written permission.
28 //
29 // This software is provided by the copyright holders and contributors "as is" and
30 // any express or implied warranties, including, but not limited to, the implied
31 // warranties of merchantability and fitness for a particular purpose are disclaimed.
32 // In no event shall the Intel Corporation or contributors be liable for any direct,
33 // indirect, incidental, special, exemplary, or consequential damages
34 // (including, but not limited to, procurement of substitute goods or services;
35 // loss of use, data, or profits; or business interruption) however caused
36 // and on any theory of liability, whether in contract, strict liability,
37 // or tort (including negligence or otherwise) arising in any way out of
38 // the use of this software, even if advised of the possibility of such damage.
39 //
40 //M*/
41
42 #include "precomp.hpp"
43 #include <opencv2/dnn/layer.details.hpp>
44
45 #include <google/protobuf/stubs/common.h>
46
47 namespace cv {
48 namespace dnn {
49 CV__DNN_INLINE_NS_BEGIN
50
51 static Mutex* __initialization_mutex = NULL;
getInitializationMutex()52 Mutex& getInitializationMutex()
53 {
54 if (__initialization_mutex == NULL)
55 __initialization_mutex = new Mutex();
56 return *__initialization_mutex;
57 }
58 // force initialization (single-threaded environment)
59 Mutex* __initialization_mutex_initializer = &getInitializationMutex();
60
61 namespace {
62 using namespace google::protobuf;
63 class ProtobufShutdown {
64 public:
65 bool initialized;
ProtobufShutdown()66 ProtobufShutdown() : initialized(true) {}
~ProtobufShutdown()67 ~ProtobufShutdown()
68 {
69 initialized = false;
70 google::protobuf::ShutdownProtobufLibrary();
71 }
72 };
73 } // namespace
74
initializeLayerFactory()75 void initializeLayerFactory()
76 {
77 CV_TRACE_FUNCTION();
78
79 static ProtobufShutdown protobufShutdown; CV_UNUSED(protobufShutdown);
80
81 CV_DNN_REGISTER_LAYER_CLASS(Slice, SliceLayer);
82 CV_DNN_REGISTER_LAYER_CLASS(Split, SplitLayer);
83 CV_DNN_REGISTER_LAYER_CLASS(Concat, ConcatLayer);
84 CV_DNN_REGISTER_LAYER_CLASS(Reshape, ReshapeLayer);
85 CV_DNN_REGISTER_LAYER_CLASS(Flatten, FlattenLayer);
86 CV_DNN_REGISTER_LAYER_CLASS(Resize, ResizeLayer);
87 CV_DNN_REGISTER_LAYER_CLASS(Interp, InterpLayer);
88 CV_DNN_REGISTER_LAYER_CLASS(CropAndResize, CropAndResizeLayer);
89
90 CV_DNN_REGISTER_LAYER_CLASS(Convolution, ConvolutionLayer);
91 CV_DNN_REGISTER_LAYER_CLASS(Deconvolution, DeconvolutionLayer);
92 CV_DNN_REGISTER_LAYER_CLASS(Pooling, PoolingLayer);
93 CV_DNN_REGISTER_LAYER_CLASS(ROIPooling, PoolingLayer);
94 CV_DNN_REGISTER_LAYER_CLASS(PSROIPooling, PoolingLayer);
95 CV_DNN_REGISTER_LAYER_CLASS(LRN, LRNLayer);
96 CV_DNN_REGISTER_LAYER_CLASS(InnerProduct, InnerProductLayer);
97 CV_DNN_REGISTER_LAYER_CLASS(Softmax, SoftmaxLayer);
98 CV_DNN_REGISTER_LAYER_CLASS(SoftMax, SoftmaxLayer); // For compatibility. See https://github.com/opencv/opencv/issues/16877
99 CV_DNN_REGISTER_LAYER_CLASS(MVN, MVNLayer);
100
101 CV_DNN_REGISTER_LAYER_CLASS(ReLU, ReLULayer);
102 CV_DNN_REGISTER_LAYER_CLASS(ReLU6, ReLU6Layer);
103 CV_DNN_REGISTER_LAYER_CLASS(ChannelsPReLU, ChannelsPReLULayer);
104 CV_DNN_REGISTER_LAYER_CLASS(PReLU, ChannelsPReLULayer);
105 CV_DNN_REGISTER_LAYER_CLASS(Sigmoid, SigmoidLayer);
106 CV_DNN_REGISTER_LAYER_CLASS(TanH, TanHLayer);
107 CV_DNN_REGISTER_LAYER_CLASS(Swish, SwishLayer);
108 CV_DNN_REGISTER_LAYER_CLASS(Mish, MishLayer);
109 CV_DNN_REGISTER_LAYER_CLASS(ELU, ELULayer);
110 CV_DNN_REGISTER_LAYER_CLASS(BNLL, BNLLLayer);
111 CV_DNN_REGISTER_LAYER_CLASS(AbsVal, AbsLayer);
112 CV_DNN_REGISTER_LAYER_CLASS(Power, PowerLayer);
113 CV_DNN_REGISTER_LAYER_CLASS(Exp, ExpLayer);
114 CV_DNN_REGISTER_LAYER_CLASS(BatchNorm, BatchNormLayer);
115 CV_DNN_REGISTER_LAYER_CLASS(MaxUnpool, MaxUnpoolLayer);
116 CV_DNN_REGISTER_LAYER_CLASS(Dropout, BlankLayer);
117 CV_DNN_REGISTER_LAYER_CLASS(Identity, BlankLayer);
118 CV_DNN_REGISTER_LAYER_CLASS(Silence, BlankLayer);
119 CV_DNN_REGISTER_LAYER_CLASS(Const, ConstLayer);
120
121 CV_DNN_REGISTER_LAYER_CLASS(Crop, CropLayer);
122 CV_DNN_REGISTER_LAYER_CLASS(Eltwise, EltwiseLayer);
123 CV_DNN_REGISTER_LAYER_CLASS(Permute, PermuteLayer);
124 CV_DNN_REGISTER_LAYER_CLASS(ShuffleChannel, ShuffleChannelLayer);
125 CV_DNN_REGISTER_LAYER_CLASS(PriorBox, PriorBoxLayer);
126 CV_DNN_REGISTER_LAYER_CLASS(PriorBoxClustered, PriorBoxLayer);
127 CV_DNN_REGISTER_LAYER_CLASS(Reorg, ReorgLayer);
128 CV_DNN_REGISTER_LAYER_CLASS(Region, RegionLayer);
129 CV_DNN_REGISTER_LAYER_CLASS(DetectionOutput, DetectionOutputLayer);
130 CV_DNN_REGISTER_LAYER_CLASS(NormalizeBBox, NormalizeBBoxLayer);
131 CV_DNN_REGISTER_LAYER_CLASS(Normalize, NormalizeBBoxLayer);
132 CV_DNN_REGISTER_LAYER_CLASS(Shift, ShiftLayer);
133 CV_DNN_REGISTER_LAYER_CLASS(Padding, PaddingLayer);
134 CV_DNN_REGISTER_LAYER_CLASS(Proposal, ProposalLayer);
135 CV_DNN_REGISTER_LAYER_CLASS(Scale, ScaleLayer);
136 CV_DNN_REGISTER_LAYER_CLASS(DataAugmentation, DataAugmentationLayer);
137 CV_DNN_REGISTER_LAYER_CLASS(Correlation, CorrelationLayer);
138 CV_DNN_REGISTER_LAYER_CLASS(Accum, AccumLayer);
139 CV_DNN_REGISTER_LAYER_CLASS(FlowWarp, FlowWarpLayer);
140
141 CV_DNN_REGISTER_LAYER_CLASS(LSTM, LSTMLayer);
142 }
143
144 CV__DNN_INLINE_NS_END
145 }} // namespace
146