mediapipe-nightly 0.10.21.post20250114__cp311-cp311-manylinux_2_28_x86_64.whl
Sign up to get free protection for your applications and to get access to all the features.
- mediapipe/__init__.py +26 -0
- mediapipe/calculators/__init__.py +0 -0
- mediapipe/calculators/audio/__init__.py +0 -0
- mediapipe/calculators/audio/mfcc_mel_calculators_pb2.py +33 -0
- mediapipe/calculators/audio/rational_factor_resample_calculator_pb2.py +33 -0
- mediapipe/calculators/audio/spectrogram_calculator_pb2.py +37 -0
- mediapipe/calculators/audio/stabilized_log_calculator_pb2.py +31 -0
- mediapipe/calculators/audio/time_series_framer_calculator_pb2.py +33 -0
- mediapipe/calculators/core/__init__.py +0 -0
- mediapipe/calculators/core/bypass_calculator_pb2.py +31 -0
- mediapipe/calculators/core/clip_vector_size_calculator_pb2.py +31 -0
- mediapipe/calculators/core/concatenate_vector_calculator_pb2.py +31 -0
- mediapipe/calculators/core/constant_side_packet_calculator_pb2.py +39 -0
- mediapipe/calculators/core/dequantize_byte_array_calculator_pb2.py +31 -0
- mediapipe/calculators/core/flow_limiter_calculator_pb2.py +32 -0
- mediapipe/calculators/core/gate_calculator_pb2.py +33 -0
- mediapipe/calculators/core/get_vector_item_calculator_pb2.py +31 -0
- mediapipe/calculators/core/graph_profile_calculator_pb2.py +31 -0
- mediapipe/calculators/core/packet_cloner_calculator_pb2.py +31 -0
- mediapipe/calculators/core/packet_resampler_calculator_pb2.py +33 -0
- mediapipe/calculators/core/packet_thinner_calculator_pb2.py +33 -0
- mediapipe/calculators/core/quantize_float_vector_calculator_pb2.py +31 -0
- mediapipe/calculators/core/sequence_shift_calculator_pb2.py +31 -0
- mediapipe/calculators/core/split_vector_calculator_pb2.py +33 -0
- mediapipe/calculators/image/__init__.py +0 -0
- mediapipe/calculators/image/bilateral_filter_calculator_pb2.py +31 -0
- mediapipe/calculators/image/feature_detector_calculator_pb2.py +31 -0
- mediapipe/calculators/image/image_clone_calculator_pb2.py +31 -0
- mediapipe/calculators/image/image_cropping_calculator_pb2.py +33 -0
- mediapipe/calculators/image/image_transformation_calculator_pb2.py +38 -0
- mediapipe/calculators/image/mask_overlay_calculator_pb2.py +33 -0
- mediapipe/calculators/image/opencv_encoded_image_to_image_frame_calculator_pb2.py +31 -0
- mediapipe/calculators/image/opencv_image_encoder_calculator_pb2.py +35 -0
- mediapipe/calculators/image/recolor_calculator_pb2.py +34 -0
- mediapipe/calculators/image/rotation_mode_pb2.py +29 -0
- mediapipe/calculators/image/scale_image_calculator_pb2.py +34 -0
- mediapipe/calculators/image/segmentation_smoothing_calculator_pb2.py +31 -0
- mediapipe/calculators/image/set_alpha_calculator_pb2.py +31 -0
- mediapipe/calculators/image/warp_affine_calculator_pb2.py +36 -0
- mediapipe/calculators/internal/__init__.py +0 -0
- mediapipe/calculators/internal/callback_packet_calculator_pb2.py +33 -0
- mediapipe/calculators/tensor/__init__.py +0 -0
- mediapipe/calculators/tensor/audio_to_tensor_calculator_pb2.py +35 -0
- mediapipe/calculators/tensor/bert_preprocessor_calculator_pb2.py +31 -0
- mediapipe/calculators/tensor/feedback_tensors_calculator_pb2.py +37 -0
- mediapipe/calculators/tensor/image_to_tensor_calculator_pb2.py +40 -0
- mediapipe/calculators/tensor/inference_calculator_pb2.py +63 -0
- mediapipe/calculators/tensor/landmarks_to_tensor_calculator_pb2.py +33 -0
- mediapipe/calculators/tensor/regex_preprocessor_calculator_pb2.py +31 -0
- mediapipe/calculators/tensor/tensor_converter_calculator_pb2.py +34 -0
- mediapipe/calculators/tensor/tensor_to_joints_calculator_pb2.py +31 -0
- mediapipe/calculators/tensor/tensors_readback_calculator_pb2.py +35 -0
- mediapipe/calculators/tensor/tensors_to_audio_calculator_pb2.py +33 -0
- mediapipe/calculators/tensor/tensors_to_classification_calculator_pb2.py +44 -0
- mediapipe/calculators/tensor/tensors_to_detections_calculator_pb2.py +39 -0
- mediapipe/calculators/tensor/tensors_to_floats_calculator_pb2.py +33 -0
- mediapipe/calculators/tensor/tensors_to_landmarks_calculator_pb2.py +33 -0
- mediapipe/calculators/tensor/tensors_to_segmentation_calculator_pb2.py +34 -0
- mediapipe/calculators/tensor/vector_to_tensor_calculator_pb2.py +27 -0
- mediapipe/calculators/tflite/__init__.py +0 -0
- mediapipe/calculators/tflite/ssd_anchors_calculator_pb2.py +32 -0
- mediapipe/calculators/tflite/tflite_converter_calculator_pb2.py +33 -0
- mediapipe/calculators/tflite/tflite_custom_op_resolver_calculator_pb2.py +31 -0
- mediapipe/calculators/tflite/tflite_inference_calculator_pb2.py +49 -0
- mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator_pb2.py +31 -0
- mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator_pb2.py +31 -0
- mediapipe/calculators/tflite/tflite_tensors_to_landmarks_calculator_pb2.py +33 -0
- mediapipe/calculators/tflite/tflite_tensors_to_segmentation_calculator_pb2.py +31 -0
- mediapipe/calculators/util/__init__.py +0 -0
- mediapipe/calculators/util/align_hand_to_pose_in_world_calculator_pb2.py +31 -0
- mediapipe/calculators/util/annotation_overlay_calculator_pb2.py +32 -0
- mediapipe/calculators/util/association_calculator_pb2.py +31 -0
- mediapipe/calculators/util/collection_has_min_size_calculator_pb2.py +31 -0
- mediapipe/calculators/util/combine_joints_calculator_pb2.py +36 -0
- mediapipe/calculators/util/detection_label_id_to_text_calculator_pb2.py +36 -0
- mediapipe/calculators/util/detections_to_rects_calculator_pb2.py +33 -0
- mediapipe/calculators/util/detections_to_render_data_calculator_pb2.py +33 -0
- mediapipe/calculators/util/face_to_rect_calculator_pb2.py +26 -0
- mediapipe/calculators/util/filter_detections_calculator_pb2.py +31 -0
- mediapipe/calculators/util/flat_color_image_calculator_pb2.py +32 -0
- mediapipe/calculators/util/labels_to_render_data_calculator_pb2.py +34 -0
- mediapipe/calculators/util/landmark_projection_calculator_pb2.py +31 -0
- mediapipe/calculators/util/landmarks_refinement_calculator_pb2.py +41 -0
- mediapipe/calculators/util/landmarks_smoothing_calculator_pb2.py +33 -0
- mediapipe/calculators/util/landmarks_to_detection_calculator_pb2.py +31 -0
- mediapipe/calculators/util/landmarks_to_floats_calculator_pb2.py +31 -0
- mediapipe/calculators/util/landmarks_to_render_data_calculator_pb2.py +32 -0
- mediapipe/calculators/util/landmarks_transformation_calculator_pb2.py +37 -0
- mediapipe/calculators/util/latency_pb2.py +26 -0
- mediapipe/calculators/util/local_file_contents_calculator_pb2.py +31 -0
- mediapipe/calculators/util/logic_calculator_pb2.py +34 -0
- mediapipe/calculators/util/non_max_suppression_calculator_pb2.py +35 -0
- mediapipe/calculators/util/packet_frequency_calculator_pb2.py +31 -0
- mediapipe/calculators/util/packet_frequency_pb2.py +26 -0
- mediapipe/calculators/util/packet_latency_calculator_pb2.py +31 -0
- mediapipe/calculators/util/rect_to_render_data_calculator_pb2.py +32 -0
- mediapipe/calculators/util/rect_to_render_scale_calculator_pb2.py +31 -0
- mediapipe/calculators/util/rect_transformation_calculator_pb2.py +31 -0
- mediapipe/calculators/util/refine_landmarks_from_heatmap_calculator_pb2.py +31 -0
- mediapipe/calculators/util/resource_provider_calculator_pb2.py +28 -0
- mediapipe/calculators/util/set_joints_visibility_calculator_pb2.py +41 -0
- mediapipe/calculators/util/thresholding_calculator_pb2.py +31 -0
- mediapipe/calculators/util/timed_box_list_id_to_label_calculator_pb2.py +31 -0
- mediapipe/calculators/util/timed_box_list_to_render_data_calculator_pb2.py +32 -0
- mediapipe/calculators/util/top_k_scores_calculator_pb2.py +31 -0
- mediapipe/calculators/util/visibility_copy_calculator_pb2.py +27 -0
- mediapipe/calculators/util/visibility_smoothing_calculator_pb2.py +31 -0
- mediapipe/calculators/video/__init__.py +0 -0
- mediapipe/calculators/video/box_detector_calculator_pb2.py +32 -0
- mediapipe/calculators/video/box_tracker_calculator_pb2.py +32 -0
- mediapipe/calculators/video/flow_packager_calculator_pb2.py +32 -0
- mediapipe/calculators/video/flow_to_image_calculator_pb2.py +31 -0
- mediapipe/calculators/video/motion_analysis_calculator_pb2.py +42 -0
- mediapipe/calculators/video/opencv_video_encoder_calculator_pb2.py +31 -0
- mediapipe/calculators/video/tool/__init__.py +0 -0
- mediapipe/calculators/video/tool/flow_quantizer_model_pb2.py +26 -0
- mediapipe/calculators/video/tracked_detection_manager_calculator_pb2.py +32 -0
- mediapipe/calculators/video/video_pre_stream_calculator_pb2.py +35 -0
- mediapipe/examples/__init__.py +14 -0
- mediapipe/examples/desktop/__init__.py +14 -0
- mediapipe/framework/__init__.py +0 -0
- mediapipe/framework/calculator_options_pb2.py +29 -0
- mediapipe/framework/calculator_pb2.py +59 -0
- mediapipe/framework/calculator_profile_pb2.py +48 -0
- mediapipe/framework/deps/__init__.py +0 -0
- mediapipe/framework/deps/proto_descriptor_pb2.py +29 -0
- mediapipe/framework/formats/__init__.py +0 -0
- mediapipe/framework/formats/affine_transform_data_pb2.py +28 -0
- mediapipe/framework/formats/annotation/__init__.py +0 -0
- mediapipe/framework/formats/annotation/locus_pb2.py +32 -0
- mediapipe/framework/formats/annotation/rasterization_pb2.py +29 -0
- mediapipe/framework/formats/body_rig_pb2.py +28 -0
- mediapipe/framework/formats/classification_pb2.py +31 -0
- mediapipe/framework/formats/detection_pb2.py +36 -0
- mediapipe/framework/formats/image_file_properties_pb2.py +26 -0
- mediapipe/framework/formats/image_format_pb2.py +29 -0
- mediapipe/framework/formats/landmark_pb2.py +37 -0
- mediapipe/framework/formats/location_data_pb2.py +38 -0
- mediapipe/framework/formats/matrix_data_pb2.py +31 -0
- mediapipe/framework/formats/motion/__init__.py +0 -0
- mediapipe/framework/formats/motion/optical_flow_field_data_pb2.py +30 -0
- mediapipe/framework/formats/object_detection/__init__.py +0 -0
- mediapipe/framework/formats/object_detection/anchor_pb2.py +26 -0
- mediapipe/framework/formats/rect_pb2.py +29 -0
- mediapipe/framework/formats/time_series_header_pb2.py +28 -0
- mediapipe/framework/graph_runtime_info_pb2.py +31 -0
- mediapipe/framework/mediapipe_options_pb2.py +27 -0
- mediapipe/framework/packet_factory_pb2.py +31 -0
- mediapipe/framework/packet_generator_pb2.py +33 -0
- mediapipe/framework/status_handler_pb2.py +28 -0
- mediapipe/framework/stream_handler/__init__.py +0 -0
- mediapipe/framework/stream_handler/default_input_stream_handler_pb2.py +27 -0
- mediapipe/framework/stream_handler/fixed_size_input_stream_handler_pb2.py +27 -0
- mediapipe/framework/stream_handler/sync_set_input_stream_handler_pb2.py +29 -0
- mediapipe/framework/stream_handler/timestamp_align_input_stream_handler_pb2.py +27 -0
- mediapipe/framework/stream_handler_pb2.py +30 -0
- mediapipe/framework/test_calculators_pb2.py +31 -0
- mediapipe/framework/thread_pool_executor_pb2.py +29 -0
- mediapipe/framework/tool/__init__.py +0 -0
- mediapipe/framework/tool/calculator_graph_template_pb2.py +44 -0
- mediapipe/framework/tool/field_data_pb2.py +28 -0
- mediapipe/framework/tool/node_chain_subgraph_pb2.py +31 -0
- mediapipe/framework/tool/packet_generator_wrapper_calculator_pb2.py +28 -0
- mediapipe/framework/tool/source_pb2.py +33 -0
- mediapipe/framework/tool/switch_container_pb2.py +32 -0
- mediapipe/gpu/__init__.py +0 -0
- mediapipe/gpu/copy_calculator_pb2.py +33 -0
- mediapipe/gpu/gl_animation_overlay_calculator_pb2.py +31 -0
- mediapipe/gpu/gl_context_options_pb2.py +31 -0
- mediapipe/gpu/gl_scaler_calculator_pb2.py +32 -0
- mediapipe/gpu/gl_surface_sink_calculator_pb2.py +32 -0
- mediapipe/gpu/gpu_origin_pb2.py +29 -0
- mediapipe/gpu/scale_mode_pb2.py +28 -0
- mediapipe/model_maker/__init__.py +27 -0
- mediapipe/model_maker/setup.py +107 -0
- mediapipe/modules/__init__.py +0 -0
- mediapipe/modules/face_detection/__init__.py +0 -0
- mediapipe/modules/face_detection/face_detection_full_range_cpu.binarypb +0 -0
- mediapipe/modules/face_detection/face_detection_full_range_sparse.tflite +0 -0
- mediapipe/modules/face_detection/face_detection_pb2.py +30 -0
- mediapipe/modules/face_detection/face_detection_short_range.tflite +0 -0
- mediapipe/modules/face_detection/face_detection_short_range_cpu.binarypb +0 -0
- mediapipe/modules/face_geometry/__init__.py +0 -0
- mediapipe/modules/face_geometry/data/__init__.py +0 -0
- mediapipe/modules/face_geometry/effect_renderer_calculator_pb2.py +27 -0
- mediapipe/modules/face_geometry/env_generator_calculator_pb2.py +28 -0
- mediapipe/modules/face_geometry/geometry_pipeline_calculator_pb2.py +27 -0
- mediapipe/modules/face_geometry/libs/__init__.py +0 -0
- mediapipe/modules/face_geometry/protos/__init__.py +0 -0
- mediapipe/modules/face_geometry/protos/environment_pb2.py +31 -0
- mediapipe/modules/face_geometry/protos/face_geometry_pb2.py +29 -0
- mediapipe/modules/face_geometry/protos/geometry_pipeline_metadata_pb2.py +32 -0
- mediapipe/modules/face_geometry/protos/mesh_3d_pb2.py +31 -0
- mediapipe/modules/face_landmark/__init__.py +0 -0
- mediapipe/modules/face_landmark/face_landmark.tflite +0 -0
- mediapipe/modules/face_landmark/face_landmark_front_cpu.binarypb +0 -0
- mediapipe/modules/face_landmark/face_landmark_with_attention.tflite +0 -0
- mediapipe/modules/hand_landmark/__init__.py +0 -0
- mediapipe/modules/hand_landmark/calculators/__init__.py +0 -0
- mediapipe/modules/hand_landmark/hand_landmark_full.tflite +0 -0
- mediapipe/modules/hand_landmark/hand_landmark_lite.tflite +0 -0
- mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb +0 -0
- mediapipe/modules/hand_landmark/handedness.txt +2 -0
- mediapipe/modules/holistic_landmark/__init__.py +0 -0
- mediapipe/modules/holistic_landmark/calculators/__init__.py +0 -0
- mediapipe/modules/holistic_landmark/calculators/roi_tracking_calculator_pb2.py +37 -0
- mediapipe/modules/holistic_landmark/hand_recrop.tflite +0 -0
- mediapipe/modules/holistic_landmark/holistic_landmark_cpu.binarypb +0 -0
- mediapipe/modules/iris_landmark/__init__.py +0 -0
- mediapipe/modules/iris_landmark/iris_landmark.tflite +0 -0
- mediapipe/modules/objectron/__init__.py +0 -0
- mediapipe/modules/objectron/calculators/__init__.py +0 -0
- mediapipe/modules/objectron/calculators/a_r_capture_metadata_pb2.py +102 -0
- mediapipe/modules/objectron/calculators/annotation_data_pb2.py +38 -0
- mediapipe/modules/objectron/calculators/belief_decoder_config_pb2.py +28 -0
- mediapipe/modules/objectron/calculators/camera_parameters_pb2.py +30 -0
- mediapipe/modules/objectron/calculators/filter_detection_calculator_pb2.py +35 -0
- mediapipe/modules/objectron/calculators/frame_annotation_to_rect_calculator_pb2.py +31 -0
- mediapipe/modules/objectron/calculators/frame_annotation_tracker_calculator_pb2.py +31 -0
- mediapipe/modules/objectron/calculators/lift_2d_frame_annotation_to_3d_calculator_pb2.py +32 -0
- mediapipe/modules/objectron/calculators/object_pb2.py +38 -0
- mediapipe/modules/objectron/calculators/tensors_to_objects_calculator_pb2.py +32 -0
- mediapipe/modules/objectron/calculators/tflite_tensors_to_objects_calculator_pb2.py +32 -0
- mediapipe/modules/objectron/object_detection_oidv4_labelmap.txt +24 -0
- mediapipe/modules/objectron/objectron_cpu.binarypb +0 -0
- mediapipe/modules/palm_detection/__init__.py +0 -0
- mediapipe/modules/palm_detection/palm_detection_full.tflite +0 -0
- mediapipe/modules/palm_detection/palm_detection_lite.tflite +0 -0
- mediapipe/modules/pose_detection/__init__.py +0 -0
- mediapipe/modules/pose_detection/pose_detection.tflite +0 -0
- mediapipe/modules/pose_landmark/__init__.py +0 -0
- mediapipe/modules/pose_landmark/pose_landmark_cpu.binarypb +0 -0
- mediapipe/modules/pose_landmark/pose_landmark_full.tflite +0 -0
- mediapipe/modules/selfie_segmentation/__init__.py +0 -0
- mediapipe/modules/selfie_segmentation/selfie_segmentation.tflite +0 -0
- mediapipe/modules/selfie_segmentation/selfie_segmentation_cpu.binarypb +0 -0
- mediapipe/modules/selfie_segmentation/selfie_segmentation_landscape.tflite +0 -0
- mediapipe/python/__init__.py +29 -0
- mediapipe/python/_framework_bindings.cpython-311-x86_64-linux-gnu.so +0 -0
- mediapipe/python/calculator_graph_test.py +251 -0
- mediapipe/python/image_frame_test.py +194 -0
- mediapipe/python/image_test.py +218 -0
- mediapipe/python/packet_creator.py +275 -0
- mediapipe/python/packet_getter.py +120 -0
- mediapipe/python/packet_test.py +533 -0
- mediapipe/python/solution_base.py +604 -0
- mediapipe/python/solution_base_test.py +396 -0
- mediapipe/python/solutions/__init__.py +27 -0
- mediapipe/python/solutions/download_utils.py +37 -0
- mediapipe/python/solutions/drawing_styles.py +249 -0
- mediapipe/python/solutions/drawing_utils.py +320 -0
- mediapipe/python/solutions/drawing_utils_test.py +258 -0
- mediapipe/python/solutions/face_detection.py +105 -0
- mediapipe/python/solutions/face_detection_test.py +92 -0
- mediapipe/python/solutions/face_mesh.py +125 -0
- mediapipe/python/solutions/face_mesh_connections.py +500 -0
- mediapipe/python/solutions/face_mesh_test.py +170 -0
- mediapipe/python/solutions/hands.py +153 -0
- mediapipe/python/solutions/hands_connections.py +32 -0
- mediapipe/python/solutions/hands_test.py +219 -0
- mediapipe/python/solutions/holistic.py +167 -0
- mediapipe/python/solutions/holistic_test.py +142 -0
- mediapipe/python/solutions/objectron.py +288 -0
- mediapipe/python/solutions/objectron_test.py +81 -0
- mediapipe/python/solutions/pose.py +192 -0
- mediapipe/python/solutions/pose_connections.py +22 -0
- mediapipe/python/solutions/pose_test.py +262 -0
- mediapipe/python/solutions/selfie_segmentation.py +76 -0
- mediapipe/python/solutions/selfie_segmentation_test.py +68 -0
- mediapipe/python/timestamp_test.py +78 -0
- mediapipe/tasks/__init__.py +14 -0
- mediapipe/tasks/cc/__init__.py +0 -0
- mediapipe/tasks/cc/audio/__init__.py +0 -0
- mediapipe/tasks/cc/audio/audio_classifier/__init__.py +0 -0
- mediapipe/tasks/cc/audio/audio_classifier/proto/__init__.py +0 -0
- mediapipe/tasks/cc/audio/audio_classifier/proto/audio_classifier_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/audio/audio_embedder/__init__.py +0 -0
- mediapipe/tasks/cc/audio/audio_embedder/proto/__init__.py +0 -0
- mediapipe/tasks/cc/audio/audio_embedder/proto/audio_embedder_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/audio/core/__init__.py +0 -0
- mediapipe/tasks/cc/audio/utils/__init__.py +0 -0
- mediapipe/tasks/cc/components/__init__.py +0 -0
- mediapipe/tasks/cc/components/calculators/__init__.py +0 -0
- mediapipe/tasks/cc/components/calculators/classification_aggregation_calculator_pb2.py +31 -0
- mediapipe/tasks/cc/components/calculators/score_calibration_calculator_pb2.py +35 -0
- mediapipe/tasks/cc/components/calculators/tensors_to_embeddings_calculator_pb2.py +32 -0
- mediapipe/tasks/cc/components/containers/__init__.py +0 -0
- mediapipe/tasks/cc/components/containers/proto/__init__.py +0 -0
- mediapipe/tasks/cc/components/containers/proto/classifications_pb2.py +30 -0
- mediapipe/tasks/cc/components/containers/proto/embeddings_pb2.py +35 -0
- mediapipe/tasks/cc/components/containers/proto/landmarks_detection_result_pb2.py +32 -0
- mediapipe/tasks/cc/components/processors/__init__.py +0 -0
- mediapipe/tasks/cc/components/processors/proto/__init__.py +0 -0
- mediapipe/tasks/cc/components/processors/proto/classification_postprocessing_graph_options_pb2.py +38 -0
- mediapipe/tasks/cc/components/processors/proto/classifier_options_pb2.py +27 -0
- mediapipe/tasks/cc/components/processors/proto/detection_postprocessing_graph_options_pb2.py +36 -0
- mediapipe/tasks/cc/components/processors/proto/detector_options_pb2.py +27 -0
- mediapipe/tasks/cc/components/processors/proto/embedder_options_pb2.py +27 -0
- mediapipe/tasks/cc/components/processors/proto/embedding_postprocessing_graph_options_pb2.py +32 -0
- mediapipe/tasks/cc/components/processors/proto/image_preprocessing_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/components/processors/proto/text_model_type_pb2.py +28 -0
- mediapipe/tasks/cc/components/processors/proto/text_preprocessing_graph_options_pb2.py +32 -0
- mediapipe/tasks/cc/components/utils/__init__.py +0 -0
- mediapipe/tasks/cc/core/__init__.py +0 -0
- mediapipe/tasks/cc/core/proto/__init__.py +0 -0
- mediapipe/tasks/cc/core/proto/acceleration_pb2.py +28 -0
- mediapipe/tasks/cc/core/proto/base_options_pb2.py +30 -0
- mediapipe/tasks/cc/core/proto/external_file_pb2.py +31 -0
- mediapipe/tasks/cc/core/proto/inference_subgraph_pb2.py +32 -0
- mediapipe/tasks/cc/core/proto/model_resources_calculator_pb2.py +32 -0
- mediapipe/tasks/cc/genai/__init__.py +0 -0
- mediapipe/tasks/cc/genai/inference/__init__.py +0 -0
- mediapipe/tasks/cc/genai/inference/c/__init__.py +0 -0
- mediapipe/tasks/cc/genai/inference/calculators/__init__.py +0 -0
- mediapipe/tasks/cc/genai/inference/calculators/detokenizer_calculator_pb2.py +27 -0
- mediapipe/tasks/cc/genai/inference/calculators/llm_gpu_calculator_pb2.py +32 -0
- mediapipe/tasks/cc/genai/inference/calculators/model_data_calculator_pb2.py +27 -0
- mediapipe/tasks/cc/genai/inference/calculators/tokenizer_calculator_pb2.py +29 -0
- mediapipe/tasks/cc/genai/inference/common/__init__.py +0 -0
- mediapipe/tasks/cc/genai/inference/proto/__init__.py +0 -0
- mediapipe/tasks/cc/genai/inference/proto/llm_file_metadata_pb2.py +32 -0
- mediapipe/tasks/cc/genai/inference/proto/llm_params_pb2.py +33 -0
- mediapipe/tasks/cc/genai/inference/proto/prompt_template_pb2.py +27 -0
- mediapipe/tasks/cc/genai/inference/proto/sampler_params_pb2.py +29 -0
- mediapipe/tasks/cc/genai/inference/proto/transformer_params_pb2.py +45 -0
- mediapipe/tasks/cc/genai/inference/utils/__init__.py +0 -0
- mediapipe/tasks/cc/genai/inference/utils/llm_utils/__init__.py +0 -0
- mediapipe/tasks/cc/genai/inference/utils/xnn_utils/__init__.py +0 -0
- mediapipe/tasks/cc/metadata/__init__.py +0 -0
- mediapipe/tasks/cc/metadata/python/__init__.py +0 -0
- mediapipe/tasks/cc/metadata/python/_pywrap_metadata_version.cpython-311-x86_64-linux-gnu.so +0 -0
- mediapipe/tasks/cc/metadata/tests/__init__.py +0 -0
- mediapipe/tasks/cc/metadata/utils/__init__.py +0 -0
- mediapipe/tasks/cc/text/__init__.py +0 -0
- mediapipe/tasks/cc/text/custom_ops/__init__.py +0 -0
- mediapipe/tasks/cc/text/custom_ops/ragged/__init__.py +0 -0
- mediapipe/tasks/cc/text/custom_ops/sentencepiece/__init__.py +0 -0
- mediapipe/tasks/cc/text/custom_ops/sentencepiece/testdata/__init__.py +0 -0
- mediapipe/tasks/cc/text/language_detector/__init__.py +0 -0
- mediapipe/tasks/cc/text/language_detector/custom_ops/__init__.py +0 -0
- mediapipe/tasks/cc/text/language_detector/custom_ops/utils/__init__.py +0 -0
- mediapipe/tasks/cc/text/language_detector/custom_ops/utils/hash/__init__.py +0 -0
- mediapipe/tasks/cc/text/language_detector/custom_ops/utils/utf/__init__.py +0 -0
- mediapipe/tasks/cc/text/text_classifier/__init__.py +0 -0
- mediapipe/tasks/cc/text/text_classifier/proto/__init__.py +0 -0
- mediapipe/tasks/cc/text/text_classifier/proto/text_classifier_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/text/text_embedder/__init__.py +0 -0
- mediapipe/tasks/cc/text/text_embedder/proto/__init__.py +0 -0
- mediapipe/tasks/cc/text/text_embedder/proto/text_embedder_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/text/tokenizers/__init__.py +0 -0
- mediapipe/tasks/cc/text/utils/__init__.py +0 -0
- mediapipe/tasks/cc/vision/__init__.py +0 -0
- mediapipe/tasks/cc/vision/core/__init__.py +0 -0
- mediapipe/tasks/cc/vision/custom_ops/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_detector/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_detector/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_detector/proto/face_detector_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/face_geometry/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_geometry/calculators/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_geometry/calculators/env_generator_calculator_pb2.py +28 -0
- mediapipe/tasks/cc/vision/face_geometry/calculators/geometry_pipeline_calculator_pb2.py +29 -0
- mediapipe/tasks/cc/vision/face_geometry/data/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_geometry/libs/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_geometry/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_geometry/proto/environment_pb2.py +31 -0
- mediapipe/tasks/cc/vision/face_geometry/proto/face_geometry_graph_options_pb2.py +29 -0
- mediapipe/tasks/cc/vision/face_geometry/proto/face_geometry_pb2.py +29 -0
- mediapipe/tasks/cc/vision/face_geometry/proto/geometry_pipeline_metadata_pb2.py +32 -0
- mediapipe/tasks/cc/vision/face_geometry/proto/mesh_3d_pb2.py +31 -0
- mediapipe/tasks/cc/vision/face_landmarker/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_landmarker/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_landmarker/proto/face_blendshapes_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/face_landmarker/proto/face_landmarker_graph_options_pb2.py +37 -0
- mediapipe/tasks/cc/vision/face_landmarker/proto/face_landmarks_detector_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/vision/face_landmarker/proto/tensors_to_face_landmarks_graph_options_pb2.py +32 -0
- mediapipe/tasks/cc/vision/face_stylizer/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_stylizer/calculators/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_stylizer/calculators/tensors_to_image_calculator_pb2.py +36 -0
- mediapipe/tasks/cc/vision/face_stylizer/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/face_stylizer/proto/face_stylizer_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/__init__.py +0 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/calculators/__init__.py +0 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/calculators/combined_prediction_calculator_pb2.py +33 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/calculators/landmarks_to_matrix_calculator_pb2.py +31 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/proto/gesture_classifier_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/proto/gesture_embedder_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/proto/gesture_recognizer_graph_options_pb2.py +36 -0
- mediapipe/tasks/cc/vision/gesture_recognizer/proto/hand_gesture_recognizer_graph_options_pb2.py +36 -0
- mediapipe/tasks/cc/vision/hand_detector/__init__.py +0 -0
- mediapipe/tasks/cc/vision/hand_detector/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/hand_detector/proto/hand_detector_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/hand_detector/proto/hand_detector_result_pb2.py +30 -0
- mediapipe/tasks/cc/vision/hand_landmarker/__init__.py +0 -0
- mediapipe/tasks/cc/vision/hand_landmarker/calculators/__init__.py +0 -0
- mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_association_calculator_pb2.py +31 -0
- mediapipe/tasks/cc/vision/hand_landmarker/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_graph_options_pb2.py +36 -0
- mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarks_detector_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_roi_refinement_graph_options_pb2.py +28 -0
- mediapipe/tasks/cc/vision/holistic_landmarker/__init__.py +0 -0
- mediapipe/tasks/cc/vision/holistic_landmarker/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/holistic_landmarker/proto/holistic_landmarker_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/holistic_landmarker/proto/holistic_result_pb2.py +29 -0
- mediapipe/tasks/cc/vision/image_classifier/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_classifier/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_classifier/proto/image_classifier_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/vision/image_embedder/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_embedder/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_embedder/proto/image_embedder_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/vision/image_generator/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_generator/diffuser/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iterate_calculator_pb2.py +40 -0
- mediapipe/tasks/cc/vision/image_generator/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_generator/proto/conditioned_image_graph_options_pb2.py +40 -0
- mediapipe/tasks/cc/vision/image_generator/proto/control_plugin_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/image_generator/proto/image_generator_graph_options_pb2.py +30 -0
- mediapipe/tasks/cc/vision/image_segmenter/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_segmenter/calculators/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_segmenter/calculators/tensors_to_segmentation_calculator_pb2.py +34 -0
- mediapipe/tasks/cc/vision/image_segmenter/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/image_segmenter/proto/image_segmenter_graph_options_pb2.py +35 -0
- mediapipe/tasks/cc/vision/image_segmenter/proto/segmenter_options_pb2.py +33 -0
- mediapipe/tasks/cc/vision/interactive_segmenter/__init__.py +0 -0
- mediapipe/tasks/cc/vision/object_detector/__init__.py +0 -0
- mediapipe/tasks/cc/vision/object_detector/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/object_detector/proto/object_detector_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/pose_detector/__init__.py +0 -0
- mediapipe/tasks/cc/vision/pose_detector/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/pose_detector/proto/pose_detector_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/pose_landmarker/__init__.py +0 -0
- mediapipe/tasks/cc/vision/pose_landmarker/proto/__init__.py +0 -0
- mediapipe/tasks/cc/vision/pose_landmarker/proto/pose_landmarker_graph_options_pb2.py +36 -0
- mediapipe/tasks/cc/vision/pose_landmarker/proto/pose_landmarks_detector_graph_options_pb2.py +34 -0
- mediapipe/tasks/cc/vision/utils/__init__.py +0 -0
- mediapipe/tasks/cc/vision/utils/ghum/__init__.py +0 -0
- mediapipe/tasks/metadata/image_segmenter_metadata_schema.fbs +59 -0
- mediapipe/tasks/metadata/image_segmenter_metadata_schema_py_generated.py +108 -0
- mediapipe/tasks/metadata/metadata_schema.fbs +732 -0
- mediapipe/tasks/metadata/metadata_schema_py_generated.py +3251 -0
- mediapipe/tasks/metadata/object_detector_metadata_schema.fbs +98 -0
- mediapipe/tasks/metadata/object_detector_metadata_schema_py_generated.py +674 -0
- mediapipe/tasks/metadata/schema_py_generated.py +18438 -0
- mediapipe/tasks/python/__init__.py +27 -0
- mediapipe/tasks/python/audio/__init__.py +33 -0
- mediapipe/tasks/python/audio/audio_classifier.py +324 -0
- mediapipe/tasks/python/audio/audio_embedder.py +285 -0
- mediapipe/tasks/python/audio/core/__init__.py +16 -0
- mediapipe/tasks/python/audio/core/audio_record.py +125 -0
- mediapipe/tasks/python/audio/core/audio_task_running_mode.py +29 -0
- mediapipe/tasks/python/audio/core/base_audio_task_api.py +181 -0
- mediapipe/tasks/python/benchmark/__init__.py +13 -0
- mediapipe/tasks/python/benchmark/benchmark_utils.py +70 -0
- mediapipe/tasks/python/benchmark/vision/__init__.py +13 -0
- mediapipe/tasks/python/benchmark/vision/benchmark.py +99 -0
- mediapipe/tasks/python/benchmark/vision/core/__init__.py +14 -0
- mediapipe/tasks/python/benchmark/vision/core/base_vision_benchmark_api.py +40 -0
- mediapipe/tasks/python/components/__init__.py +13 -0
- mediapipe/tasks/python/components/containers/__init__.py +53 -0
- mediapipe/tasks/python/components/containers/audio_data.py +137 -0
- mediapipe/tasks/python/components/containers/bounding_box.py +73 -0
- mediapipe/tasks/python/components/containers/category.py +78 -0
- mediapipe/tasks/python/components/containers/classification_result.py +111 -0
- mediapipe/tasks/python/components/containers/detections.py +181 -0
- mediapipe/tasks/python/components/containers/embedding_result.py +89 -0
- mediapipe/tasks/python/components/containers/keypoint.py +77 -0
- mediapipe/tasks/python/components/containers/landmark.py +122 -0
- mediapipe/tasks/python/components/containers/landmark_detection_result.py +106 -0
- mediapipe/tasks/python/components/containers/rect.py +109 -0
- mediapipe/tasks/python/components/processors/__init__.py +23 -0
- mediapipe/tasks/python/components/processors/classifier_options.py +86 -0
- mediapipe/tasks/python/components/utils/__init__.py +13 -0
- mediapipe/tasks/python/components/utils/cosine_similarity.py +68 -0
- mediapipe/tasks/python/core/__init__.py +13 -0
- mediapipe/tasks/python/core/base_options.py +121 -0
- mediapipe/tasks/python/core/optional_dependencies.py +25 -0
- mediapipe/tasks/python/core/task_info.py +139 -0
- mediapipe/tasks/python/genai/__init__.py +14 -0
- mediapipe/tasks/python/genai/bundler/__init__.py +23 -0
- mediapipe/tasks/python/genai/bundler/llm_bundler.py +130 -0
- mediapipe/tasks/python/genai/bundler/llm_bundler_test.py +168 -0
- mediapipe/tasks/python/genai/converter/__init__.py +24 -0
- mediapipe/tasks/python/genai/converter/converter_base.py +179 -0
- mediapipe/tasks/python/genai/converter/converter_factory.py +79 -0
- mediapipe/tasks/python/genai/converter/llm_converter.py +374 -0
- mediapipe/tasks/python/genai/converter/llm_converter_test.py +63 -0
- mediapipe/tasks/python/genai/converter/pytorch_converter.py +318 -0
- mediapipe/tasks/python/genai/converter/pytorch_converter_test.py +86 -0
- mediapipe/tasks/python/genai/converter/quantization_util.py +516 -0
- mediapipe/tasks/python/genai/converter/quantization_util_test.py +259 -0
- mediapipe/tasks/python/genai/converter/safetensors_converter.py +580 -0
- mediapipe/tasks/python/genai/converter/safetensors_converter_test.py +83 -0
- mediapipe/tasks/python/genai/converter/weight_bins_writer.py +120 -0
- mediapipe/tasks/python/genai/converter/weight_bins_writer_test.py +95 -0
- mediapipe/tasks/python/metadata/__init__.py +13 -0
- mediapipe/tasks/python/metadata/flatbuffers_lib/_pywrap_flatbuffers.cpython-311-x86_64-linux-gnu.so +0 -0
- mediapipe/tasks/python/metadata/metadata.py +928 -0
- mediapipe/tasks/python/metadata/metadata_displayer_cli.py +34 -0
- mediapipe/tasks/python/metadata/metadata_writers/__init__.py +13 -0
- mediapipe/tasks/python/metadata/metadata_writers/face_stylizer.py +138 -0
- mediapipe/tasks/python/metadata/metadata_writers/image_classifier.py +71 -0
- mediapipe/tasks/python/metadata/metadata_writers/image_segmenter.py +170 -0
- mediapipe/tasks/python/metadata/metadata_writers/metadata_info.py +1166 -0
- mediapipe/tasks/python/metadata/metadata_writers/metadata_writer.py +845 -0
- mediapipe/tasks/python/metadata/metadata_writers/model_asset_bundle_utils.py +71 -0
- mediapipe/tasks/python/metadata/metadata_writers/object_detector.py +331 -0
- mediapipe/tasks/python/metadata/metadata_writers/text_classifier.py +119 -0
- mediapipe/tasks/python/metadata/metadata_writers/writer_utils.py +91 -0
- mediapipe/tasks/python/test/__init__.py +13 -0
- mediapipe/tasks/python/test/audio/__init__.py +13 -0
- mediapipe/tasks/python/test/audio/audio_classifier_test.py +387 -0
- mediapipe/tasks/python/test/audio/audio_embedder_test.py +297 -0
- mediapipe/tasks/python/test/test_utils.py +196 -0
- mediapipe/tasks/python/test/text/__init__.py +13 -0
- mediapipe/tasks/python/test/text/language_detector_test.py +228 -0
- mediapipe/tasks/python/test/text/text_classifier_test.py +235 -0
- mediapipe/tasks/python/test/text/text_embedder_test.py +326 -0
- mediapipe/tasks/python/test/vision/__init__.py +13 -0
- mediapipe/tasks/python/test/vision/face_aligner_test.py +190 -0
- mediapipe/tasks/python/test/vision/face_detector_test.py +523 -0
- mediapipe/tasks/python/test/vision/face_landmarker_test.py +565 -0
- mediapipe/tasks/python/test/vision/face_stylizer_test.py +191 -0
- mediapipe/tasks/python/test/vision/hand_landmarker_test.py +437 -0
- mediapipe/tasks/python/test/vision/holistic_landmarker_test.py +544 -0
- mediapipe/tasks/python/test/vision/image_classifier_test.py +657 -0
- mediapipe/tasks/python/test/vision/image_embedder_test.py +423 -0
- mediapipe/tasks/python/test/vision/image_segmenter_test.py +512 -0
- mediapipe/tasks/python/test/vision/interactive_segmenter_test.py +341 -0
- mediapipe/tasks/python/test/vision/object_detector_test.py +493 -0
- mediapipe/tasks/python/test/vision/pose_landmarker_test.py +518 -0
- mediapipe/tasks/python/text/__init__.py +35 -0
- mediapipe/tasks/python/text/core/__init__.py +16 -0
- mediapipe/tasks/python/text/core/base_text_task_api.py +54 -0
- mediapipe/tasks/python/text/language_detector.py +220 -0
- mediapipe/tasks/python/text/text_classifier.py +187 -0
- mediapipe/tasks/python/text/text_embedder.py +188 -0
- mediapipe/tasks/python/vision/__init__.py +90 -0
- mediapipe/tasks/python/vision/core/__init__.py +14 -0
- mediapipe/tasks/python/vision/core/base_vision_task_api.py +226 -0
- mediapipe/tasks/python/vision/core/image_processing_options.py +39 -0
- mediapipe/tasks/python/vision/core/vision_task_running_mode.py +31 -0
- mediapipe/tasks/python/vision/face_aligner.py +158 -0
- mediapipe/tasks/python/vision/face_detector.py +332 -0
- mediapipe/tasks/python/vision/face_landmarker.py +3244 -0
- mediapipe/tasks/python/vision/face_stylizer.py +158 -0
- mediapipe/tasks/python/vision/gesture_recognizer.py +480 -0
- mediapipe/tasks/python/vision/hand_landmarker.py +504 -0
- mediapipe/tasks/python/vision/holistic_landmarker.py +576 -0
- mediapipe/tasks/python/vision/image_classifier.py +358 -0
- mediapipe/tasks/python/vision/image_embedder.py +362 -0
- mediapipe/tasks/python/vision/image_segmenter.py +433 -0
- mediapipe/tasks/python/vision/interactive_segmenter.py +285 -0
- mediapipe/tasks/python/vision/object_detector.py +389 -0
- mediapipe/tasks/python/vision/pose_landmarker.py +455 -0
- mediapipe/util/__init__.py +0 -0
- mediapipe/util/analytics/__init__.py +0 -0
- mediapipe/util/analytics/mediapipe_log_extension_pb2.py +44 -0
- mediapipe/util/analytics/mediapipe_logging_enums_pb2.py +37 -0
- mediapipe/util/audio_decoder_pb2.py +33 -0
- mediapipe/util/color_pb2.py +33 -0
- mediapipe/util/label_map_pb2.py +27 -0
- mediapipe/util/render_data_pb2.py +58 -0
- mediapipe/util/sequence/__init__.py +14 -0
- mediapipe/util/sequence/media_sequence.py +716 -0
- mediapipe/util/sequence/media_sequence_test.py +290 -0
- mediapipe/util/sequence/media_sequence_util.py +800 -0
- mediapipe/util/sequence/media_sequence_util_test.py +389 -0
- mediapipe/util/tracking/__init__.py +0 -0
- mediapipe/util/tracking/box_detector_pb2.py +39 -0
- mediapipe/util/tracking/box_tracker_pb2.py +32 -0
- mediapipe/util/tracking/camera_motion_pb2.py +31 -0
- mediapipe/util/tracking/flow_packager_pb2.py +60 -0
- mediapipe/util/tracking/frame_selection_pb2.py +35 -0
- mediapipe/util/tracking/frame_selection_solution_evaluator_pb2.py +28 -0
- mediapipe/util/tracking/motion_analysis_pb2.py +35 -0
- mediapipe/util/tracking/motion_estimation_pb2.py +66 -0
- mediapipe/util/tracking/motion_models_pb2.py +42 -0
- mediapipe/util/tracking/motion_saliency_pb2.py +26 -0
- mediapipe/util/tracking/push_pull_filtering_pb2.py +26 -0
- mediapipe/util/tracking/region_flow_computation_pb2.py +59 -0
- mediapipe/util/tracking/region_flow_pb2.py +49 -0
- mediapipe/util/tracking/tone_estimation_pb2.py +45 -0
- mediapipe/util/tracking/tone_models_pb2.py +32 -0
- mediapipe/util/tracking/tracked_detection_manager_config_pb2.py +26 -0
- mediapipe/util/tracking/tracking_pb2.py +73 -0
- mediapipe_nightly-0.10.21.post20250114.dist-info/LICENSE +218 -0
- mediapipe_nightly-0.10.21.post20250114.dist-info/METADATA +199 -0
- mediapipe_nightly-0.10.21.post20250114.dist-info/RECORD +593 -0
- mediapipe_nightly-0.10.21.post20250114.dist-info/WHEEL +5 -0
- mediapipe_nightly-0.10.21.post20250114.dist-info/top_level.txt +4 -0
- mediapipe_nightly.libs/libEGL-48f73270.so.1.1.0 +0 -0
- mediapipe_nightly.libs/libGLESv2-ed5eda4f.so.2.1.0 +0 -0
- mediapipe_nightly.libs/libGLdispatch-64b28464.so.0.0.0 +0 -0
@@ -0,0 +1,845 @@
|
|
1
|
+
# Copyright 2022 The MediaPipe Authors.
|
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
|
+
"""Generic metadata writer."""
|
16
|
+
|
17
|
+
import collections
|
18
|
+
import csv
|
19
|
+
import dataclasses
|
20
|
+
import os
|
21
|
+
import tempfile
|
22
|
+
from typing import List, Optional, Tuple, Union
|
23
|
+
|
24
|
+
import flatbuffers
|
25
|
+
|
26
|
+
from mediapipe.tasks.metadata import metadata_schema_py_generated as metadata_fb
|
27
|
+
from mediapipe.tasks.python.metadata import metadata
|
28
|
+
from mediapipe.tasks.python.metadata.metadata_writers import metadata_info
|
29
|
+
from mediapipe.tasks.python.metadata.metadata_writers import writer_utils
|
30
|
+
|
31
|
+
_INPUT_IMAGE_NAME = 'image'
|
32
|
+
_INPUT_IMAGE_DESCRIPTION = 'Input image to be processed.'
|
33
|
+
_INPUT_REGEX_TEXT_NAME = 'input_text'
|
34
|
+
_INPUT_REGEX_TEXT_DESCRIPTION = ('Embedding vectors representing the input '
|
35
|
+
'text to be processed.')
|
36
|
+
_OUTPUT_CLASSIFICATION_NAME = 'score'
|
37
|
+
_OUTPUT_CLASSIFICATION_DESCRIPTION = 'Score of the labels respectively.'
|
38
|
+
_OUTPUT_SEGMENTATION_MASKS_NAME = 'segmentation_masks'
|
39
|
+
_OUTPUT_SEGMENTATION_MASKS_DESCRIPTION = (
|
40
|
+
'Masks over the target objects with high accuracy.'
|
41
|
+
)
|
42
|
+
# Detection tensor result to be grouped together.
|
43
|
+
_DETECTION_GROUP_NAME = 'detection_result'
|
44
|
+
# File name to export score calibration parameters.
|
45
|
+
_SCORE_CALIBATION_FILENAME = 'score_calibration.txt'
|
46
|
+
|
47
|
+
|
48
|
+
@dataclasses.dataclass
|
49
|
+
class CalibrationParameter:
|
50
|
+
"""Parameters for score calibration [1].
|
51
|
+
|
52
|
+
Score calibration is performed on an output tensor through sigmoid functions.
|
53
|
+
One of the main purposes of score calibration is to make scores across classes
|
54
|
+
comparable, so that a common threshold can be used for all output classes.
|
55
|
+
|
56
|
+
For each index in the output tensor, this applies:
|
57
|
+
* `f(x) = scale / (1 + e^-(slope * g(x) + offset))` if `x > min_score` or if
|
58
|
+
no `min_score` has been specified.
|
59
|
+
* `f(x) = default_score` otherwise or if no scale, slope and offset have
|
60
|
+
been specified.
|
61
|
+
|
62
|
+
[1]:
|
63
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L434
|
64
|
+
"""
|
65
|
+
scale: float
|
66
|
+
slope: float
|
67
|
+
offset: float
|
68
|
+
min_score: Optional[float] = None
|
69
|
+
|
70
|
+
|
71
|
+
@dataclasses.dataclass
|
72
|
+
class LabelItem:
|
73
|
+
"""Label item for labels per locale.
|
74
|
+
|
75
|
+
Attributes:
|
76
|
+
filename: The file name to save the labels.
|
77
|
+
names: A list of label names.
|
78
|
+
locale: The specified locale for labels.
|
79
|
+
"""
|
80
|
+
filename: str
|
81
|
+
names: List[str]
|
82
|
+
locale: Optional[str] = None
|
83
|
+
|
84
|
+
|
85
|
+
@dataclasses.dataclass
|
86
|
+
class ScoreThresholding:
|
87
|
+
"""Parameters to performs thresholding on output tensor values [1].
|
88
|
+
|
89
|
+
Attributes:
|
90
|
+
global_score_threshold: The recommended global threshold below which results
|
91
|
+
are considered low-confidence and should be filtered out. [1]:
|
92
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L468
|
93
|
+
"""
|
94
|
+
global_score_threshold: float
|
95
|
+
|
96
|
+
|
97
|
+
@dataclasses.dataclass
|
98
|
+
class RegexTokenizer:
|
99
|
+
"""Parameters of the Regex tokenizer [1] metadata information.
|
100
|
+
|
101
|
+
[1]:
|
102
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L500
|
103
|
+
|
104
|
+
Attributes:
|
105
|
+
delim_regex_pattern: the regular expression to segment strings and create
|
106
|
+
tokens.
|
107
|
+
vocab_file_path: path to the vocabulary file.
|
108
|
+
"""
|
109
|
+
delim_regex_pattern: str
|
110
|
+
vocab_file_path: str
|
111
|
+
|
112
|
+
|
113
|
+
@dataclasses.dataclass
|
114
|
+
class BertTokenizer:
|
115
|
+
"""Parameters of the Bert tokenizer [1] metadata information.
|
116
|
+
|
117
|
+
[1]:
|
118
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L477
|
119
|
+
|
120
|
+
Attributes:
|
121
|
+
vocab_file_path: path to the vocabulary file.
|
122
|
+
"""
|
123
|
+
vocab_file_path: str
|
124
|
+
|
125
|
+
|
126
|
+
@dataclasses.dataclass
|
127
|
+
class SentencePieceTokenizer:
|
128
|
+
"""Parameters of the sentence piece tokenizer tokenizer [1] metadata information.
|
129
|
+
|
130
|
+
[1]:
|
131
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L485
|
132
|
+
|
133
|
+
Attributes:
|
134
|
+
sentence_piece_model_path: path to the sentence piece model file.
|
135
|
+
vocab_file_path: path to the vocabulary file.
|
136
|
+
"""
|
137
|
+
sentence_piece_model_path: str
|
138
|
+
vocab_file_path: Optional[str] = None
|
139
|
+
|
140
|
+
|
141
|
+
class Labels(object):
|
142
|
+
"""Simple container holding classification labels of a particular tensor.
|
143
|
+
|
144
|
+
Example usage:
|
145
|
+
# The first added label list can be used as category names as needed.
|
146
|
+
labels = Labels()
|
147
|
+
.add(['/m/011l78', '/m/031d23'])
|
148
|
+
.add(['cat', 'dog], 'en')
|
149
|
+
.add(['chat', 'chien], 'fr')
|
150
|
+
"""
|
151
|
+
|
152
|
+
def __init__(self) -> None:
|
153
|
+
self._labels = [] # [LabelItem]
|
154
|
+
|
155
|
+
@property
|
156
|
+
def labels(self) -> List[LabelItem]:
|
157
|
+
return self._labels
|
158
|
+
|
159
|
+
def add(self,
|
160
|
+
labels: List[str],
|
161
|
+
locale: Optional[str] = None,
|
162
|
+
exported_filename: Optional[str] = None) -> 'Labels':
|
163
|
+
"""Adds labels in the container.
|
164
|
+
|
165
|
+
Args:
|
166
|
+
labels: A list of label names, e.g. ['apple', 'pear', 'banana'].
|
167
|
+
locale: The specified locale for labels.
|
168
|
+
exported_filename: The file name to export the labels. If not set,
|
169
|
+
filename defaults to 'labels.txt'.
|
170
|
+
|
171
|
+
Returns:
|
172
|
+
The Labels instance, can be used for chained operation.
|
173
|
+
"""
|
174
|
+
if not labels:
|
175
|
+
raise ValueError('The list of labels is empty.')
|
176
|
+
|
177
|
+
# Prepare the new item to be inserted
|
178
|
+
if not exported_filename:
|
179
|
+
exported_filename = 'labels'
|
180
|
+
if locale:
|
181
|
+
exported_filename += f'_{locale}'
|
182
|
+
exported_filename += '.txt'
|
183
|
+
item = LabelItem(filename=exported_filename, names=labels, locale=locale)
|
184
|
+
|
185
|
+
# Insert the new element at the end of the list
|
186
|
+
self._labels.append(item)
|
187
|
+
return self
|
188
|
+
|
189
|
+
def add_from_file(self,
|
190
|
+
label_filepath: str,
|
191
|
+
locale: Optional[str] = None,
|
192
|
+
exported_filename: Optional[str] = None) -> 'Labels':
|
193
|
+
"""Adds a label file in the container.
|
194
|
+
|
195
|
+
Args:
|
196
|
+
label_filepath: File path to read labels. Each line is a label name in the
|
197
|
+
file.
|
198
|
+
locale: The specified locale for labels.
|
199
|
+
exported_filename: The file name to export the labels. If not set,
|
200
|
+
filename defaults to 'labels.txt'.
|
201
|
+
|
202
|
+
Returns:
|
203
|
+
The Labels instance, can be used for chained operation.
|
204
|
+
"""
|
205
|
+
|
206
|
+
with open(label_filepath, 'r') as f:
|
207
|
+
labels = f.read().split('\n')
|
208
|
+
return self.add(labels, locale, exported_filename)
|
209
|
+
|
210
|
+
|
211
|
+
class ScoreCalibration:
|
212
|
+
"""Simple container holding score calibration related parameters."""
|
213
|
+
|
214
|
+
# A shortcut to avoid client side code importing metadata_fb
|
215
|
+
transformation_types = metadata_fb.ScoreTransformationType
|
216
|
+
|
217
|
+
def __init__(self,
|
218
|
+
transformation_type: metadata_fb.ScoreTransformationType,
|
219
|
+
parameters: List[Optional[CalibrationParameter]],
|
220
|
+
default_score: int = 0):
|
221
|
+
self.transformation_type = transformation_type
|
222
|
+
self.parameters = parameters
|
223
|
+
self.default_score = default_score
|
224
|
+
|
225
|
+
@classmethod
|
226
|
+
def create_from_file(cls,
|
227
|
+
transformation_type: metadata_fb.ScoreTransformationType,
|
228
|
+
file_path: str,
|
229
|
+
default_score: int = 0) -> 'ScoreCalibration':
|
230
|
+
"""Creates ScoreCalibration from the file.
|
231
|
+
|
232
|
+
Args:
|
233
|
+
transformation_type: type of the function used for transforming the
|
234
|
+
uncalibrated score before applying score calibration.
|
235
|
+
file_path: file_path of the score calibration file [1]. Contains
|
236
|
+
sigmoid-based score calibration parameters, formatted as CSV. Lines
|
237
|
+
contain for each index of an output tensor the scale, slope, offset and
|
238
|
+
(optional) min_score parameters to be used for sigmoid fitting (in this
|
239
|
+
order and in `strtof`-compatible [2] format). Scale should be a
|
240
|
+
non-negative value. A line may be left empty to default calibrated
|
241
|
+
scores for this index to default_score. In summary, each line should
|
242
|
+
thus contain 0, 3 or 4 comma-separated values.
|
243
|
+
default_score: the default calibrated score to apply if the uncalibrated
|
244
|
+
score is below min_score or if no parameters were specified for a given
|
245
|
+
index.
|
246
|
+
[1]:
|
247
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L133
|
248
|
+
[2]:
|
249
|
+
https://en.cppreference.com/w/c/string/byte/strtof
|
250
|
+
|
251
|
+
Returns:
|
252
|
+
A ScoreCalibration object.
|
253
|
+
Raises:
|
254
|
+
ValueError: if the score_calibration file is malformed.
|
255
|
+
"""
|
256
|
+
with open(file_path, 'r') as calibration_file:
|
257
|
+
csv_reader = csv.reader(calibration_file, delimiter=',')
|
258
|
+
parameters = []
|
259
|
+
for row in csv_reader:
|
260
|
+
if not row:
|
261
|
+
parameters.append(None)
|
262
|
+
continue
|
263
|
+
|
264
|
+
if len(row) != 3 and len(row) != 4:
|
265
|
+
raise ValueError(
|
266
|
+
f'Expected empty lines or 3 or 4 parameters per line in score'
|
267
|
+
f' calibration file, but got {len(row)}.')
|
268
|
+
|
269
|
+
if float(row[0]) < 0:
|
270
|
+
raise ValueError(
|
271
|
+
f'Expected scale to be a non-negative value, but got '
|
272
|
+
f'{float(row[0])}.')
|
273
|
+
|
274
|
+
parameters.append(
|
275
|
+
CalibrationParameter(
|
276
|
+
scale=float(row[0]),
|
277
|
+
slope=float(row[1]),
|
278
|
+
offset=float(row[2]),
|
279
|
+
min_score=None if len(row) == 3 else float(row[3])))
|
280
|
+
|
281
|
+
return cls(transformation_type, parameters, default_score)
|
282
|
+
|
283
|
+
|
284
|
+
def _fill_default_tensor_names(
|
285
|
+
tensor_metadata_list: List[metadata_fb.TensorMetadataT],
|
286
|
+
tensor_names_from_model: List[str]):
|
287
|
+
"""Fills the default tensor names."""
|
288
|
+
# If tensor name in metadata is empty, default to the tensor name saved in
|
289
|
+
# the model.
|
290
|
+
for tensor_metadata, name in zip(tensor_metadata_list,
|
291
|
+
tensor_names_from_model):
|
292
|
+
tensor_metadata.name = tensor_metadata.name or name
|
293
|
+
|
294
|
+
|
295
|
+
def _pair_tensor_metadata(
|
296
|
+
tensor_md: List[metadata_info.TensorMd],
|
297
|
+
tensor_names_from_model: List[str]) -> List[metadata_info.TensorMd]:
|
298
|
+
"""Pairs tensor_md according to the tensor names from the model."""
|
299
|
+
tensor_names_from_arg = [
|
300
|
+
md.tensor_name for md in tensor_md or [] if md.tensor_name is not None
|
301
|
+
]
|
302
|
+
if not tensor_names_from_arg:
|
303
|
+
return tensor_md
|
304
|
+
|
305
|
+
if collections.Counter(tensor_names_from_arg) != collections.Counter(
|
306
|
+
tensor_names_from_model):
|
307
|
+
raise ValueError(
|
308
|
+
'The tensor names from arguments ({}) do not match the tensor names'
|
309
|
+
' read from the model ({}).'.format(tensor_names_from_arg,
|
310
|
+
tensor_names_from_model))
|
311
|
+
pairs_tensor_md = []
|
312
|
+
name_md_dict = dict(zip(tensor_names_from_arg, tensor_md))
|
313
|
+
for name in tensor_names_from_model:
|
314
|
+
pairs_tensor_md.append(name_md_dict[name])
|
315
|
+
return pairs_tensor_md
|
316
|
+
|
317
|
+
|
318
|
+
def _create_metadata_buffer(
|
319
|
+
model_buffer: bytearray,
|
320
|
+
general_md: Optional[metadata_info.GeneralMd] = None,
|
321
|
+
input_md: Optional[List[metadata_info.TensorMd]] = None,
|
322
|
+
output_md: Optional[List[metadata_info.TensorMd]] = None,
|
323
|
+
input_process_units: Optional[List[metadata_fb.ProcessUnitT]] = None,
|
324
|
+
output_group_md: Optional[List[metadata_info.TensorGroupMd]] = None,
|
325
|
+
custom_metadata_md: Optional[List[metadata_info.CustomMetadataMd]] = None,
|
326
|
+
) -> bytearray:
|
327
|
+
"""Creates a buffer of the metadata.
|
328
|
+
|
329
|
+
Args:
|
330
|
+
model_buffer: valid buffer of the model file.
|
331
|
+
general_md: general information about the model.
|
332
|
+
input_md: metadata information of the input tensors.
|
333
|
+
output_md: metadata information of the output tensors.
|
334
|
+
input_process_units: a lists of metadata of the input process units [1].
|
335
|
+
output_group_md: a list of metadata of output tensor groups [2];
|
336
|
+
custom_metadata_md: a lists of custom metadata.
|
337
|
+
[1]:
|
338
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L655
|
339
|
+
[2]:
|
340
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L677
|
341
|
+
|
342
|
+
Returns:
|
343
|
+
A buffer of the metadata.
|
344
|
+
|
345
|
+
Raises:
|
346
|
+
ValueError: if the tensor names from `input_md` and `output_md` do not
|
347
|
+
match the tensor names read from the model.
|
348
|
+
"""
|
349
|
+
# Create input metadata from `input_md`.
|
350
|
+
if input_md:
|
351
|
+
input_md = _pair_tensor_metadata(
|
352
|
+
input_md, writer_utils.get_input_tensor_names(model_buffer))
|
353
|
+
input_metadata = [m.create_metadata() for m in input_md]
|
354
|
+
else:
|
355
|
+
num_input_tensors = writer_utils.get_subgraph(model_buffer).InputsLength()
|
356
|
+
input_metadata = [metadata_fb.TensorMetadataT()] * num_input_tensors
|
357
|
+
|
358
|
+
_fill_default_tensor_names(input_metadata,
|
359
|
+
writer_utils.get_input_tensor_names(model_buffer))
|
360
|
+
|
361
|
+
# Create output metadata from `output_md`.
|
362
|
+
if output_md:
|
363
|
+
output_md = _pair_tensor_metadata(
|
364
|
+
output_md, writer_utils.get_output_tensor_names(model_buffer))
|
365
|
+
output_metadata = [m.create_metadata() for m in output_md]
|
366
|
+
else:
|
367
|
+
num_output_tensors = writer_utils.get_subgraph(model_buffer).OutputsLength()
|
368
|
+
output_metadata = [metadata_fb.TensorMetadataT()] * num_output_tensors
|
369
|
+
_fill_default_tensor_names(output_metadata,
|
370
|
+
writer_utils.get_output_tensor_names(model_buffer))
|
371
|
+
|
372
|
+
# Create the subgraph metadata.
|
373
|
+
subgraph_metadata = metadata_fb.SubGraphMetadataT()
|
374
|
+
subgraph_metadata.inputTensorMetadata = input_metadata
|
375
|
+
subgraph_metadata.outputTensorMetadata = output_metadata
|
376
|
+
if input_process_units:
|
377
|
+
subgraph_metadata.inputProcessUnits = input_process_units
|
378
|
+
if custom_metadata_md:
|
379
|
+
subgraph_metadata.customMetadata = [
|
380
|
+
m.create_metadata() for m in custom_metadata_md
|
381
|
+
]
|
382
|
+
if output_group_md:
|
383
|
+
subgraph_metadata.outputTensorGroups = [
|
384
|
+
m.create_metadata() for m in output_group_md
|
385
|
+
]
|
386
|
+
|
387
|
+
# Create the whole model metadata.
|
388
|
+
if general_md is None:
|
389
|
+
general_md = metadata_info.GeneralMd()
|
390
|
+
model_metadata = general_md.create_metadata()
|
391
|
+
model_metadata.subgraphMetadata = [subgraph_metadata]
|
392
|
+
|
393
|
+
# Get the metadata flatbuffer.
|
394
|
+
b = flatbuffers.Builder(0)
|
395
|
+
b.Finish(
|
396
|
+
model_metadata.Pack(b),
|
397
|
+
metadata.MetadataPopulator.METADATA_FILE_IDENTIFIER)
|
398
|
+
return b.Output()
|
399
|
+
|
400
|
+
|
401
|
+
class MetadataWriter(object):
|
402
|
+
"""Generic Metadata writer.
|
403
|
+
|
404
|
+
Example usage:
|
405
|
+
|
406
|
+
For an example model which requires two inputs: image and general feature
|
407
|
+
inputs, and generates one output: classification.
|
408
|
+
|
409
|
+
with open(model_path, 'rb') as f:
|
410
|
+
writer = MetadataWriter.create(f.read())
|
411
|
+
model_content, metadata_json_content = writer
|
412
|
+
.add_genernal_info('model_name', 'model description')
|
413
|
+
.add_image_input()
|
414
|
+
.add_feature_input()
|
415
|
+
.add_classification_output(Labels().add(['A', 'B']))
|
416
|
+
.populate()
|
417
|
+
"""
|
418
|
+
|
419
|
+
@classmethod
|
420
|
+
def create(cls, model_buffer: bytearray) -> 'MetadataWriter':
|
421
|
+
return cls(model_buffer)
|
422
|
+
|
423
|
+
def __init__(self, model_buffer: bytearray) -> None:
|
424
|
+
self._model_buffer = model_buffer
|
425
|
+
self._general_md = None
|
426
|
+
self._input_mds = []
|
427
|
+
self._input_process_units = []
|
428
|
+
self._output_mds = []
|
429
|
+
self._output_group_mds = []
|
430
|
+
self._associated_files = []
|
431
|
+
self._custom_metadata_mds = []
|
432
|
+
self._temp_folder = tempfile.TemporaryDirectory()
|
433
|
+
|
434
|
+
def __del__(self):
|
435
|
+
if os.path.exists(self._temp_folder.name):
|
436
|
+
self._temp_folder.cleanup()
|
437
|
+
|
438
|
+
def add_general_info(
|
439
|
+
self,
|
440
|
+
model_name: str,
|
441
|
+
model_description: Optional[str] = None) -> 'MetadataWriter':
|
442
|
+
"""Adds a general info metadata for the general metadata informantion."""
|
443
|
+
# Will overwrite the previous `self._general_md` if exists.
|
444
|
+
self._general_md = metadata_info.GeneralMd(
|
445
|
+
name=model_name, description=model_description)
|
446
|
+
return self
|
447
|
+
|
448
|
+
color_space_types = metadata_fb.ColorSpaceType
|
449
|
+
|
450
|
+
def add_feature_input(self,
|
451
|
+
name: Optional[str] = None,
|
452
|
+
description: Optional[str] = None) -> 'MetadataWriter':
|
453
|
+
"""Adds an input tensor metadata for the general basic feature input."""
|
454
|
+
input_md = metadata_info.TensorMd(name=name, description=description)
|
455
|
+
self._input_mds.append(input_md)
|
456
|
+
return self
|
457
|
+
|
458
|
+
def add_image_input(
|
459
|
+
self,
|
460
|
+
norm_mean: List[float],
|
461
|
+
norm_std: List[float],
|
462
|
+
color_space_type: Optional[int] = metadata_fb.ColorSpaceType.RGB,
|
463
|
+
name: str = _INPUT_IMAGE_NAME,
|
464
|
+
description: str = _INPUT_IMAGE_DESCRIPTION) -> 'MetadataWriter':
|
465
|
+
"""Adds an input image metadata for the image input.
|
466
|
+
|
467
|
+
Args:
|
468
|
+
norm_mean: The mean value used to normalize each input channel. If there
|
469
|
+
is only one element in the list, its value will be broadcasted to all
|
470
|
+
channels. Also note that norm_mean and norm_std should have the same
|
471
|
+
number of elements. [1]
|
472
|
+
norm_std: The std value used to normalize each input channel. If there is
|
473
|
+
only one element in the list, its value will be broadcasted to all
|
474
|
+
channels. [1]
|
475
|
+
color_space_type: The color space type of the input image. [2]
|
476
|
+
name: Name of the input tensor.
|
477
|
+
description: Description of the input tensor.
|
478
|
+
|
479
|
+
Returns:
|
480
|
+
The MetadataWriter instance, can be used for chained operation.
|
481
|
+
|
482
|
+
[1]:
|
483
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L389
|
484
|
+
[2]:
|
485
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L198
|
486
|
+
"""
|
487
|
+
input_md = metadata_info.InputImageTensorMd(
|
488
|
+
name=name,
|
489
|
+
description=description,
|
490
|
+
norm_mean=norm_mean,
|
491
|
+
norm_std=norm_std,
|
492
|
+
color_space_type=color_space_type,
|
493
|
+
tensor_type=self._input_tensor_type(len(self._input_mds)))
|
494
|
+
|
495
|
+
self._input_mds.append(input_md)
|
496
|
+
return self
|
497
|
+
|
498
|
+
def add_regex_text_input(
|
499
|
+
self,
|
500
|
+
regex_tokenizer: RegexTokenizer,
|
501
|
+
name: str = _INPUT_REGEX_TEXT_NAME,
|
502
|
+
description: str = _INPUT_REGEX_TEXT_DESCRIPTION) -> 'MetadataWriter':
|
503
|
+
"""Adds an input text metadata for the text input with regex tokenizer.
|
504
|
+
|
505
|
+
Args:
|
506
|
+
regex_tokenizer: information of the regex tokenizer [1] used to process
|
507
|
+
the input string.
|
508
|
+
name: Name of the input tensor.
|
509
|
+
description: Description of the input tensor.
|
510
|
+
|
511
|
+
Returns:
|
512
|
+
The MetadataWriter instance, can be used for chained operation.
|
513
|
+
|
514
|
+
[1]:
|
515
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L500
|
516
|
+
"""
|
517
|
+
tokenizer_md = metadata_info.RegexTokenizerMd(
|
518
|
+
delim_regex_pattern=regex_tokenizer.delim_regex_pattern,
|
519
|
+
vocab_file_path=regex_tokenizer.vocab_file_path)
|
520
|
+
input_md = metadata_info.InputTextTensorMd(
|
521
|
+
name=name, description=description, tokenizer_md=tokenizer_md)
|
522
|
+
self._input_mds.append(input_md)
|
523
|
+
self._associated_files.append(regex_tokenizer.vocab_file_path)
|
524
|
+
return self
|
525
|
+
|
526
|
+
def add_bert_text_input(self, tokenizer: Union[BertTokenizer,
|
527
|
+
SentencePieceTokenizer],
|
528
|
+
ids_name: str, mask_name: str,
|
529
|
+
segment_name: str) -> 'MetadataWriter':
|
530
|
+
"""Adds an metadata for the text input with bert / sentencepiece tokenizer.
|
531
|
+
|
532
|
+
`ids_name`, `mask_name`, and `segment_name` correspond to the `Tensor.name`
|
533
|
+
in the TFLite schema, which help to determine the tensor order when
|
534
|
+
populating metadata.
|
535
|
+
|
536
|
+
Args:
|
537
|
+
tokenizer: information of the tokenizer used to process the input string,
|
538
|
+
if any. Supported tokenziers are: `BertTokenizer` [1] and
|
539
|
+
`SentencePieceTokenizer` [2].
|
540
|
+
ids_name: name of the ids tensor, which represents the tokenized ids of
|
541
|
+
the input text.
|
542
|
+
mask_name: name of the mask tensor, which represents the mask with `1` for
|
543
|
+
real tokens and `0` for padding tokens.
|
544
|
+
segment_name: name of the segment ids tensor, where `0` stands for the
|
545
|
+
first sequence, and `1` stands for the second sequence if exists.
|
546
|
+
|
547
|
+
Returns:
|
548
|
+
The MetadataWriter instance, can be used for chained operation.
|
549
|
+
|
550
|
+
Raises:
|
551
|
+
ValueError: if the type tokenizer is not BertTokenizer or
|
552
|
+
SentencePieceTokenizer.
|
553
|
+
|
554
|
+
[1]:
|
555
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L477
|
556
|
+
[2]:
|
557
|
+
https://github.com/google/mediapipe/blob/f8af41b1eb49ff4bdad756ff19d1d36f486be614/mediapipe/tasks/metadata/metadata_schema.fbs#L485
|
558
|
+
"""
|
559
|
+
if isinstance(tokenizer, BertTokenizer):
|
560
|
+
tokenizer_md = metadata_info.BertTokenizerMd(
|
561
|
+
vocab_file_path=tokenizer.vocab_file_path)
|
562
|
+
elif isinstance(tokenizer, SentencePieceTokenizer):
|
563
|
+
tokenizer_md = metadata_info.SentencePieceTokenizerMd(
|
564
|
+
sentence_piece_model_path=tokenizer.sentence_piece_model_path,
|
565
|
+
vocab_file_path=tokenizer.vocab_file_path)
|
566
|
+
else:
|
567
|
+
raise ValueError(
|
568
|
+
f'The type of tokenizer, {type(tokenizer)}, is unsupported')
|
569
|
+
bert_input_md = metadata_info.BertInputTensorsMd(
|
570
|
+
self._model_buffer,
|
571
|
+
ids_name,
|
572
|
+
mask_name,
|
573
|
+
segment_name,
|
574
|
+
tokenizer_md=tokenizer_md)
|
575
|
+
|
576
|
+
self._input_mds.extend(bert_input_md.input_md)
|
577
|
+
self._associated_files.extend(
|
578
|
+
bert_input_md.get_tokenizer_associated_files())
|
579
|
+
self._input_process_units.extend(
|
580
|
+
bert_input_md.create_input_process_unit_metadata())
|
581
|
+
return self
|
582
|
+
|
583
|
+
def add_classification_output(
|
584
|
+
self,
|
585
|
+
labels: Optional[Labels] = None,
|
586
|
+
score_calibration: Optional[ScoreCalibration] = None,
|
587
|
+
score_thresholding: Optional[ScoreThresholding] = None,
|
588
|
+
name: str = _OUTPUT_CLASSIFICATION_NAME,
|
589
|
+
description: str = _OUTPUT_CLASSIFICATION_DESCRIPTION
|
590
|
+
) -> 'MetadataWriter':
|
591
|
+
"""Add a classification head metadata for classification output tensor.
|
592
|
+
|
593
|
+
Example usage:
|
594
|
+
writer.add_classification_output(
|
595
|
+
Labels()
|
596
|
+
.add(['/m/011l78', '/m/031d23'])
|
597
|
+
.add(['cat', 'dog], 'en')
|
598
|
+
.add(['chat', 'chien], 'fr')
|
599
|
+
)
|
600
|
+
|
601
|
+
Args:
|
602
|
+
labels: an instance of Labels helper class.
|
603
|
+
score_calibration: an instance of ScoreCalibration helper class.
|
604
|
+
score_thresholding: an instance of ScoreThresholding.
|
605
|
+
name: Metadata name of the tensor. Note that this is different from tensor
|
606
|
+
name in the flatbuffer.
|
607
|
+
description: human readable description of what the output is.
|
608
|
+
|
609
|
+
Returns:
|
610
|
+
The current Writer instance to allow chained operation.
|
611
|
+
"""
|
612
|
+
calibration_md = self._create_score_calibration_md(score_calibration)
|
613
|
+
score_thresholding_md = None
|
614
|
+
if score_thresholding:
|
615
|
+
score_thresholding_md = metadata_info.ScoreThresholdingMd(
|
616
|
+
score_thresholding.global_score_threshold)
|
617
|
+
|
618
|
+
label_files = self._create_label_file_md(labels)
|
619
|
+
output_md = metadata_info.ClassificationTensorMd(
|
620
|
+
name=name,
|
621
|
+
description=description,
|
622
|
+
label_files=label_files,
|
623
|
+
tensor_type=self._output_tensor_type(len(self._output_mds)),
|
624
|
+
score_calibration_md=calibration_md,
|
625
|
+
score_thresholding_md=score_thresholding_md,
|
626
|
+
)
|
627
|
+
self._output_mds.append(output_md)
|
628
|
+
return self
|
629
|
+
|
630
|
+
def add_detection_output(
|
631
|
+
self,
|
632
|
+
labels: Optional[Labels] = None,
|
633
|
+
score_calibration: Optional[ScoreCalibration] = None,
|
634
|
+
group_name: str = _DETECTION_GROUP_NAME,
|
635
|
+
) -> 'MetadataWriter':
|
636
|
+
"""Adds a detection head metadata for detection output tensor of models with postprocessing.
|
637
|
+
|
638
|
+
Args:
|
639
|
+
labels: an instance of Labels helper class.
|
640
|
+
score_calibration: an instance of ScoreCalibration helper class.
|
641
|
+
group_name: name of output tensor group.
|
642
|
+
|
643
|
+
Returns:
|
644
|
+
The current Writer instance to allow chained operation.
|
645
|
+
"""
|
646
|
+
calibration_md = self._create_score_calibration_md(score_calibration)
|
647
|
+
label_files = self._create_label_file_md(labels)
|
648
|
+
detection_output_mds = metadata_info.DetectionOutputTensorsMd(
|
649
|
+
self._model_buffer,
|
650
|
+
label_files=label_files,
|
651
|
+
score_calibration_md=calibration_md,
|
652
|
+
).output_mds
|
653
|
+
self._output_mds.extend(detection_output_mds)
|
654
|
+
# Outputs are location, category, score, number of detections.
|
655
|
+
if len(detection_output_mds) != 4:
|
656
|
+
raise ValueError('The size of detections output should be 4.')
|
657
|
+
# The first 3 tensors (location, category, score) are grouped.
|
658
|
+
group_md = metadata_info.TensorGroupMd(
|
659
|
+
name=group_name,
|
660
|
+
tensor_names=[output_md.name for output_md in detection_output_mds[:3]],
|
661
|
+
)
|
662
|
+
self._output_group_mds.append(group_md)
|
663
|
+
return self
|
664
|
+
|
665
|
+
def add_raw_detection_output(
|
666
|
+
self,
|
667
|
+
labels: Optional[Labels] = None,
|
668
|
+
output_tensors_order: metadata_info.RawDetectionOutputTensorsOrder = metadata_info.RawDetectionOutputTensorsOrder.UNSPECIFIED,
|
669
|
+
) -> 'MetadataWriter':
|
670
|
+
"""Adds a detection head metadata for detection output tensor of models without postprocessing.
|
671
|
+
|
672
|
+
Args:
|
673
|
+
labels: an instance of Labels helper class.
|
674
|
+
output_tensors_order: the order of the output tensors. For models of
|
675
|
+
out-of-graph non-maximum-suppression only.
|
676
|
+
|
677
|
+
Returns:
|
678
|
+
The current Writer instance to allow chained operation.
|
679
|
+
"""
|
680
|
+
label_files = self._create_label_file_md(labels)
|
681
|
+
detection_output_mds = metadata_info.RawDetectionOutputTensorsMd(
|
682
|
+
self._model_buffer,
|
683
|
+
label_files=label_files,
|
684
|
+
output_tensors_order=output_tensors_order,
|
685
|
+
).output_mds
|
686
|
+
self._output_mds.extend(detection_output_mds)
|
687
|
+
# Outputs are location, score.
|
688
|
+
if len(detection_output_mds) != 2:
|
689
|
+
raise ValueError('The size of detections output should be 2.')
|
690
|
+
return self
|
691
|
+
|
692
|
+
def add_segmentation_output(
|
693
|
+
self,
|
694
|
+
labels: Optional[Labels] = None,
|
695
|
+
name: str = _OUTPUT_SEGMENTATION_MASKS_NAME,
|
696
|
+
description: str = _OUTPUT_SEGMENTATION_MASKS_DESCRIPTION,
|
697
|
+
) -> 'MetadataWriter':
|
698
|
+
"""Adds a segmentation head metadata for segmentation output tensor.
|
699
|
+
|
700
|
+
Args:
|
701
|
+
labels: an instance of Labels helper class.
|
702
|
+
name: Metadata name of the tensor. Note that this is different from tensor
|
703
|
+
name in the flatbuffer.
|
704
|
+
description: human readable description of what the output is.
|
705
|
+
|
706
|
+
Returns:
|
707
|
+
The current Writer instance to allow chained operation.
|
708
|
+
"""
|
709
|
+
label_files = self._create_label_file_md(labels)
|
710
|
+
output_md = metadata_info.SegmentationMaskMd(
|
711
|
+
name=name,
|
712
|
+
description=description,
|
713
|
+
label_files=label_files,
|
714
|
+
)
|
715
|
+
self._output_mds.append(output_md)
|
716
|
+
return self
|
717
|
+
|
718
|
+
def add_feature_output(self,
|
719
|
+
name: Optional[str] = None,
|
720
|
+
description: Optional[str] = None) -> 'MetadataWriter':
|
721
|
+
"""Adds an output tensor metadata for the general basic feature output."""
|
722
|
+
output_md = metadata_info.TensorMd(name=name, description=description)
|
723
|
+
self._output_mds.append(output_md)
|
724
|
+
return self
|
725
|
+
|
726
|
+
def add_custom_metadata(
|
727
|
+
self, custom_metadata_md: metadata_info.CustomMetadataMd
|
728
|
+
) -> 'MetadataWriter':
|
729
|
+
self._custom_metadata_mds.append(custom_metadata_md)
|
730
|
+
return self
|
731
|
+
|
732
|
+
def populate(self) -> Tuple[bytearray, str]:
|
733
|
+
"""Populates metadata into the TFLite file.
|
734
|
+
|
735
|
+
Note that only the output tflite is used for deployment. The output JSON
|
736
|
+
content is used to interpret the metadata content.
|
737
|
+
|
738
|
+
Returns:
|
739
|
+
A tuple of (model_with_metadata_in_bytes, metadata_json_content)
|
740
|
+
"""
|
741
|
+
# Populates metadata and associated files into TFLite model buffer.
|
742
|
+
populator = metadata.MetadataPopulator.with_model_buffer(self._model_buffer)
|
743
|
+
metadata_buffer = _create_metadata_buffer(
|
744
|
+
model_buffer=self._model_buffer,
|
745
|
+
general_md=self._general_md,
|
746
|
+
input_md=self._input_mds,
|
747
|
+
output_md=self._output_mds,
|
748
|
+
input_process_units=self._input_process_units,
|
749
|
+
custom_metadata_md=self._custom_metadata_mds,
|
750
|
+
output_group_md=self._output_group_mds,
|
751
|
+
)
|
752
|
+
populator.load_metadata_buffer(metadata_buffer)
|
753
|
+
if self._associated_files:
|
754
|
+
populator.load_associated_files(self._associated_files)
|
755
|
+
populator.populate()
|
756
|
+
tflite_content = populator.get_model_buffer()
|
757
|
+
|
758
|
+
displayer = metadata.MetadataDisplayer.with_model_buffer(tflite_content)
|
759
|
+
metadata_json_content = displayer.get_metadata_json()
|
760
|
+
|
761
|
+
return tflite_content, metadata_json_content
|
762
|
+
|
763
|
+
def _input_tensor_type(self, idx):
|
764
|
+
return writer_utils.get_input_tensor_types(self._model_buffer)[idx]
|
765
|
+
|
766
|
+
def _output_tensor_type(self, idx):
|
767
|
+
return writer_utils.get_output_tensor_types(self._model_buffer)[idx]
|
768
|
+
|
769
|
+
def _export_labels(self, filename: str, index_to_label: List[str]) -> str:
|
770
|
+
filepath = os.path.join(self._temp_folder.name, filename)
|
771
|
+
with open(filepath, 'w') as f:
|
772
|
+
f.write('\n'.join(index_to_label))
|
773
|
+
self._associated_files.append(filepath)
|
774
|
+
return filepath
|
775
|
+
|
776
|
+
def _export_calibration_file(self, filename: str,
|
777
|
+
calibrations: List[CalibrationParameter]) -> str:
|
778
|
+
"""Stores calibration parameters in a csv file."""
|
779
|
+
filepath = os.path.join(self._temp_folder.name, filename)
|
780
|
+
with open(filepath, 'w') as f:
|
781
|
+
for item in calibrations:
|
782
|
+
if item:
|
783
|
+
if item.scale is None or item.slope is None or item.offset is None:
|
784
|
+
raise ValueError('scale, slope and offset values can not be set to '
|
785
|
+
'None.')
|
786
|
+
elif item.min_score is not None:
|
787
|
+
f.write(f'{item.scale},{item.slope},{item.offset},{item.min_score}')
|
788
|
+
else:
|
789
|
+
f.write(f'{item.scale},{item.slope},{item.offset}')
|
790
|
+
f.write('\n')
|
791
|
+
|
792
|
+
self._associated_files.append(filepath)
|
793
|
+
return filepath
|
794
|
+
|
795
|
+
def _create_score_calibration_md(
|
796
|
+
self, score_calibration: ScoreCalibration
|
797
|
+
) -> Optional[metadata_info.ScoreCalibrationMd]:
|
798
|
+
"""Creates the ScoreCalibrationMd object."""
|
799
|
+
if score_calibration is None:
|
800
|
+
return None
|
801
|
+
return metadata_info.ScoreCalibrationMd(
|
802
|
+
score_transformation_type=score_calibration.transformation_type,
|
803
|
+
default_score=score_calibration.default_score,
|
804
|
+
file_path=self._export_calibration_file(
|
805
|
+
_SCORE_CALIBATION_FILENAME, score_calibration.parameters
|
806
|
+
),
|
807
|
+
)
|
808
|
+
|
809
|
+
def _create_label_file_md(
|
810
|
+
self, labels: Optional[Labels] = None
|
811
|
+
) -> Optional[List[metadata_info.LabelFileMd]]:
|
812
|
+
"""Creates a list of LabelFileMd objects."""
|
813
|
+
label_files = None
|
814
|
+
if labels:
|
815
|
+
label_files = []
|
816
|
+
for item in labels.labels:
|
817
|
+
label_files.append(
|
818
|
+
metadata_info.LabelFileMd(
|
819
|
+
self._export_labels(item.filename, item.names),
|
820
|
+
locale=item.locale,
|
821
|
+
)
|
822
|
+
)
|
823
|
+
return label_files
|
824
|
+
|
825
|
+
|
826
|
+
class MetadataWriterBase:
|
827
|
+
"""Base MetadataWriter class which contains the apis exposed to users.
|
828
|
+
|
829
|
+
MetadataWriter for Tasks e.g. image classifier / object detector will inherit
|
830
|
+
this class for their own usage.
|
831
|
+
"""
|
832
|
+
|
833
|
+
def __init__(self, writer: MetadataWriter) -> None:
|
834
|
+
self.writer = writer
|
835
|
+
|
836
|
+
def populate(self) -> Tuple[bytearray, str]:
|
837
|
+
"""Populates metadata into the TFLite file.
|
838
|
+
|
839
|
+
Note that only the output tflite is used for deployment. The output JSON
|
840
|
+
content is used to interpret the metadata content.
|
841
|
+
|
842
|
+
Returns:
|
843
|
+
A tuple of (model_with_metadata_in_bytes, metadata_json_content)
|
844
|
+
"""
|
845
|
+
return self.writer.populate()
|