Skip to content

Commit 8f6fed1

Browse files
committed
Separated TfLiteCategory to standalone header
1 parent aed9982 commit 8f6fed1

File tree

2 files changed

+70
-0
lines changed

2 files changed

+70
-0
lines changed

tensorflow_lite_support/c/task/processor/BUILD

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,20 @@ package(
33
licenses = ["notice"], # Apache 2.0
44
)
55

6+
cc_library(
7+
name = "category",
8+
hdrs = ["category.h"],
9+
)
10+
611
cc_library(
712
name = "classification_result",
813
srcs = [
914
"classification_result.cc",
1015
],
1116
hdrs = ["classification_result.h"],
17+
deps = [
18+
":category"
19+
]
1220
)
1321

1422
cc_library(
@@ -20,3 +28,16 @@ cc_library(
2028
name = "classification_options",
2129
hdrs = ["classification_options.h"],
2230
)
31+
32+
cc_library(
33+
name = "detection_result",
34+
srcs = [
35+
"detection_result.cc",
36+
],
37+
hdrs = ["detection_result.h"],
38+
deps = [
39+
":category",
40+
":bounding_box"
41+
]
42+
)
43+
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/* Copyright 2021 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+
#ifndef TENSORFLOW_LITE_SUPPORT_C_TASK_PROCESSOR_CATEGORY_H_
16+
#define TENSORFLOW_LITE_SUPPORT_C_TASK_PROCESSOR_CATEGORY_H_
17+
18+
// Defines C structure for a Category which encapsulates a single predicted
19+
// class.
20+
21+
#ifdef __cplusplus
22+
extern "C" {
23+
#endif // __cplusplus
24+
25+
// A single predicted class.
26+
typedef struct TfLiteCategory {
27+
// The index of the class in the corresponding label map, usually packed in
28+
// the TFLite Model Metadata [1].
29+
//
30+
// [1]: https://www.tensorflow.org/lite/convert/metadata
31+
int index;
32+
33+
// The score for this class e.g. (but not necessarily) a probability in [0,1].
34+
float score;
35+
36+
// A human readable name of the class filled from the label map.
37+
char* display_name;
38+
// An ID for the class, not necessarily human-readable (e.g. a Google
39+
// Knowledge Graph ID [1]), filled from the label map.
40+
//
41+
// [1]: https://developers.google.com/knowledge-graph
42+
char* label;
43+
} TfLiteCategory;
44+
45+
#ifdef __cplusplus
46+
} // extern "C"
47+
#endif // __cplusplus
48+
49+
#endif // TENSORFLOW_LITE_SUPPORT_C_TASK_VISION_CATEGORY_H_

0 commit comments

Comments
 (0)