-
Notifications
You must be signed in to change notification settings - Fork 63
Expand file tree
/
Copy pathtest_tf_vision.h
More file actions
144 lines (108 loc) · 6.27 KB
/
Copy pathtest_tf_vision.h
File metadata and controls
144 lines (108 loc) · 6.27 KB
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
// Copyright (C) 2021 THL A29 Limited, a Tencent company. All rights reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
// in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the License
// is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
// or implied. See the License for the specific language governing permissions and limitations under
// the License.
//
// ╔════════════════════════════════════════════════════════════════════════════════════════╗
// ║──█████████╗───███████╗───████████╗───██╗──────██╗───███████╗───████████╗───████████╗───║
// ║──██╔══════╝──██╔════██╗──██╔════██╗──██║──────██║──██╔════██╗──██╔════██╗──██╔════██╗──║
// ║──████████╗───██║────██║──████████╔╝──██║──█╗──██║──█████████║──████████╔╝──██║────██║──║
// ║──██╔═════╝───██║────██║──██╔════██╗──██║█████╗██║──██╔════██║──██╔════██╗──██║────██║──║
// ║──██║─────────╚███████╔╝──██║────██║──╚████╔████╔╝──██║────██║──██║────██║──████████╔╝──║
// ║──╚═╝──────────╚══════╝───╚═╝────╚═╝───╚═══╝╚═══╝───╚═╝────╚═╝──╚═╝────╚═╝──╚═══════╝───║
// ╚════════════════════════════════════════════════════════════════════════════════════════╝
//
// Authors: Aster JIAN (asterjian@qq.com)
// Yzx (yzxyzxyzx777@outlook.com)
// Ao LI (346950981@qq.com)
// Paul LU (lujq96@gmail.com)
#pragma once
#include <string>
#include <vector>
#include "unit_test/unit_test_tf_helper.h"
class TestTfVisions : public ::testing::Test {
protected:
void SetUp() override {
filename = std::string(tf_root_dir) + "../../models/tf_vision_models/";
// configuration
infer_mode = "float32";
threshold = 1e-2;
};
void TearDown() override{};
float threshold{1e-3};
std::string filename;
std::string infer_mode;
std::vector<std::string> output_names;
std::unordered_map<std::string, TF_Tensor*> input_map;
};
TEST_F(TestTfVisions, DenseNet201) {
filename = filename + "densenet201.pb";
const int batch_size = 1;
const auto input = fwd::tf_::CreateRandomTensor<float>(TF_FLOAT, {batch_size, 224, 224, 3});
input_map["input_4"] = input.get();
output_names = {"relu/Relu"};
TestTFInference(filename, infer_mode, input_map, output_names, threshold);
}
TEST_F(TestTfVisions, InceptionV3) {
filename = filename + "inception_v3.pb";
const int batch_size = 1;
const auto input = fwd::tf_::CreateRandomTensor<float>(TF_FLOAT, {batch_size, 224, 224, 3});
input_map["input_1"] = input.get();
output_names = {"mixed10/concat"};
TestTFInference(filename, infer_mode, input_map, output_names, threshold);
}
TEST_F(TestTfVisions, InceptionResNetV2) {
filename = filename + "inception_resnet_v2.pb";
const int batch_size = 1;
const auto input = fwd::tf_::CreateRandomTensor<float>(TF_FLOAT, {batch_size, 224, 224, 3});
input_map["input_7"] = input.get();
output_names = {"conv_7b_ac/Relu"};
TestTFInference(filename, infer_mode, input_map, output_names, threshold);
}
TEST_F(TestTfVisions, MobileNetV2) {
filename = filename + "mobilenet_v2.pb";
const int batch_size = 1;
const auto input = fwd::tf_::CreateRandomTensor<float>(TF_FLOAT, {batch_size, 224, 224, 3});
input_map["input_5"] = input.get();
output_names = {"out_relu/Relu6"};
TestTFInference(filename, infer_mode, input_map, output_names, threshold);
}
TEST_F(TestTfVisions, NasNetLarge) {
filename = filename + "nasnet_large.pb";
const int batch_size = 1;
const auto input = fwd::tf_::CreateRandomTensor<float>(TF_FLOAT, {batch_size, 331, 331, 3});
input_map["input_5"] = input.get();
output_names = {"activation_556/Relu"};
TestTFInference(filename, infer_mode, input_map, output_names, threshold);
}
TEST_F(TestTfVisions, ResNet152V2) {
filename = filename + "resnet152_v2.pb";
const int batch_size = 1;
const auto input = fwd::tf_::CreateRandomTensor<float>(TF_FLOAT, {batch_size, 224, 224, 3});
input_map["input_3"] = input.get();
output_names = {"post_relu/Relu"};
TestTFInference(filename, infer_mode, input_map, output_names, threshold);
}
TEST_F(TestTfVisions, Vgg19) {
filename = filename + "vgg19.pb";
const int batch_size = 1;
const auto input = fwd::tf_::CreateRandomTensor<float>(TF_FLOAT, {batch_size, 224, 224, 3});
input_map["input_2"] = input.get();
output_names = {"block5_pool/MaxPool"};
TestTFInference(filename, infer_mode, input_map, output_names, threshold);
}
TEST_F(TestTfVisions, Xception) {
filename = filename + "xception.pb";
const int batch_size = 1;
const auto input = fwd::tf_::CreateRandomTensor<float>(TF_FLOAT, {batch_size, 224, 224, 3});
input_map["input_1"] = input.get();
output_names = {"block14_sepconv2_act/Relu"};
TestTFInference(filename, infer_mode, input_map, output_names, threshold);
}