This repository has been archived by the owner on Aug 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 74
/
Copy pathlandmarks_detection_model.cpp
68 lines (62 loc) · 2.51 KB
/
landmarks_detection_model.cpp
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
// Copyright (c) 2018 Intel Corporation
//
// 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.
/**
* @brief a header file with declaration of LandmarksDetectionModel class
* @file landmarks_detection_model.cpp
*/
#include <string>
#include "dynamic_vino_lib/models/landmarks_detection_model.h"
#include "dynamic_vino_lib/slog.h"
// Validated Landmarks Detection Network
Models::LandmarksDetectionModel::LandmarksDetectionModel(const std::string& model_loc, int max_batch_size)
: BaseModel(model_loc, max_batch_size)
{
}
bool Models::LandmarksDetectionModel::updateLayerProperty(InferenceEngine::CNNNetReader::Ptr net_reader)
{
//INPUT
InferenceEngine::InputsDataMap input_info_map(net_reader->getNetwork().getInputsInfo());
auto input_layerName = input_info_map.begin()->first;
auto input_layerData = input_info_map.begin()->second;
auto input_layerDims = input_layerData->getTensorDesc().getDims();
if (input_layerDims.size() == 4)
{
input_layerData->setLayout(InferenceEngine::Layout::NCHW);
input_layerData->setPrecision(InferenceEngine::Precision::U8);
}
else if (input_layerDims.size() == 2)
{
input_layerData->setLayout(InferenceEngine::Layout::NC);
input_layerData->setPrecision(InferenceEngine::Precision::FP32);
}
else
{
throw std::runtime_error("Unknow type of input layer layout. Expected either 4 or 2 dimensional inputs");
}
// OUTPUT
InferenceEngine::OutputsDataMap output_info_map(net_reader->getNetwork().getOutputsInfo());
auto output_layerName = output_info_map.begin()->first;
auto output_layerData = output_info_map.begin()->second;
auto output_layerDims = output_layerData->getTensorDesc().getDims();
output_layerData->setPrecision(InferenceEngine::Precision::FP32);
// output_layerData->setLayout(InferenceEngine::Layout::NCHW);
// set input and output layer name
input_ = input_layerName;
output_ = output_layerName;
return true;
}
const std::string Models::LandmarksDetectionModel::getModelCategory() const
{
return "Landmarks Detection";
}