Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Tetragramm
GitHub Repository: Tetragramm/opencv
Path: blob/master/modules/dnn/src/caffe/caffe_io.hpp
16339 views
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
/*M///////////////////////////////////////////////////////////////////////////////////////
43
//COPYRIGHT
44
//
45
//All contributions by the University of California:
46
//Copyright (c) 2014, The Regents of the University of California (Regents)
47
//All rights reserved.
48
//
49
//All other contributions:
50
//Copyright (c) 2014, the respective contributors
51
//All rights reserved.
52
//
53
//Caffe uses a shared copyright model: each contributor holds copyright over
54
//their contributions to Caffe. The project versioning records all such
55
//contribution and copyright details. If a contributor wants to further mark
56
//their specific copyright on a particular contribution, they should indicate
57
//their copyright solely in the commit message of the change when it is
58
//committed.
59
//
60
//LICENSE
61
//
62
//Redistribution and use in source and binary forms, with or without
63
//modification, are permitted provided that the following conditions are met:
64
//
65
//1. Redistributions of source code must retain the above copyright notice, this
66
// list of conditions and the following disclaimer.
67
//2. Redistributions in binary form must reproduce the above copyright notice,
68
// this list of conditions and the following disclaimer in the documentation
69
// and/or other materials provided with the distribution.
70
//
71
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
72
//ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
73
//WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
74
//DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
75
//ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
76
//(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
77
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
78
//ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
79
//(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
80
//SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
81
//
82
//CONTRIBUTION AGREEMENT
83
//
84
//By contributing to the BVLC/caffe repository through pull-request, comment,
85
//or otherwise, the contributor releases their content to the
86
//license and copyright terms herein.
87
//
88
//M*/
89
90
#ifndef __OPENCV_DNN_CAFFE_IO_HPP__
91
#define __OPENCV_DNN_CAFFE_IO_HPP__
92
#ifdef HAVE_PROTOBUF
93
94
#if defined(__GNUC__) && __GNUC__ >= 5
95
#pragma GCC diagnostic push
96
#pragma GCC diagnostic ignored "-Wsuggest-override"
97
#endif
98
#include "opencv-caffe.pb.h"
99
#if defined(__GNUC__) && __GNUC__ >= 5
100
#pragma GCC diagnostic pop
101
#endif
102
103
namespace caffe { using namespace opencv_caffe; } // avoid massive renames from caffe proto package
104
105
namespace cv {
106
namespace dnn {
107
108
// Read parameters from a file into a NetParameter proto message.
109
void ReadNetParamsFromTextFileOrDie(const char* param_file,
110
caffe::NetParameter* param);
111
void ReadNetParamsFromBinaryFileOrDie(const char* param_file,
112
caffe::NetParameter* param);
113
114
// Read parameters from a memory buffer into a NetParammeter proto message.
115
void ReadNetParamsFromBinaryBufferOrDie(const char* data, size_t len,
116
caffe::NetParameter* param);
117
void ReadNetParamsFromTextBufferOrDie(const char* data, size_t len,
118
caffe::NetParameter* param);
119
120
// Utility functions used internally by Caffe and TensorFlow loaders
121
bool ReadProtoFromTextFile(const char* filename, ::google::protobuf::Message* proto);
122
bool ReadProtoFromBinaryFile(const char* filename, ::google::protobuf::Message* proto);
123
bool ReadProtoFromTextBuffer(const char* data, size_t len, ::google::protobuf::Message* proto);
124
bool ReadProtoFromBinaryBuffer(const char* data, size_t len, ::google::protobuf::Message* proto);
125
126
}
127
}
128
#endif
129
#endif
130
131