/* Copyright 2021 The TensorFlow Authors. All Rights Reserved. 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. ==============================================================================*/ #ifndef TENSORFLOW_LITE_SUPPORT_CC_TASK_VISION_IMAGE_EMBEDDER_H_ #define TENSORFLOW_LITE_SUPPORT_CC_TASK_VISION_IMAGE_EMBEDDER_H_ #include <vector> #include "absl/status/status.h" // from @com_google_absl #include "tensorflow/lite/core/api/op_resolver.h" #include "tensorflow/lite/kernels/register.h" #include "tensorflow_lite_support/cc/port/integral_types.h" #include "tensorflow_lite_support/cc/port/statusor.h" #include "tensorflow_lite_support/cc/task/core/external_file_handler.h" #include "tensorflow_lite_support/cc/task/processor/embedding_postprocessor.h" #include "tensorflow_lite_support/cc/task/vision/core/base_vision_task_api.h" #include "tensorflow_lite_support/cc/task/vision/core/frame_buffer.h" #include "tensorflow_lite_support/cc/task/vision/proto/bounding_box_proto_inc.h" #include "tensorflow_lite_support/cc/task/vision/proto/embeddings_proto_inc.h" #include "tensorflow_lite_support/cc/task/vision/proto/image_embedder_options_proto_inc.h" namespace tflite { namespace task { namespace vision { // Performs dense feature vector extraction on images. // // The API expects a TFLite model with optional, but strongly recommended, // TFLite Model Metadata. // // Input tensor: // (kTfLiteUInt8/kTfLiteFloat32) // - image input of size `[batch x height x width x channels]`. // - batch inference is not supported (`batch` is required to be 1). // - only RGB inputs are supported (`channels` is required to be 3). // - if type is kTfLiteFloat32, NormalizationOptions are required to be // attached to the metadata for input normalization. // At least one output tensor with: // (kTfLiteUInt8/kTfLiteFloat32) // - `N` components corresponding to the `N` dimensions of the returned // feature vector for this output layer. // - Either 2 or 4 dimensions, i.e. `[1 x N]` or `[1 x 1 x 1 x N]`. // // TODO(b/180502532): add pointer to example model. // // A CLI demo tool is available for easily trying out this API, and provides // example usage. See: // examples/task/vision/desktop/image_embedder_demo.cc class ImageEmbedder : public tflite::task::vision::BaseVisionTaskApi<EmbeddingResult> { … }; } // namespace vision } // namespace task } // namespace tflite #endif // TENSORFLOW_LITE_SUPPORT_CC_TASK_VISION_IMAGE_EMBEDDER_H_