1 /* Copyright 2020 The TensorFlow Authors. All Rights Reserved.
2 
3 Licensed under the Apache License, Version 2.0 (the "License");
4 you may not use this file except in compliance with the License.
5 You may obtain a copy of the License at
6 
7     http://www.apache.org/licenses/LICENSE-2.0
8 
9 Unless required by applicable law or agreed to in writing, software
10 distributed under the License is distributed on an "AS IS" BASIS,
11 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 See the License for the specific language governing permissions and
13 limitations under the License.
14 ==============================================================================*/
15 
16 #ifndef TENSORFLOW_LITE_SUPPORT_CC_TASK_CORE_CATEGORY_H_
17 #define TENSORFLOW_LITE_SUPPORT_CC_TASK_CORE_CATEGORY_H_
18 #include <string>
19 
20 namespace tflite {
21 namespace task {
22 namespace core {
23 
24 // Result for classification APIs.
25 struct Category {
26   std::string class_name;
27   double score;
CategoryCategory28   Category(const std::string& class_name, double score)
29       : class_name(class_name), score(score) {}
30 
31   friend bool operator==(const Category& lhs, const Category& rhs) {
32     return lhs.score == rhs.score && lhs.class_name == rhs.class_name;
33   }
34 
35   friend bool operator!=(const Category& lhs, const Category& rhs) {
36     return !(lhs == rhs);
37   }
38 };
39 
40 }  // namespace core
41 }  // namespace task
42 }  // namespace tflite
43 
44 #endif  // TENSORFLOW_LITE_SUPPORT_CC_TASK_CORE_CATEGORY_H_
45