File tree Expand file tree Collapse file tree 3 files changed +28
-15
lines changed
Expand file tree Collapse file tree 3 files changed +28
-15
lines changed Original file line number Diff line number Diff line change @@ -45,8 +45,17 @@ typedef struct TfLiteClassificationOptions {
4545 // class labels are ignored. Mutually exclusive with label_denylist.
4646 TfLiteStringArrayOption label_allowlist ;
4747
48+ // The locale to use for display names specified through the TFLite Model
49+ // Metadata, if any. Defaults to English.
4850 const char * display_names_local ;
51+
52+ // The maximum number of top-scored classification results to return. If < 0,
53+ // all available results will be returned. If 0, an invalid argument error is
54+ // returned. Defaults to -1.
4955 int max_results ;
56+
57+ // Score threshold, overrides the ones provided in the model metadata
58+ // (if any). Results below this value are rejected.
5059 float score_threshold ;
5160} TfLiteClassificationOptions ;
5261
Original file line number Diff line number Diff line change @@ -32,21 +32,6 @@ using ImageClassifierCpp = ::tflite::task::vision::ImageClassifier;
3232using ImageClassifierOptionsCpp =
3333 ::tflite::task::vision::ImageClassifierOptions;
3434using FrameBufferCpp = ::tflite::task::vision::FrameBuffer;
35- } // namespace
36-
37- #ifdef __cplusplus
38- extern " C" {
39- #endif // __cplusplus
40-
41- struct TfLiteImageClassifier {
42- std::unique_ptr<ImageClassifierCpp> impl;
43- };
44-
45- TfLiteImageClassifierOptions TfLiteImageClassifierOptionsCreate () {
46- return {.classification_options = {.max_results = -1 },
47- .base_options = {
48- .compute_settings = {.cpu_settings = {.num_threads = -1 }}}};
49- }
5035
5136std::unique_ptr<ImageClassifierOptionsCpp>
5237CreateImageClassifierCppOptionsFromCOptions (
@@ -98,6 +83,24 @@ CreateImageClassifierCppOptionsFromCOptions(
9883
9984 return cpp_options;
10085}
86+ } // namespace
87+
88+ #ifdef __cplusplus
89+ extern " C" {
90+ #endif // __cplusplus
91+
92+ struct TfLiteImageClassifier {
93+ std::unique_ptr<ImageClassifierCpp> impl;
94+ };
95+
96+ TfLiteImageClassifierOptions TfLiteImageClassifierOptionsCreate () {
97+ // Use brace-enclosed initializer list will break the Kokoro test.
98+ TfLiteImageClassifierOptions options = {{{0 }}};
99+ options.classification_options .max_results = -1 ;
100+ options.classification_options .score_threshold = 0.0 ;
101+ options.base_options .compute_settings .cpu_settings .num_threads = -1 ;
102+ return options;
103+ }
101104
102105TfLiteImageClassifier* TfLiteImageClassifierFromOptions (
103106 const TfLiteImageClassifierOptions* options) {
Original file line number Diff line number Diff line change @@ -56,6 +56,7 @@ bazel build -c opt ${BAZEL_PARALLEL} --define=darwinn_portable=1 \
5656bazel clean
5757
5858bazel test $BAZEL_PARALLEL --test_output=all \
59+ //tensorflow_lite_support/c/test/... \
5960 //tensorflow_lite_support/cc/test/task/vision:all \
6061 //tensorflow_lite_support/custom_ops/kernel/sentencepiece:all \
6162 //tensorflow_lite_support/metadata/python/tests:metadata_test \
You can’t perform that action at this time.
0 commit comments