Internal change
PiperOrigin-RevId: 517886450
This commit is contained in:
parent
524acaaaa7
commit
47fa1a9578
|
@ -138,7 +138,7 @@ class InferenceSubgraph : public Subgraph {
|
||||||
delegate.mutable_tflite()->CopyFrom(acceleration.tflite());
|
delegate.mutable_tflite()->CopyFrom(acceleration.tflite());
|
||||||
break;
|
break;
|
||||||
case Acceleration::DELEGATE_NOT_SET:
|
case Acceleration::DELEGATE_NOT_SET:
|
||||||
// Deafult inference calculator setting.
|
// Default inference calculator setting.
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
return delegate;
|
return delegate;
|
||||||
|
|
|
@ -124,10 +124,10 @@ class ModelTaskGraph : public Subgraph {
|
||||||
// Inserts a mediapipe task inference subgraph into the provided
|
// Inserts a mediapipe task inference subgraph into the provided
|
||||||
// GraphBuilder. The returned node provides the following interfaces to the
|
// GraphBuilder. The returned node provides the following interfaces to the
|
||||||
// the rest of the graph:
|
// the rest of the graph:
|
||||||
// - a tensor vector (std::vector<MeidaPipe::Tensor>) input stream with tag
|
// - a tensor vector (std::vector<mediapipe::Tensor>) input stream with tag
|
||||||
// "TENSORS", representing the input tensors to be consumed by the
|
// "TENSORS", representing the input tensors to be consumed by the
|
||||||
// inference engine.
|
// inference engine.
|
||||||
// - a tensor vector (std::vector<MeidaPipe::Tensor>) output stream with tag
|
// - a tensor vector (std::vector<mediapipe::Tensor>) output stream with tag
|
||||||
// "TENSORS", representing the output tensors generated by the inference
|
// "TENSORS", representing the output tensors generated by the inference
|
||||||
// engine.
|
// engine.
|
||||||
// - a MetadataExtractor output side packet with tag "METADATA_EXTRACTOR".
|
// - a MetadataExtractor output side packet with tag "METADATA_EXTRACTOR".
|
||||||
|
|
|
@ -301,7 +301,7 @@ absl::Status TaskRunner::Close() {
|
||||||
}
|
}
|
||||||
is_running_ = false;
|
is_running_ = false;
|
||||||
MP_RETURN_IF_ERROR(
|
MP_RETURN_IF_ERROR(
|
||||||
AddPayload(graph_.CloseAllInputStreams(), "Fail to close intput streams",
|
AddPayload(graph_.CloseAllInputStreams(), "Fail to close input streams",
|
||||||
MediaPipeTasksStatus::kRunnerFailsToCloseError));
|
MediaPipeTasksStatus::kRunnerFailsToCloseError));
|
||||||
MP_RETURN_IF_ERROR(AddPayload(
|
MP_RETURN_IF_ERROR(AddPayload(
|
||||||
graph_.WaitUntilDone(), "Fail to shutdown the MediaPipe graph.",
|
graph_.WaitUntilDone(), "Fail to shutdown the MediaPipe graph.",
|
||||||
|
|
|
@ -65,7 +65,7 @@ class TaskRunner {
|
||||||
// Creates the task runner with a CalculatorGraphConfig proto.
|
// Creates the task runner with a CalculatorGraphConfig proto.
|
||||||
// If a tflite op resolver object is provided, the task runner will take
|
// If a tflite op resolver object is provided, the task runner will take
|
||||||
// it as the global op resolver for all models running within this task.
|
// it as the global op resolver for all models running within this task.
|
||||||
// The op resolver's owernship will be transferred into the pipeleine runner.
|
// The op resolver's ownership will be transferred into the pipeleine runner.
|
||||||
// When a user-defined PacketsCallback is provided, clients must use the
|
// When a user-defined PacketsCallback is provided, clients must use the
|
||||||
// asynchronous method, Send(), to provide the input packets. If the packets
|
// asynchronous method, Send(), to provide the input packets. If the packets
|
||||||
// callback is absent, clients must use the synchronous method, Process(), to
|
// callback is absent, clients must use the synchronous method, Process(), to
|
||||||
|
@ -84,7 +84,7 @@ class TaskRunner {
|
||||||
// frames from a video file and an audio file. The call blocks the current
|
// frames from a video file and an audio file. The call blocks the current
|
||||||
// thread until a failure status or a successful result is returned.
|
// thread until a failure status or a successful result is returned.
|
||||||
// If the input packets have no timestamp, an internal timestamp will be
|
// If the input packets have no timestamp, an internal timestamp will be
|
||||||
// assigend per invocation. Otherwise, when the timestamp is set in the
|
// assigned per invocation. Otherwise, when the timestamp is set in the
|
||||||
// input packets, the caller must ensure that the input packet timestamps are
|
// input packets, the caller must ensure that the input packet timestamps are
|
||||||
// greater than the timestamps of the previous invocation. This method is
|
// greater than the timestamps of the previous invocation. This method is
|
||||||
// thread-unsafe and it is the caller's responsibility to synchronize access
|
// thread-unsafe and it is the caller's responsibility to synchronize access
|
||||||
|
|
|
@ -213,7 +213,7 @@ void UpdateMinimumVersionForTable<tflite::Content>(const tflite::Content* table,
|
||||||
Version* min_version) {
|
Version* min_version) {
|
||||||
if (table == nullptr) return;
|
if (table == nullptr) return;
|
||||||
|
|
||||||
// Checks the ContenProperties field.
|
// Checks the ContentProperties field.
|
||||||
if (table->content_properties_type() == ContentProperties_AudioProperties) {
|
if (table->content_properties_type() == ContentProperties_AudioProperties) {
|
||||||
UpdateMinimumVersion(
|
UpdateMinimumVersion(
|
||||||
GetMemberVersion(SchemaMembers::kContentPropertiesAudioProperties),
|
GetMemberVersion(SchemaMembers::kContentPropertiesAudioProperties),
|
||||||
|
|
|
@ -265,7 +265,7 @@ TEST(MetadataVersionTest,
|
||||||
metadata_builder.add_subgraph_metadata(subgraphs);
|
metadata_builder.add_subgraph_metadata(subgraphs);
|
||||||
FinishModelMetadataBuffer(builder, metadata_builder.Finish());
|
FinishModelMetadataBuffer(builder, metadata_builder.Finish());
|
||||||
|
|
||||||
// Gets the mimimum metadata parser version.
|
// Gets the minimum metadata parser version.
|
||||||
std::string min_version;
|
std::string min_version;
|
||||||
EXPECT_EQ(GetMinimumMetadataParserVersion(builder.GetBufferPointer(),
|
EXPECT_EQ(GetMinimumMetadataParserVersion(builder.GetBufferPointer(),
|
||||||
builder.GetSize(), &min_version),
|
builder.GetSize(), &min_version),
|
||||||
|
|
|
@ -56,7 +56,7 @@ extern "C" {
|
||||||
int utf_runetochar(char* s, const Rune* r);
|
int utf_runetochar(char* s, const Rune* r);
|
||||||
|
|
||||||
// utf_charntorune copies (decodes) at most UTFmax bytes starting at `str` to
|
// utf_charntorune copies (decodes) at most UTFmax bytes starting at `str` to
|
||||||
// one rune, pointed to by `rune`, accesss at most `length` bytes of `str`, and
|
// one rune, pointed to by `rune`, access at most `length` bytes of `str`, and
|
||||||
// returns the number of bytes consumed.
|
// returns the number of bytes consumed.
|
||||||
// If the UTF sequence is incomplete within n bytes,
|
// If the UTF sequence is incomplete within n bytes,
|
||||||
// utf_charntorune will set *r to Runeerror and return 0. If it is complete
|
// utf_charntorune will set *r to Runeerror and return 0. If it is complete
|
||||||
|
|
|
@ -74,7 +74,7 @@ class FaceDetector : core::BaseVisionTaskApi {
|
||||||
// three running modes:
|
// three running modes:
|
||||||
// 1) Image mode for detecting faces on single image inputs. Users
|
// 1) Image mode for detecting faces on single image inputs. Users
|
||||||
// provide mediapipe::Image to the `Detect` method, and will receive the
|
// provide mediapipe::Image to the `Detect` method, and will receive the
|
||||||
// deteced face detection results as the return value.
|
// detected face detection results as the return value.
|
||||||
// 2) Video mode for detecting faces on the decoded frames of a
|
// 2) Video mode for detecting faces on the decoded frames of a
|
||||||
// video. Users call `DetectForVideo` method, and will receive the detected
|
// video. Users call `DetectForVideo` method, and will receive the detected
|
||||||
// face detection results as the return value.
|
// face detection results as the return value.
|
||||||
|
|
|
@ -99,7 +99,7 @@ class ScreenToMetricSpaceConverter {
|
||||||
//
|
//
|
||||||
// (3) Use the canonical-to-runtime scale from (2) to unproject the screen
|
// (3) Use the canonical-to-runtime scale from (2) to unproject the screen
|
||||||
// landmarks. The result is referenced as "intermediate landmarks" because
|
// landmarks. The result is referenced as "intermediate landmarks" because
|
||||||
// they are the first estimation of the resuling metric landmarks, but are
|
// they are the first estimation of the resulting metric landmarks,but are
|
||||||
// not quite there yet.
|
// not quite there yet.
|
||||||
//
|
//
|
||||||
// (4) Estimate a canonical-to-runtime landmark set scale by running the
|
// (4) Estimate a canonical-to-runtime landmark set scale by running the
|
||||||
|
@ -347,7 +347,7 @@ class GeometryPipelineImpl : public GeometryPipeline {
|
||||||
proto::Mesh3d* mutable_mesh = face_geometry.mutable_mesh();
|
proto::Mesh3d* mutable_mesh = face_geometry.mutable_mesh();
|
||||||
// Copy the canonical face mesh as the face geometry mesh.
|
// Copy the canonical face mesh as the face geometry mesh.
|
||||||
mutable_mesh->CopyFrom(canonical_mesh_);
|
mutable_mesh->CopyFrom(canonical_mesh_);
|
||||||
// Replace XYZ vertex mesh coodinates with the metric landmark positions.
|
// Replace XYZ vertex mesh coordinates with the metric landmark positions.
|
||||||
for (int i = 0; i < canonical_mesh_num_vertices_; ++i) {
|
for (int i = 0; i < canonical_mesh_num_vertices_; ++i) {
|
||||||
uint32_t vertex_buffer_offset = canonical_mesh_vertex_size_ * i +
|
uint32_t vertex_buffer_offset = canonical_mesh_vertex_size_ * i +
|
||||||
canonical_mesh_vertex_position_offset_;
|
canonical_mesh_vertex_position_offset_;
|
||||||
|
|
|
@ -28,7 +28,7 @@ message FaceGeometry {
|
||||||
// the face landmark IDs.
|
// the face landmark IDs.
|
||||||
//
|
//
|
||||||
// XYZ coordinates exist in the right-handed Metric 3D space configured by an
|
// XYZ coordinates exist in the right-handed Metric 3D space configured by an
|
||||||
// environment. UV coodinates are taken from the canonical face mesh model.
|
// environment. UV coordinates are taken from the canonical face mesh model.
|
||||||
//
|
//
|
||||||
// XY coordinates are guaranteed to match the screen positions of
|
// XY coordinates are guaranteed to match the screen positions of
|
||||||
// the input face landmarks after (1) being multiplied by the face pose
|
// the input face landmarks after (1) being multiplied by the face pose
|
||||||
|
|
|
@ -109,7 +109,7 @@ class FaceLandmarker : tasks::vision::core::BaseVisionTaskApi {
|
||||||
// three running modes:
|
// three running modes:
|
||||||
// 1) Image mode for detecting face landmarks on single image inputs. Users
|
// 1) Image mode for detecting face landmarks on single image inputs. Users
|
||||||
// provide mediapipe::Image to the `Detect` method, and will receive the
|
// provide mediapipe::Image to the `Detect` method, and will receive the
|
||||||
// deteced face landmarks results as the return value.
|
// detected face landmarks results as the return value.
|
||||||
// 2) Video mode for detecting face landmarks on the decoded frames of a
|
// 2) Video mode for detecting face landmarks on the decoded frames of a
|
||||||
// video. Users call `DetectForVideo` method, and will receive the detected
|
// video. Users call `DetectForVideo` method, and will receive the detected
|
||||||
// face landmarks results as the return value.
|
// face landmarks results as the return value.
|
||||||
|
|
|
@ -160,7 +160,7 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources,
|
||||||
->mutable_acceleration()
|
->mutable_acceleration()
|
||||||
->mutable_xnnpack();
|
->mutable_xnnpack();
|
||||||
LOG(WARNING) << "Face blendshape model contains CPU only ops. Sets "
|
LOG(WARNING) << "Face blendshape model contains CPU only ops. Sets "
|
||||||
<< "FaceBlendshapesGraph acceleartion to Xnnpack.";
|
<< "FaceBlendshapesGraph acceleration to Xnnpack.";
|
||||||
}
|
}
|
||||||
|
|
||||||
return absl::OkStatus();
|
return absl::OkStatus();
|
||||||
|
@ -180,7 +180,7 @@ absl::Status SetSubTaskBaseOptions(const ModelAssetBundleResources& resources,
|
||||||
// would be triggered to detect faces.
|
// would be triggered to detect faces.
|
||||||
//
|
//
|
||||||
// FaceGeometryFromLandmarksGraph finds the transformation from canonical face
|
// FaceGeometryFromLandmarksGraph finds the transformation from canonical face
|
||||||
// to the detected faces. This transformation is useful for renderring face
|
// to the detected faces. This transformation is useful for rendering face
|
||||||
// effects on the detected faces. This subgraph is added if users request a
|
// effects on the detected faces. This subgraph is added if users request a
|
||||||
// FaceGeometry Tag.
|
// FaceGeometry Tag.
|
||||||
//
|
//
|
||||||
|
@ -324,7 +324,7 @@ class FaceLandmarkerGraph : public core::ModelTaskGraph {
|
||||||
!sc->Service(::mediapipe::tasks::core::kModelResourcesCacheService)
|
!sc->Service(::mediapipe::tasks::core::kModelResourcesCacheService)
|
||||||
.IsAvailable()));
|
.IsAvailable()));
|
||||||
if (output_geometry) {
|
if (output_geometry) {
|
||||||
// Set the face geometry metdata file for
|
// Set the face geometry metadata file for
|
||||||
// FaceGeometryFromLandmarksGraph.
|
// FaceGeometryFromLandmarksGraph.
|
||||||
ASSIGN_OR_RETURN(auto face_geometry_pipeline_metadata_file,
|
ASSIGN_OR_RETURN(auto face_geometry_pipeline_metadata_file,
|
||||||
model_asset_bundle_resources->GetFile(
|
model_asset_bundle_resources->GetFile(
|
||||||
|
|
|
@ -462,7 +462,7 @@ REGISTER_MEDIAPIPE_GRAPH(
|
||||||
// - Accepts an input image and a vector of face rect RoIs to detect the
|
// - Accepts an input image and a vector of face rect RoIs to detect the
|
||||||
// multiple face landmarks enclosed by the RoIs. Output vectors of
|
// multiple face landmarks enclosed by the RoIs. Output vectors of
|
||||||
// face landmarks related results, where each element in the vectors
|
// face landmarks related results, where each element in the vectors
|
||||||
// corrresponds to the result of the same face.
|
// corresponds to the result of the same face.
|
||||||
//
|
//
|
||||||
// Inputs:
|
// Inputs:
|
||||||
// IMAGE - Image
|
// IMAGE - Image
|
||||||
|
|
|
@ -81,7 +81,7 @@ class FaceStylizer : tasks::vision::core::BaseVisionTaskApi {
|
||||||
// running mode.
|
// running mode.
|
||||||
//
|
//
|
||||||
// The input image can be of any size with format RGB or RGBA.
|
// The input image can be of any size with format RGB or RGBA.
|
||||||
// To ensure that the output image has reasonable quailty, the stylized output
|
// To ensure that the output image has reasonable quality, the stylized output
|
||||||
// image size is the smaller of the model output size and the size of the
|
// image size is the smaller of the model output size and the size of the
|
||||||
// 'region_of_interest' specified in 'image_processing_options'.
|
// 'region_of_interest' specified in 'image_processing_options'.
|
||||||
absl::StatusOr<mediapipe::Image> Stylize(
|
absl::StatusOr<mediapipe::Image> Stylize(
|
||||||
|
@ -106,7 +106,7 @@ class FaceStylizer : tasks::vision::core::BaseVisionTaskApi {
|
||||||
// The image can be of any size with format RGB or RGBA. It's required to
|
// The image can be of any size with format RGB or RGBA. It's required to
|
||||||
// provide the video frame's timestamp (in milliseconds). The input timestamps
|
// provide the video frame's timestamp (in milliseconds). The input timestamps
|
||||||
// must be monotonically increasing.
|
// must be monotonically increasing.
|
||||||
// To ensure that the output image has reasonable quailty, the stylized output
|
// To ensure that the output image has reasonable quality, the stylized output
|
||||||
// image size is the smaller of the model output size and the size of the
|
// image size is the smaller of the model output size and the size of the
|
||||||
// 'region_of_interest' specified in 'image_processing_options'.
|
// 'region_of_interest' specified in 'image_processing_options'.
|
||||||
absl::StatusOr<mediapipe::Image> StylizeForVideo(
|
absl::StatusOr<mediapipe::Image> StylizeForVideo(
|
||||||
|
|
|
@ -73,7 +73,7 @@ struct PoseDetectionOuts {
|
||||||
// detector with model metadata.
|
// detector with model metadata.
|
||||||
void ConfigureSsdAnchorsCalculator(
|
void ConfigureSsdAnchorsCalculator(
|
||||||
mediapipe::SsdAnchorsCalculatorOptions* options) {
|
mediapipe::SsdAnchorsCalculatorOptions* options) {
|
||||||
// Dervied from
|
// Derived from
|
||||||
// mediapipe/modules/pose_detection/pose_detection_gpu.pbtxt
|
// mediapipe/modules/pose_detection/pose_detection_gpu.pbtxt
|
||||||
options->set_num_layers(5);
|
options->set_num_layers(5);
|
||||||
options->set_min_scale(0.1484375);
|
options->set_min_scale(0.1484375);
|
||||||
|
@ -96,7 +96,7 @@ void ConfigureSsdAnchorsCalculator(
|
||||||
void ConfigureTensorsToDetectionsCalculator(
|
void ConfigureTensorsToDetectionsCalculator(
|
||||||
const PoseDetectorGraphOptions& tasks_options,
|
const PoseDetectorGraphOptions& tasks_options,
|
||||||
mediapipe::TensorsToDetectionsCalculatorOptions* options) {
|
mediapipe::TensorsToDetectionsCalculatorOptions* options) {
|
||||||
// Dervied from
|
// Derived from
|
||||||
// mediapipe/modules/pose_detection/pose_detection_gpu.pbtxt
|
// mediapipe/modules/pose_detection/pose_detection_gpu.pbtxt
|
||||||
options->set_num_classes(1);
|
options->set_num_classes(1);
|
||||||
options->set_num_boxes(2254);
|
options->set_num_boxes(2254);
|
||||||
|
|
|
@ -70,7 +70,7 @@ extern NSString *const MPPTasksErrorDomain;
|
||||||
* @param error Pointer to the memory location where errors if any should be saved. If `nil`, no
|
* @param error Pointer to the memory location where errors if any should be saved. If `nil`, no
|
||||||
* error will be saved.
|
* error will be saved.
|
||||||
*
|
*
|
||||||
* @return Pointer to the allocated block of memory on successfull allocation. `nil` in case as
|
* @return Pointer to the allocated block of memory on successful allocation. `nil` in case as
|
||||||
* error is encountered because of invalid `memSize`. If failure is due to any other reason, method
|
* error is encountered because of invalid `memSize`. If failure is due to any other reason, method
|
||||||
* terminates program execution.
|
* terminates program execution.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -22,7 +22,7 @@
|
||||||
NS_ASSUME_NONNULL_BEGIN
|
NS_ASSUME_NONNULL_BEGIN
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Holds all needed informaton to initialize a MediaPipe Task.
|
* Holds all needed information to initialize a MediaPipe Task.
|
||||||
*/
|
*/
|
||||||
@interface MPPTaskInfo : NSObject <NSCopying>
|
@interface MPPTaskInfo : NSObject <NSCopying>
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
* additional functionality. For eg:, vision tasks must create an `MPPVisionTaskRunner` and provide
|
* additional functionality. For eg:, vision tasks must create an `MPPVisionTaskRunner` and provide
|
||||||
* additional functionality. An instance of `MPPVisionTaskRunner` can in turn be used by the each
|
* additional functionality. An instance of `MPPVisionTaskRunner` can in turn be used by the each
|
||||||
* vision task for creation and execution of the task. Please see the documentation for the C++ Task
|
* vision task for creation and execution of the task. Please see the documentation for the C++ Task
|
||||||
* Runner for more details on how the taks runner operates.
|
* Runner for more details on how the tasks runner operates.
|
||||||
*/
|
*/
|
||||||
@interface MPPTaskRunner : NSObject
|
@interface MPPTaskRunner : NSObject
|
||||||
|
|
||||||
|
@ -66,7 +66,7 @@ NS_ASSUME_NONNULL_BEGIN
|
||||||
* for processing either batch data such as unrelated images and texts or offline streaming data
|
* for processing either batch data such as unrelated images and texts or offline streaming data
|
||||||
* such as the decoded frames from a video file or audio file. The call blocks the current
|
* such as the decoded frames from a video file or audio file. The call blocks the current
|
||||||
* thread until a failure status or a successful result is returned. If the input packets have no
|
* thread until a failure status or a successful result is returned. If the input packets have no
|
||||||
* timestamp, an internal timestamp will be assigend per invocation. Otherwise, when the timestamp
|
* timestamp, an internal timestamp will be assigned per invocation. Otherwise, when the timestamp
|
||||||
* is set in the input packets, the caller must ensure that the input packet timestamps are greater
|
* is set in the input packets, the caller must ensure that the input packet timestamps are greater
|
||||||
* than the timestamps of the previous invocation. This method is thread-unsafe and it is the
|
* than the timestamps of the previous invocation. This method is thread-unsafe and it is the
|
||||||
* caller's responsibility to synchronize access to this method across multiple threads and to
|
* caller's responsibility to synchronize access to this method across multiple threads and to
|
||||||
|
|
|
@ -96,7 +96,7 @@ Args:
|
||||||
Raises:
|
Raises:
|
||||||
RuntimeError: Any of the following:
|
RuntimeError: Any of the following:
|
||||||
a) The graph config proto is invalid.
|
a) The graph config proto is invalid.
|
||||||
b) The underlying medipaipe graph fails to initilize and start.
|
b) The underlying medipaipe graph fails to initialize and start.
|
||||||
)doc",
|
)doc",
|
||||||
py::arg("graph_config"), py::arg("packets_callback") = py::none());
|
py::arg("graph_config"), py::arg("packets_callback") = py::none());
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ This method is designed for processing either batch data such as unrelated
|
||||||
images and texts or offline streaming data such as the decoded frames from a
|
images and texts or offline streaming data such as the decoded frames from a
|
||||||
video file and an audio file. The call blocks the current thread until a failure
|
video file and an audio file. The call blocks the current thread until a failure
|
||||||
status or a successful result is returned.
|
status or a successful result is returned.
|
||||||
If the input packets have no timestamp, an internal timestamp will be assigend
|
If the input packets have no timestamp, an internal timestamp will be assigned
|
||||||
per invocation. Otherwise, when the timestamp is set in the input packets, the
|
per invocation. Otherwise, when the timestamp is set in the input packets, the
|
||||||
caller must ensure that the input packet timestamps are greater than the
|
caller must ensure that the input packet timestamps are greater than the
|
||||||
timestamps of the previous invocation. This method is thread-unsafe and it is
|
timestamps of the previous invocation. This method is thread-unsafe and it is
|
||||||
|
|
|
@ -112,10 +112,10 @@ class MetadataPopulator(object):
|
||||||
mediapipe/tasks/metadata/metadata_schema.fbs
|
mediapipe/tasks/metadata/metadata_schema.fbs
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
Populate matadata and label file into an image classifier model.
|
Populate metadata and label file into an image classifier model.
|
||||||
|
|
||||||
First, based on metadata_schema.fbs, generate the metadata for this image
|
First, based on metadata_schema.fbs, generate the metadata for this image
|
||||||
classifer model using Flatbuffers API. Attach the label file onto the ouput
|
classifier model using Flatbuffers API. Attach the label file onto the output
|
||||||
tensor (the tensor of probabilities) in the metadata.
|
tensor (the tensor of probabilities) in the metadata.
|
||||||
|
|
||||||
Then, pack the metadata and label file into the model as follows.
|
Then, pack the metadata and label file into the model as follows.
|
||||||
|
@ -173,7 +173,7 @@ class MetadataPopulator(object):
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
IOError: File not found.
|
IOError: File not found.
|
||||||
ValueError: the model does not have the expected flatbuffer identifer.
|
ValueError: the model does not have the expected flatbuffer identifier.
|
||||||
"""
|
"""
|
||||||
_assert_model_file_identifier(model_file)
|
_assert_model_file_identifier(model_file)
|
||||||
self._model_file = model_file
|
self._model_file = model_file
|
||||||
|
@ -193,7 +193,7 @@ class MetadataPopulator(object):
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
IOError: File not found.
|
IOError: File not found.
|
||||||
ValueError: the model does not have the expected flatbuffer identifer.
|
ValueError: the model does not have the expected flatbuffer identifier.
|
||||||
"""
|
"""
|
||||||
return cls(model_file)
|
return cls(model_file)
|
||||||
|
|
||||||
|
@ -210,7 +210,7 @@ class MetadataPopulator(object):
|
||||||
A MetadataPopulator(_MetadataPopulatorWithBuffer) object.
|
A MetadataPopulator(_MetadataPopulatorWithBuffer) object.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: the model does not have the expected flatbuffer identifer.
|
ValueError: the model does not have the expected flatbuffer identifier.
|
||||||
"""
|
"""
|
||||||
return _MetadataPopulatorWithBuffer(model_buf)
|
return _MetadataPopulatorWithBuffer(model_buf)
|
||||||
|
|
||||||
|
@ -293,7 +293,7 @@ class MetadataPopulator(object):
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: The metadata to be populated is empty.
|
ValueError: The metadata to be populated is empty.
|
||||||
ValueError: The metadata does not have the expected flatbuffer identifer.
|
ValueError: The metadata does not have the expected flatbuffer identifier.
|
||||||
ValueError: Cannot get minimum metadata parser version.
|
ValueError: Cannot get minimum metadata parser version.
|
||||||
ValueError: The number of SubgraphMetadata is not 1.
|
ValueError: The number of SubgraphMetadata is not 1.
|
||||||
ValueError: The number of input/output tensors does not match the number
|
ValueError: The number of input/output tensors does not match the number
|
||||||
|
@ -646,7 +646,7 @@ class MetadataPopulator(object):
|
||||||
|
|
||||||
|
|
||||||
class _MetadataPopulatorWithBuffer(MetadataPopulator):
|
class _MetadataPopulatorWithBuffer(MetadataPopulator):
|
||||||
"""Subclass of MetadtaPopulator that populates metadata to a model buffer.
|
"""Subclass of MetadataPopulator that populates metadata to a model buffer.
|
||||||
|
|
||||||
This class is used to populate metadata into a in-memory model buffer. As we
|
This class is used to populate metadata into a in-memory model buffer. As we
|
||||||
use Zip API to concatenate associated files after tflite model file, the
|
use Zip API to concatenate associated files after tflite model file, the
|
||||||
|
@ -664,7 +664,7 @@ class _MetadataPopulatorWithBuffer(MetadataPopulator):
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: model_buf is empty.
|
ValueError: model_buf is empty.
|
||||||
ValueError: model_buf does not have the expected flatbuffer identifer.
|
ValueError: model_buf does not have the expected flatbuffer identifier.
|
||||||
"""
|
"""
|
||||||
if not model_buf:
|
if not model_buf:
|
||||||
raise ValueError("model_buf cannot be empty.")
|
raise ValueError("model_buf cannot be empty.")
|
||||||
|
@ -826,7 +826,7 @@ def convert_to_json(
|
||||||
metadata_buffer: valid metadata buffer in bytes.
|
metadata_buffer: valid metadata buffer in bytes.
|
||||||
custom_metadata_schema: A dict of custom metadata schema, in which key is
|
custom_metadata_schema: A dict of custom metadata schema, in which key is
|
||||||
custom metadata name [1], value is the filepath that defines custom
|
custom metadata name [1], value is the filepath that defines custom
|
||||||
metadata schema. For intance, custom_metadata_schema =
|
metadata schema. For instance, custom_metadata_schema =
|
||||||
{"SEGMENTER_METADATA": "metadata/vision_tasks_metadata_schema.fbs"}. [1]:
|
{"SEGMENTER_METADATA": "metadata/vision_tasks_metadata_schema.fbs"}. [1]:
|
||||||
https://github.com/google/mediapipe/blob/46b5c4012d2ef76c9d92bb0d88a6b107aee83814/mediapipe/tasks/metadata/metadata_schema.fbs#L612
|
https://github.com/google/mediapipe/blob/46b5c4012d2ef76c9d92bb0d88a6b107aee83814/mediapipe/tasks/metadata/metadata_schema.fbs#L612
|
||||||
|
|
||||||
|
@ -834,7 +834,7 @@ def convert_to_json(
|
||||||
Metadata in JSON format.
|
Metadata in JSON format.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: error occured when parsing the metadata schema file.
|
ValueError: error occurred when parsing the metadata schema file.
|
||||||
"""
|
"""
|
||||||
opt = _pywrap_flatbuffers.IDLOptions()
|
opt = _pywrap_flatbuffers.IDLOptions()
|
||||||
opt.strict_json = True
|
opt.strict_json = True
|
||||||
|
|
|
@ -59,7 +59,7 @@ def convert_to_json(metadata_buffer: bytearray) -> str:
|
||||||
Metadata in JSON format.
|
Metadata in JSON format.
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: error occured when parsing the metadata schema file.
|
ValueError: error occurred when parsing the metadata schema file.
|
||||||
"""
|
"""
|
||||||
return metadata.convert_to_json(
|
return metadata.convert_to_json(
|
||||||
metadata_buffer,
|
metadata_buffer,
|
||||||
|
|
|
@ -161,7 +161,7 @@ describe('AudioEmbedder', () => {
|
||||||
{floatEmbedding: [0.1, 0.9], headIndex: 1, headName: 'headName'});
|
{floatEmbedding: [0.1, 0.9], headIndex: 1, headName: 'headName'});
|
||||||
}
|
}
|
||||||
|
|
||||||
it('from embeddings strem', async () => {
|
it('from embeddings stream', async () => {
|
||||||
audioEmbedder.fakeWasmModule._waitUntilIdle.and.callFake(() => {
|
audioEmbedder.fakeWasmModule._waitUntilIdle.and.callFake(() => {
|
||||||
verifyListenersRegistered(audioEmbedder);
|
verifyListenersRegistered(audioEmbedder);
|
||||||
// Pass the test data to our listener
|
// Pass the test data to our listener
|
||||||
|
|
|
@ -44,7 +44,7 @@ export declare interface GestureRecognizerOptions extends VisionTaskOptions {
|
||||||
minTrackingConfidence?: number|undefined;
|
minTrackingConfidence?: number|undefined;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the optional `ClassifierOptions` controling the canned gestures
|
* Sets the optional `ClassifierOptions` controlling the canned gestures
|
||||||
* classifier, such as score threshold, allow list and deny list of gestures.
|
* classifier, such as score threshold, allow list and deny list of gestures.
|
||||||
* The categories for canned gesture
|
* The categories for canned gesture
|
||||||
* classifiers are: ["None", "Closed_Fist", "Open_Palm", "Pointing_Up",
|
* classifiers are: ["None", "Closed_Fist", "Open_Palm", "Pointing_Up",
|
||||||
|
|
Loading…
Reference in New Issue
Block a user