2 * Copyright (c) 2023 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include "machine_learning_exception.h"
20 #include "mv_image_classification_config.h"
21 #include "image_classification_adapter.h"
24 using namespace MediaVision::Common;
25 using namespace mediavision::machine_learning;
26 using namespace mediavision::machine_learning::exception;
30 namespace machine_learning
32 template<typename T, typename V> ImageClassificationAdapter<T, V>::ImageClassificationAdapter() : _source()
34 _image_classification = make_unique<ImageClassificationDefault>();
37 template<typename T, typename V> ImageClassificationAdapter<T, V>::~ImageClassificationAdapter()
40 template<typename T, typename V> void ImageClassificationAdapter<T, V>::create(int type)
42 throw InvalidOperation("Interface not supported.");
45 template<typename T, typename V> void ImageClassificationAdapter<T, V>::configure()
47 _image_classification->parseMetaFile();
48 _image_classification->configure();
51 template<typename T, typename V> void ImageClassificationAdapter<T, V>::prepare()
53 _image_classification->prepare();
56 template<typename T, typename V> void ImageClassificationAdapter<T, V>::setInput(T &t)
60 if (!_source.model_file.empty() && !_source.meta_file.empty() && !_source.label_file.empty())
61 _image_classification->setUserModel(_source.model_file, _source.meta_file, _source.label_file);
64 template<typename T, typename V> void ImageClassificationAdapter<T, V>::perform()
66 _image_classification->preprocess(_source.inference_src);
67 _image_classification->inference(_source.inference_src);
70 template<typename T, typename V> V &ImageClassificationAdapter<T, V>::getOutput()
72 return _image_classification->result();
75 template class ImageClassificationAdapter<ImageClassificationInput, ImageClassificationResult>;