mediapipe-nightly 0.10.21.post20250114__cp312-cp312-macosx_11_0_universal2.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/arm64.cpython-312-darwin.so +0 -0
- mediapipe/python/_framework_bindings.cpython-312-darwin.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/arm64.cpython-312-darwin.so +0 -0
- mediapipe/tasks/cc/metadata/python/_pywrap_metadata_version.cpython-312-darwin.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/arm64.cpython-312-darwin.so +0 -0
- mediapipe/tasks/python/metadata/flatbuffers_lib/_pywrap_flatbuffers.cpython-312-darwin.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/version.txt +1 -0
- mediapipe_nightly-0.10.21.post20250114.dist-info/LICENSE +218 -0
- mediapipe_nightly-0.10.21.post20250114.dist-info/METADATA +209 -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
@@ -0,0 +1,604 @@
|
|
1
|
+
# Copyright 2020 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
|
+
"""MediaPipe SolutionBase module.
|
15
|
+
|
16
|
+
MediaPipe SolutionBase is the common base class for the high-level MediaPipe
|
17
|
+
Solution APIs such as BlazeFace, hand tracking, and BlazePose. The SolutionBase
|
18
|
+
class contains the shared logic among the high-level Solution APIs including
|
19
|
+
graph initialization, processing image/audio data, and graph shutdown. Thus,
|
20
|
+
users can easily create new MediaPipe Solution APIs on top of the SolutionBase
|
21
|
+
class.
|
22
|
+
"""
|
23
|
+
|
24
|
+
import collections
|
25
|
+
import enum
|
26
|
+
import os
|
27
|
+
from typing import Any, Iterable, List, Mapping, NamedTuple, Optional, Union
|
28
|
+
|
29
|
+
import numpy as np
|
30
|
+
|
31
|
+
from google.protobuf.internal import containers
|
32
|
+
from google.protobuf import descriptor
|
33
|
+
from google.protobuf import message
|
34
|
+
# resources dependency
|
35
|
+
# pylint: disable=unused-import
|
36
|
+
from mediapipe.calculators.core import constant_side_packet_calculator_pb2
|
37
|
+
from mediapipe.calculators.image import image_transformation_calculator_pb2
|
38
|
+
from mediapipe.calculators.tensor import tensors_to_detections_calculator_pb2
|
39
|
+
from mediapipe.calculators.util import landmarks_smoothing_calculator_pb2
|
40
|
+
from mediapipe.calculators.util import logic_calculator_pb2
|
41
|
+
from mediapipe.calculators.util import thresholding_calculator_pb2
|
42
|
+
from mediapipe.framework import calculator_pb2
|
43
|
+
from mediapipe.framework.formats import body_rig_pb2
|
44
|
+
from mediapipe.framework.formats import classification_pb2
|
45
|
+
from mediapipe.framework.formats import detection_pb2
|
46
|
+
from mediapipe.framework.formats import landmark_pb2
|
47
|
+
from mediapipe.framework.formats import rect_pb2
|
48
|
+
from mediapipe.modules.objectron.calculators import annotation_data_pb2
|
49
|
+
from mediapipe.modules.objectron.calculators import lift_2d_frame_annotation_to_3d_calculator_pb2
|
50
|
+
# pylint: enable=unused-import
|
51
|
+
from mediapipe.python import packet_creator
|
52
|
+
from mediapipe.python import packet_getter
|
53
|
+
from mediapipe.python._framework_bindings import calculator_graph
|
54
|
+
from mediapipe.python._framework_bindings import image_frame
|
55
|
+
from mediapipe.python._framework_bindings import packet
|
56
|
+
from mediapipe.python._framework_bindings import resource_util
|
57
|
+
from mediapipe.python._framework_bindings import validated_graph_config
|
58
|
+
|
59
|
+
RGB_CHANNELS = 3
|
60
|
+
# TODO: Enable calculator options modification for more calculators.
|
61
|
+
CALCULATOR_TO_OPTIONS = {
|
62
|
+
'ConstantSidePacketCalculator':
|
63
|
+
constant_side_packet_calculator_pb2.ConstantSidePacketCalculatorOptions,
|
64
|
+
'ImageTransformationCalculator':
|
65
|
+
image_transformation_calculator_pb2
|
66
|
+
.ImageTransformationCalculatorOptions,
|
67
|
+
'LandmarksSmoothingCalculator':
|
68
|
+
landmarks_smoothing_calculator_pb2.LandmarksSmoothingCalculatorOptions,
|
69
|
+
'LogicCalculator':
|
70
|
+
logic_calculator_pb2.LogicCalculatorOptions,
|
71
|
+
'ThresholdingCalculator':
|
72
|
+
thresholding_calculator_pb2.ThresholdingCalculatorOptions,
|
73
|
+
'TensorsToDetectionsCalculator':
|
74
|
+
tensors_to_detections_calculator_pb2
|
75
|
+
.TensorsToDetectionsCalculatorOptions,
|
76
|
+
'Lift2DFrameAnnotationTo3DCalculator':
|
77
|
+
lift_2d_frame_annotation_to_3d_calculator_pb2
|
78
|
+
.Lift2DFrameAnnotationTo3DCalculatorOptions,
|
79
|
+
}
|
80
|
+
|
81
|
+
|
82
|
+
def type_names_from_oneof(oneof_type_name: str) -> Optional[List[str]]:
|
83
|
+
if oneof_type_name.startswith('OneOf<') and oneof_type_name.endswith('>'):
|
84
|
+
comma_separated_types = oneof_type_name[len('OneOf<'):-len('>')]
|
85
|
+
return [n.strip() for n in comma_separated_types.split(',')]
|
86
|
+
return None
|
87
|
+
|
88
|
+
|
89
|
+
# TODO: Support more packet data types, such as "Any" type.
|
90
|
+
@enum.unique
|
91
|
+
class PacketDataType(enum.Enum):
|
92
|
+
"""The packet data types supported by the SolutionBase class."""
|
93
|
+
STRING = 'string'
|
94
|
+
BOOL = 'bool'
|
95
|
+
BOOL_LIST = 'bool_list'
|
96
|
+
INT = 'int'
|
97
|
+
INT_LIST = 'int_list'
|
98
|
+
FLOAT = 'float'
|
99
|
+
FLOAT_LIST = 'float_list'
|
100
|
+
AUDIO = 'matrix'
|
101
|
+
IMAGE = 'image'
|
102
|
+
IMAGE_LIST = 'image_list'
|
103
|
+
IMAGE_FRAME = 'image_frame'
|
104
|
+
PROTO = 'proto'
|
105
|
+
PROTO_LIST = 'proto_list'
|
106
|
+
|
107
|
+
@staticmethod
|
108
|
+
def from_registered_name(registered_name: str) -> 'PacketDataType':
|
109
|
+
try:
|
110
|
+
return NAME_TO_TYPE[registered_name]
|
111
|
+
except KeyError as e:
|
112
|
+
names = type_names_from_oneof(registered_name)
|
113
|
+
if names:
|
114
|
+
for n in names:
|
115
|
+
if n in NAME_TO_TYPE.keys():
|
116
|
+
return NAME_TO_TYPE[n]
|
117
|
+
raise e
|
118
|
+
|
119
|
+
NAME_TO_TYPE: Mapping[str, 'PacketDataType'] = {
|
120
|
+
'string': PacketDataType.STRING,
|
121
|
+
'bool': PacketDataType.BOOL,
|
122
|
+
'::std::vector<bool>': PacketDataType.BOOL_LIST,
|
123
|
+
'int': PacketDataType.INT,
|
124
|
+
'::std::vector<int>': PacketDataType.INT_LIST,
|
125
|
+
'int64': PacketDataType.INT,
|
126
|
+
'int64_t': PacketDataType.INT,
|
127
|
+
'::std::vector<int64>': PacketDataType.INT_LIST,
|
128
|
+
'::std::vector<int64_t>': PacketDataType.INT_LIST,
|
129
|
+
'float': PacketDataType.FLOAT,
|
130
|
+
'::std::vector<float>': PacketDataType.FLOAT_LIST,
|
131
|
+
'::mediapipe::Matrix': PacketDataType.AUDIO,
|
132
|
+
'::mediapipe::ImageFrame': PacketDataType.IMAGE_FRAME,
|
133
|
+
'::mediapipe::Classification': PacketDataType.PROTO,
|
134
|
+
'::mediapipe::ClassificationList': PacketDataType.PROTO,
|
135
|
+
'::mediapipe::ClassificationListCollection': PacketDataType.PROTO,
|
136
|
+
'::mediapipe::Detection': PacketDataType.PROTO,
|
137
|
+
'::mediapipe::DetectionList': PacketDataType.PROTO,
|
138
|
+
'::mediapipe::Landmark': PacketDataType.PROTO,
|
139
|
+
'::mediapipe::LandmarkList': PacketDataType.PROTO,
|
140
|
+
'::mediapipe::LandmarkListCollection': PacketDataType.PROTO,
|
141
|
+
'::mediapipe::NormalizedLandmark': PacketDataType.PROTO,
|
142
|
+
'::mediapipe::FrameAnnotation': PacketDataType.PROTO,
|
143
|
+
'::mediapipe::Trigger': PacketDataType.PROTO,
|
144
|
+
'::mediapipe::Rect': PacketDataType.PROTO,
|
145
|
+
'::mediapipe::NormalizedRect': PacketDataType.PROTO,
|
146
|
+
'::mediapipe::NormalizedLandmarkList': PacketDataType.PROTO,
|
147
|
+
'::mediapipe::NormalizedLandmarkListCollection': PacketDataType.PROTO,
|
148
|
+
'::mediapipe::Image': PacketDataType.IMAGE,
|
149
|
+
'::std::vector<::mediapipe::Image>': PacketDataType.IMAGE_LIST,
|
150
|
+
'::std::vector<::mediapipe::Classification>': PacketDataType.PROTO_LIST,
|
151
|
+
'::std::vector<::mediapipe::ClassificationList>': PacketDataType.PROTO_LIST,
|
152
|
+
'::std::vector<::mediapipe::Detection>': PacketDataType.PROTO_LIST,
|
153
|
+
'::std::vector<::mediapipe::DetectionList>': PacketDataType.PROTO_LIST,
|
154
|
+
'::std::vector<::mediapipe::Landmark>': PacketDataType.PROTO_LIST,
|
155
|
+
'::std::vector<::mediapipe::LandmarkList>': PacketDataType.PROTO_LIST,
|
156
|
+
'::std::vector<::mediapipe::NormalizedLandmark>': PacketDataType.PROTO_LIST,
|
157
|
+
'::std::vector<::mediapipe::NormalizedLandmarkList>': (
|
158
|
+
PacketDataType.PROTO_LIST
|
159
|
+
),
|
160
|
+
'::std::vector<::mediapipe::Rect>': PacketDataType.PROTO_LIST,
|
161
|
+
'::std::vector<::mediapipe::NormalizedRect>': PacketDataType.PROTO_LIST,
|
162
|
+
'::mediapipe::Joint': PacketDataType.PROTO,
|
163
|
+
'::mediapipe::JointList': PacketDataType.PROTO,
|
164
|
+
'::std::vector<::mediapipe::JointList>': PacketDataType.PROTO_LIST,
|
165
|
+
}
|
166
|
+
|
167
|
+
|
168
|
+
class SolutionBase:
|
169
|
+
"""The common base class for the high-level MediaPipe Solution APIs.
|
170
|
+
|
171
|
+
The SolutionBase class contains the shared logic among the high-level solution
|
172
|
+
APIs including graph initialization, processing image/audio data, and graph
|
173
|
+
shutdown.
|
174
|
+
|
175
|
+
Example usage:
|
176
|
+
with solution_base.SolutionBase(
|
177
|
+
binary_graph_path='mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb',
|
178
|
+
side_inputs={'num_hands': 2}) as hand_tracker:
|
179
|
+
# Read an image and convert the BGR image to RGB.
|
180
|
+
input_image = cv2.cvtColor(cv2.imread('/tmp/hand.png'), COLOR_BGR2RGB)
|
181
|
+
results = hand_tracker.process(input_image)
|
182
|
+
print(results.palm_detections)
|
183
|
+
print(results.multi_hand_landmarks)
|
184
|
+
"""
|
185
|
+
|
186
|
+
def __init__(
|
187
|
+
self,
|
188
|
+
binary_graph_path: Optional[str] = None,
|
189
|
+
graph_config: Optional[calculator_pb2.CalculatorGraphConfig] = None,
|
190
|
+
calculator_params: Optional[Mapping[str, Any]] = None,
|
191
|
+
graph_options: Optional[message.Message] = None,
|
192
|
+
side_inputs: Optional[Mapping[str, Any]] = None,
|
193
|
+
outputs: Optional[List[str]] = None,
|
194
|
+
stream_type_hints: Optional[Mapping[str, PacketDataType]] = None):
|
195
|
+
"""Initializes the SolutionBase object.
|
196
|
+
|
197
|
+
Args:
|
198
|
+
binary_graph_path: The path to a binary mediapipe graph file (.binarypb).
|
199
|
+
graph_config: A CalculatorGraphConfig proto message or its text proto
|
200
|
+
format.
|
201
|
+
calculator_params: A mapping from the
|
202
|
+
{calculator_name}.{options_field_name} str to the field value.
|
203
|
+
graph_options: The graph options protobuf for the mediapipe graph.
|
204
|
+
side_inputs: A mapping from the side packet name to the packet raw data.
|
205
|
+
outputs: A list of the graph output stream names to observe. If the list
|
206
|
+
is empty, all the output streams listed in the graph config will be
|
207
|
+
automatically observed by default.
|
208
|
+
stream_type_hints: A mapping from the stream name to its packet type hint.
|
209
|
+
|
210
|
+
Raises:
|
211
|
+
FileNotFoundError: If the binary graph file can't be found.
|
212
|
+
RuntimeError: If the underlying calculator graph can't be successfully
|
213
|
+
initialized or started.
|
214
|
+
ValueError: If any of the following:
|
215
|
+
a) If not exactly one of 'binary_graph_path' or 'graph_config' arguments
|
216
|
+
is provided.
|
217
|
+
b) If the graph validation process contains error.
|
218
|
+
c) If the registered type name of the streams and side packets can't be
|
219
|
+
found.
|
220
|
+
d) If the calculator options of the calculator listed in
|
221
|
+
calculator_params is not allowed to be modified.
|
222
|
+
e) If the calculator options field is a repeated field but the field
|
223
|
+
value to be set is not iterable.
|
224
|
+
f) If not all calculator params are valid.
|
225
|
+
"""
|
226
|
+
if bool(binary_graph_path) == bool(graph_config):
|
227
|
+
raise ValueError(
|
228
|
+
"Must provide exactly one of 'binary_graph_path' or 'graph_config'.")
|
229
|
+
# MediaPipe package root path
|
230
|
+
root_path = os.sep.join(os.path.abspath(__file__).split(os.sep)[:-3])
|
231
|
+
resource_util.set_resource_dir(root_path)
|
232
|
+
validated_graph = validated_graph_config.ValidatedGraphConfig()
|
233
|
+
if binary_graph_path:
|
234
|
+
validated_graph.initialize(
|
235
|
+
binary_graph_path=os.path.join(root_path, binary_graph_path))
|
236
|
+
else:
|
237
|
+
validated_graph.initialize(graph_config=graph_config)
|
238
|
+
|
239
|
+
canonical_graph_config_proto = self._initialize_graph_interface(
|
240
|
+
validated_graph, side_inputs, outputs, stream_type_hints)
|
241
|
+
if calculator_params:
|
242
|
+
self._modify_calculator_options(canonical_graph_config_proto,
|
243
|
+
calculator_params)
|
244
|
+
if graph_options:
|
245
|
+
self._set_extension(canonical_graph_config_proto.graph_options,
|
246
|
+
graph_options)
|
247
|
+
|
248
|
+
self._graph = calculator_graph.CalculatorGraph(
|
249
|
+
graph_config=canonical_graph_config_proto)
|
250
|
+
self._simulated_timestamp = 0
|
251
|
+
self._graph_outputs = {}
|
252
|
+
|
253
|
+
def callback(stream_name: str, output_packet: packet.Packet) -> None:
|
254
|
+
self._graph_outputs[stream_name] = output_packet
|
255
|
+
|
256
|
+
for stream_name in self._output_stream_type_info.keys():
|
257
|
+
self._graph.observe_output_stream(stream_name, callback, True)
|
258
|
+
|
259
|
+
self._input_side_packets = {
|
260
|
+
name: self._make_packet(self._side_input_type_info[name], data)
|
261
|
+
for name, data in (side_inputs or {}).items()
|
262
|
+
}
|
263
|
+
self._graph.start_run(self._input_side_packets)
|
264
|
+
|
265
|
+
# TODO: Use "inspect.Parameter" to fetch the input argument names and
|
266
|
+
# types from "_input_stream_type_info" and then auto generate the process
|
267
|
+
# method signature by "inspect.Signature" in __init__.
|
268
|
+
def process(
|
269
|
+
self, input_data: Union[np.ndarray, Mapping[str, Union[np.ndarray,
|
270
|
+
message.Message]]]
|
271
|
+
) -> NamedTuple:
|
272
|
+
"""Processes a set of RGB image data and output SolutionOutputs.
|
273
|
+
|
274
|
+
Args:
|
275
|
+
input_data: Either a single numpy ndarray object representing the solo
|
276
|
+
image input of a graph or a mapping from the stream name to the image or
|
277
|
+
proto data that represents every input streams of a graph.
|
278
|
+
|
279
|
+
Raises:
|
280
|
+
NotImplementedError: If input_data contains audio data or a list of proto
|
281
|
+
objects.
|
282
|
+
RuntimeError: If the underlying graph occurs any error.
|
283
|
+
ValueError: If the input image data is not three channel RGB.
|
284
|
+
|
285
|
+
Returns:
|
286
|
+
A NamedTuple object that contains the output data of a graph run.
|
287
|
+
The field names in the NamedTuple object are mapping to the graph output
|
288
|
+
stream names.
|
289
|
+
|
290
|
+
Examples:
|
291
|
+
solution = solution_base.SolutionBase(graph_config=hand_landmark_graph)
|
292
|
+
results = solution.process(cv2.imread('/tmp/hand0.png')[:, :, ::-1])
|
293
|
+
print(results.detection)
|
294
|
+
results = solution.process(
|
295
|
+
{'video_in' : cv2.imread('/tmp/hand1.png')[:, :, ::-1]})
|
296
|
+
print(results.hand_landmarks)
|
297
|
+
"""
|
298
|
+
self._graph_outputs.clear()
|
299
|
+
|
300
|
+
if isinstance(input_data, np.ndarray):
|
301
|
+
if self._input_stream_type_info is None:
|
302
|
+
raise ValueError('_input_stream_type_info is None in SolutionBase')
|
303
|
+
if len(self._input_stream_type_info.keys()) != 1:
|
304
|
+
raise ValueError(
|
305
|
+
"Can't process single image input since the graph has more than one"
|
306
|
+
' input streams.'
|
307
|
+
)
|
308
|
+
input_dict = {next(iter(self._input_stream_type_info)): input_data}
|
309
|
+
else:
|
310
|
+
input_dict = input_data
|
311
|
+
|
312
|
+
# Set the timestamp increment to 33333 us to simulate the 30 fps video
|
313
|
+
# input.
|
314
|
+
self._simulated_timestamp += 33333
|
315
|
+
if self._graph is None:
|
316
|
+
raise ValueError('_graph is None in SolutionBase')
|
317
|
+
for stream_name, data in input_dict.items():
|
318
|
+
input_stream_type = self._input_stream_type_info[stream_name]
|
319
|
+
if (input_stream_type == PacketDataType.PROTO_LIST or
|
320
|
+
input_stream_type == PacketDataType.AUDIO):
|
321
|
+
# TODO: Support audio data.
|
322
|
+
raise NotImplementedError(
|
323
|
+
f'SolutionBase can only process non-audio and non-proto-list data. '
|
324
|
+
f'{self._input_stream_type_info[stream_name].name} '
|
325
|
+
f'type is not supported yet.')
|
326
|
+
elif (input_stream_type == PacketDataType.IMAGE_FRAME or
|
327
|
+
input_stream_type == PacketDataType.IMAGE):
|
328
|
+
if data.shape[2] != RGB_CHANNELS:
|
329
|
+
raise ValueError('Input image must contain three channel rgb data.')
|
330
|
+
self._graph.add_packet_to_input_stream(
|
331
|
+
stream=stream_name,
|
332
|
+
packet=self._make_packet(input_stream_type,
|
333
|
+
data).at(self._simulated_timestamp))
|
334
|
+
else:
|
335
|
+
self._graph.add_packet_to_input_stream(
|
336
|
+
stream=stream_name,
|
337
|
+
packet=self._make_packet(input_stream_type,
|
338
|
+
data).at(self._simulated_timestamp))
|
339
|
+
|
340
|
+
self._graph.wait_until_idle()
|
341
|
+
# Create a NamedTuple object where the field names are mapping to the graph
|
342
|
+
# output stream names.
|
343
|
+
if self._output_stream_type_info is None:
|
344
|
+
raise ValueError('_output_stream_type_info is None in SolutionBase')
|
345
|
+
solution_outputs = collections.namedtuple(
|
346
|
+
'SolutionOutputs', self._output_stream_type_info.keys())
|
347
|
+
for stream_name in self._output_stream_type_info.keys():
|
348
|
+
if stream_name in self._graph_outputs:
|
349
|
+
setattr(
|
350
|
+
solution_outputs, stream_name,
|
351
|
+
self._get_packet_content(self._output_stream_type_info[stream_name],
|
352
|
+
self._graph_outputs[stream_name]))
|
353
|
+
else:
|
354
|
+
setattr(solution_outputs, stream_name, None)
|
355
|
+
|
356
|
+
return solution_outputs
|
357
|
+
|
358
|
+
def close(self) -> None:
|
359
|
+
"""Closes all the input sources and the graph."""
|
360
|
+
if self._graph is None:
|
361
|
+
raise ValueError('Closing SolutionBase._graph which is already None')
|
362
|
+
self._graph.close()
|
363
|
+
self._graph = None
|
364
|
+
self._input_stream_type_info = None
|
365
|
+
self._output_stream_type_info = None
|
366
|
+
|
367
|
+
def reset(self) -> None:
|
368
|
+
"""Resets the graph for another run."""
|
369
|
+
if self._graph:
|
370
|
+
self._graph.close()
|
371
|
+
self._graph.start_run(self._input_side_packets)
|
372
|
+
|
373
|
+
def _initialize_graph_interface(
|
374
|
+
self,
|
375
|
+
validated_graph: validated_graph_config.ValidatedGraphConfig,
|
376
|
+
side_inputs: Optional[Mapping[str, Any]] = None,
|
377
|
+
outputs: Optional[List[str]] = None,
|
378
|
+
stream_type_hints: Optional[Mapping[str, PacketDataType]] = None):
|
379
|
+
"""Gets graph interface type information and returns the canonical graph config proto."""
|
380
|
+
|
381
|
+
canonical_graph_config_proto = calculator_pb2.CalculatorGraphConfig()
|
382
|
+
canonical_graph_config_proto.ParseFromString(validated_graph.binary_config)
|
383
|
+
|
384
|
+
# Gets name from a 'TAG:index:name' str.
|
385
|
+
def get_name(tag_index_name):
|
386
|
+
return tag_index_name.split(':')[-1]
|
387
|
+
|
388
|
+
# Gets the packet type information of the input streams and output streams
|
389
|
+
# from the user provided stream_type_hints field or validated calculator
|
390
|
+
# graph. The mappings from the stream names to the packet data types is
|
391
|
+
# for deciding which packet creator and getter methods to call in the
|
392
|
+
# process() method.
|
393
|
+
def get_stream_packet_type(packet_tag_index_name):
|
394
|
+
stream_name = get_name(packet_tag_index_name)
|
395
|
+
if stream_type_hints and stream_name in stream_type_hints.keys():
|
396
|
+
return stream_type_hints[stream_name]
|
397
|
+
return PacketDataType.from_registered_name(
|
398
|
+
validated_graph.registered_stream_type_name(stream_name))
|
399
|
+
|
400
|
+
self._input_stream_type_info = {
|
401
|
+
get_name(tag_index_name): get_stream_packet_type(tag_index_name)
|
402
|
+
for tag_index_name in canonical_graph_config_proto.input_stream
|
403
|
+
}
|
404
|
+
|
405
|
+
if not outputs:
|
406
|
+
output_streams = canonical_graph_config_proto.output_stream
|
407
|
+
else:
|
408
|
+
output_streams = outputs
|
409
|
+
self._output_stream_type_info = {
|
410
|
+
get_name(tag_index_name): get_stream_packet_type(tag_index_name)
|
411
|
+
for tag_index_name in output_streams
|
412
|
+
}
|
413
|
+
|
414
|
+
# Gets the packet type information of the input side packets from the
|
415
|
+
# validated calculator graph. The mappings from the side packet names to the
|
416
|
+
# packet data types is for making the input_side_packets dict for graph
|
417
|
+
# start_run().
|
418
|
+
def get_side_packet_type(packet_tag_index_name):
|
419
|
+
return PacketDataType.from_registered_name(
|
420
|
+
validated_graph.registered_side_packet_type_name(
|
421
|
+
get_name(packet_tag_index_name)))
|
422
|
+
|
423
|
+
self._side_input_type_info = {
|
424
|
+
get_name(tag_index_name): get_side_packet_type(tag_index_name)
|
425
|
+
for tag_index_name, _ in (side_inputs or {}).items()
|
426
|
+
}
|
427
|
+
return canonical_graph_config_proto
|
428
|
+
|
429
|
+
def _modify_calculator_options(
|
430
|
+
self, calculator_graph_config: calculator_pb2.CalculatorGraphConfig,
|
431
|
+
calculator_params: Mapping[str, Any]) -> None:
|
432
|
+
"""Modifies the CalculatorOptions of the calculators listed in calculator_params."""
|
433
|
+
|
434
|
+
# Reorganizes the calculator options field data by calculator name and puts
|
435
|
+
# all the field data of the same calculator in a list.
|
436
|
+
def generate_nested_calculator_params(flat_map):
|
437
|
+
nested_map = {}
|
438
|
+
for compound_name, field_value in flat_map.items():
|
439
|
+
calculator_and_field_name = compound_name.split('.')
|
440
|
+
if len(calculator_and_field_name) != 2:
|
441
|
+
raise ValueError(
|
442
|
+
f'The key "{compound_name}" in the calculator_params is invalid.')
|
443
|
+
calculator_name = calculator_and_field_name[0]
|
444
|
+
field_name = calculator_and_field_name[1]
|
445
|
+
if calculator_name in nested_map:
|
446
|
+
nested_map[calculator_name].append((field_name, field_value))
|
447
|
+
else:
|
448
|
+
nested_map[calculator_name] = [(field_name, field_value)]
|
449
|
+
return nested_map
|
450
|
+
|
451
|
+
def modify_options_fields(calculator_options, options_field_list):
|
452
|
+
for field_name, field_value in options_field_list:
|
453
|
+
if field_value is None:
|
454
|
+
calculator_options.ClearField(field_name)
|
455
|
+
else:
|
456
|
+
field_label = calculator_options.DESCRIPTOR.fields_by_name[
|
457
|
+
field_name].label
|
458
|
+
if field_label == descriptor.FieldDescriptor.LABEL_REPEATED:
|
459
|
+
if not isinstance(field_value, Iterable):
|
460
|
+
raise ValueError(
|
461
|
+
f'{field_name} is a repeated proto field but the value '
|
462
|
+
f'to be set is {type(field_value)}, which is not iterable.')
|
463
|
+
# TODO: Support resetting the entire repeated field
|
464
|
+
# (array-option) and changing the individual values in the repeated
|
465
|
+
# field (array-element-option).
|
466
|
+
calculator_options.ClearField(field_name)
|
467
|
+
for elem in field_value:
|
468
|
+
getattr(calculator_options, field_name).append(elem)
|
469
|
+
else:
|
470
|
+
setattr(calculator_options, field_name, field_value)
|
471
|
+
|
472
|
+
nested_calculator_params = generate_nested_calculator_params(
|
473
|
+
calculator_params)
|
474
|
+
|
475
|
+
num_modified = 0
|
476
|
+
for node in calculator_graph_config.node:
|
477
|
+
if node.name not in nested_calculator_params:
|
478
|
+
continue
|
479
|
+
options_type = CALCULATOR_TO_OPTIONS.get(node.calculator)
|
480
|
+
if options_type is None:
|
481
|
+
raise ValueError(
|
482
|
+
f'Modifying the calculator options of {node.name} is not supported.'
|
483
|
+
)
|
484
|
+
options_field_list = nested_calculator_params[node.name]
|
485
|
+
if node.HasField('options') and node.node_options:
|
486
|
+
raise ValueError(
|
487
|
+
f'Cannot modify the calculator options of {node.name} because it '
|
488
|
+
f'has both options and node_options fields.')
|
489
|
+
if node.node_options:
|
490
|
+
# The "node_options" case for the proto3 syntax.
|
491
|
+
node_options_modified = False
|
492
|
+
for elem in node.node_options:
|
493
|
+
type_name = elem.type_url.split('/')[-1]
|
494
|
+
if type_name == options_type.DESCRIPTOR.full_name:
|
495
|
+
calculator_options = options_type.FromString(elem.value)
|
496
|
+
modify_options_fields(calculator_options, options_field_list)
|
497
|
+
elem.value = calculator_options.SerializeToString()
|
498
|
+
node_options_modified = True
|
499
|
+
break
|
500
|
+
# There is no existing node_options being modified. Add a new
|
501
|
+
# node_options instead.
|
502
|
+
if not node_options_modified:
|
503
|
+
calculator_options = options_type()
|
504
|
+
modify_options_fields(calculator_options, options_field_list)
|
505
|
+
node.node_options.add().Pack(calculator_options)
|
506
|
+
else:
|
507
|
+
# The "options" case for the proto2 syntax as well as the fallback
|
508
|
+
# when the calculator doesn't have either "options" or "node_options".
|
509
|
+
modify_options_fields(node.options.Extensions[options_type.ext],
|
510
|
+
options_field_list)
|
511
|
+
|
512
|
+
num_modified += 1
|
513
|
+
# Exits the loop early when every elements in nested_calculator_params
|
514
|
+
# have been visited.
|
515
|
+
if num_modified == len(nested_calculator_params):
|
516
|
+
break
|
517
|
+
if num_modified < len(nested_calculator_params):
|
518
|
+
raise ValueError('Not all calculator params are valid.')
|
519
|
+
|
520
|
+
def create_graph_options(self, options_message: message.Message,
|
521
|
+
values: Mapping[str, Any]) -> message.Message:
|
522
|
+
"""Sets protobuf field values.
|
523
|
+
|
524
|
+
Args:
|
525
|
+
options_message: the options protobuf message.
|
526
|
+
values: field value pairs, where each field may be a "." separated path.
|
527
|
+
|
528
|
+
Returns:
|
529
|
+
the options protobuf message.
|
530
|
+
"""
|
531
|
+
|
532
|
+
if hasattr(values, 'items'):
|
533
|
+
values = values.items()
|
534
|
+
for pair in values:
|
535
|
+
(field, value) = pair
|
536
|
+
fields = field.split('.')
|
537
|
+
m = options_message
|
538
|
+
while len(fields) > 1:
|
539
|
+
m = getattr(m, fields[0])
|
540
|
+
del fields[0]
|
541
|
+
v = getattr(m, fields[0])
|
542
|
+
if hasattr(v, 'append'):
|
543
|
+
del v[:]
|
544
|
+
v.extend(value)
|
545
|
+
elif hasattr(v, 'CopyFrom'):
|
546
|
+
v.CopyFrom(value)
|
547
|
+
else:
|
548
|
+
setattr(m, fields[0], value)
|
549
|
+
return options_message
|
550
|
+
|
551
|
+
def _set_extension(self,
|
552
|
+
extension_list: containers.RepeatedCompositeFieldContainer,
|
553
|
+
extension_value: message.Message) -> None:
|
554
|
+
"""Sets one value in a repeated protobuf.Any extension field."""
|
555
|
+
for extension_any in extension_list:
|
556
|
+
if extension_any.Is(extension_value.DESCRIPTOR):
|
557
|
+
v = type(extension_value)()
|
558
|
+
extension_any.Unpack(v)
|
559
|
+
v.MergeFrom(extension_value)
|
560
|
+
extension_any.Pack(v)
|
561
|
+
return
|
562
|
+
extension_list.add().Pack(extension_value)
|
563
|
+
|
564
|
+
def _make_packet(self, packet_data_type: PacketDataType,
|
565
|
+
data: Any) -> packet.Packet:
|
566
|
+
if (packet_data_type == PacketDataType.IMAGE_FRAME or
|
567
|
+
packet_data_type == PacketDataType.IMAGE):
|
568
|
+
return getattr(packet_creator, 'create_' + packet_data_type.value)(
|
569
|
+
data, image_format=image_frame.ImageFormat.SRGB)
|
570
|
+
else:
|
571
|
+
return getattr(packet_creator, 'create_' + packet_data_type.value)(data)
|
572
|
+
|
573
|
+
def _get_packet_content(self, packet_data_type: PacketDataType,
|
574
|
+
output_packet: packet.Packet) -> Any:
|
575
|
+
"""Gets packet content from a packet by type.
|
576
|
+
|
577
|
+
Args:
|
578
|
+
packet_data_type: The supported packet data type.
|
579
|
+
output_packet: The packet to get content from.
|
580
|
+
|
581
|
+
Returns:
|
582
|
+
Packet content by packet data type. None to indicate "no output".
|
583
|
+
|
584
|
+
"""
|
585
|
+
|
586
|
+
if output_packet.is_empty():
|
587
|
+
return None
|
588
|
+
if packet_data_type == PacketDataType.STRING:
|
589
|
+
return packet_getter.get_str(output_packet)
|
590
|
+
elif (packet_data_type == PacketDataType.IMAGE_FRAME or
|
591
|
+
packet_data_type == PacketDataType.IMAGE):
|
592
|
+
return getattr(packet_getter, 'get_' +
|
593
|
+
packet_data_type.value)(output_packet).numpy_view()
|
594
|
+
else:
|
595
|
+
return getattr(packet_getter, 'get_' + packet_data_type.value)(
|
596
|
+
output_packet)
|
597
|
+
|
598
|
+
def __enter__(self):
|
599
|
+
"""A "with" statement support."""
|
600
|
+
return self
|
601
|
+
|
602
|
+
def __exit__(self, exc_type, exc_val, exc_tb):
|
603
|
+
"""Closes all the input sources and the graph."""
|
604
|
+
self.close()
|