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,121 @@
|
|
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
|
+
"""Base options for MediaPipe Task APIs."""
|
15
|
+
|
16
|
+
import dataclasses
|
17
|
+
import enum
|
18
|
+
import os
|
19
|
+
import platform
|
20
|
+
from typing import Any, Optional
|
21
|
+
|
22
|
+
from mediapipe.calculators.tensor import inference_calculator_pb2
|
23
|
+
from mediapipe.tasks.cc.core.proto import acceleration_pb2
|
24
|
+
from mediapipe.tasks.cc.core.proto import base_options_pb2
|
25
|
+
from mediapipe.tasks.cc.core.proto import external_file_pb2
|
26
|
+
from mediapipe.tasks.python.core.optional_dependencies import doc_controls
|
27
|
+
|
28
|
+
_DelegateProto = inference_calculator_pb2.InferenceCalculatorOptions.Delegate
|
29
|
+
_AccelerationProto = acceleration_pb2.Acceleration
|
30
|
+
_BaseOptionsProto = base_options_pb2.BaseOptions
|
31
|
+
_ExternalFileProto = external_file_pb2.ExternalFile
|
32
|
+
|
33
|
+
|
34
|
+
@dataclasses.dataclass
|
35
|
+
class BaseOptions:
|
36
|
+
"""Base options for MediaPipe Tasks' Python APIs.
|
37
|
+
|
38
|
+
Represents external model asset used by the Task APIs. The files can be
|
39
|
+
specified by one of the following two ways:
|
40
|
+
|
41
|
+
(1) model asset file path in `model_asset_path`.
|
42
|
+
(2) model asset contents loaded in `model_asset_buffer`.
|
43
|
+
|
44
|
+
If more than one field of these fields is provided, they are used in this
|
45
|
+
precedence order.
|
46
|
+
|
47
|
+
Attributes:
|
48
|
+
model_asset_path: Path to the model asset file.
|
49
|
+
model_asset_buffer: The model asset file contents as bytes.
|
50
|
+
delegate: Acceleration to use. Supported values are GPU and CPU. GPU support
|
51
|
+
is currently limited to Ubuntu platforms.
|
52
|
+
"""
|
53
|
+
|
54
|
+
class Delegate(enum.IntEnum):
|
55
|
+
CPU = 0
|
56
|
+
GPU = 1
|
57
|
+
|
58
|
+
model_asset_path: Optional[str] = None
|
59
|
+
model_asset_buffer: Optional[bytes] = None
|
60
|
+
delegate: Optional[Delegate] = None
|
61
|
+
|
62
|
+
@doc_controls.do_not_generate_docs
|
63
|
+
def to_pb2(self) -> _BaseOptionsProto:
|
64
|
+
"""Generates a BaseOptions protobuf object."""
|
65
|
+
if self.model_asset_path is not None:
|
66
|
+
full_path = os.path.abspath(self.model_asset_path)
|
67
|
+
else:
|
68
|
+
full_path = None
|
69
|
+
|
70
|
+
platform_name = platform.system()
|
71
|
+
|
72
|
+
if self.delegate == BaseOptions.Delegate.GPU:
|
73
|
+
if platform_name in ['Linux', 'Darwin']:
|
74
|
+
acceleration_proto = _AccelerationProto(gpu=_DelegateProto.Gpu())
|
75
|
+
else:
|
76
|
+
raise NotImplementedError(
|
77
|
+
'GPU Delegate is not yet supported for ' + platform_name
|
78
|
+
)
|
79
|
+
elif self.delegate == BaseOptions.Delegate.CPU:
|
80
|
+
acceleration_proto = _AccelerationProto(tflite=_DelegateProto.TfLite())
|
81
|
+
else:
|
82
|
+
acceleration_proto = None
|
83
|
+
|
84
|
+
return _BaseOptionsProto(
|
85
|
+
model_asset=_ExternalFileProto(
|
86
|
+
file_name=full_path, file_content=self.model_asset_buffer
|
87
|
+
),
|
88
|
+
acceleration=acceleration_proto,
|
89
|
+
)
|
90
|
+
|
91
|
+
@classmethod
|
92
|
+
@doc_controls.do_not_generate_docs
|
93
|
+
def create_from_pb2(cls, pb2_obj: _BaseOptionsProto) -> 'BaseOptions':
|
94
|
+
"""Creates a `BaseOptions` object from the given protobuf object."""
|
95
|
+
delegate = None
|
96
|
+
if pb2_obj.acceleration is not None:
|
97
|
+
delegate = (
|
98
|
+
BaseOptions.Delegate.GPU
|
99
|
+
if pb2_obj.acceleration.gpu is not None
|
100
|
+
else BaseOptions.Delegate.CPU
|
101
|
+
)
|
102
|
+
|
103
|
+
return BaseOptions(
|
104
|
+
model_asset_path=pb2_obj.model_asset.file_name,
|
105
|
+
model_asset_buffer=pb2_obj.model_asset.file_content,
|
106
|
+
delegate=delegate,
|
107
|
+
)
|
108
|
+
|
109
|
+
def __eq__(self, other: Any) -> bool:
|
110
|
+
"""Checks if this object is equal to the given object.
|
111
|
+
|
112
|
+
Args:
|
113
|
+
other: The object to be compared with.
|
114
|
+
|
115
|
+
Returns:
|
116
|
+
True if the objects are equal.
|
117
|
+
"""
|
118
|
+
if not isinstance(other, BaseOptions):
|
119
|
+
return False
|
120
|
+
|
121
|
+
return self.to_pb2().__eq__(other.to_pb2())
|
@@ -0,0 +1,25 @@
|
|
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
|
+
"""MediaPipe Tasks' common but optional dependencies."""
|
15
|
+
|
16
|
+
# TensorFlow isn't a dependency of mediapipe pip package. It's only
|
17
|
+
# required in the API docgen pipeline so we'll ignore it if tensorflow is not
|
18
|
+
# installed.
|
19
|
+
try:
|
20
|
+
from tensorflow.tools.docs import doc_controls
|
21
|
+
except ModuleNotFoundError:
|
22
|
+
# Replace the real doc_controls.do_not_generate_docs with an no-op
|
23
|
+
doc_controls = lambda: None
|
24
|
+
no_op = lambda x: x
|
25
|
+
setattr(doc_controls, 'do_not_generate_docs', no_op)
|
@@ -0,0 +1,139 @@
|
|
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
|
+
"""MediaPipe Tasks' task info data class."""
|
15
|
+
|
16
|
+
import dataclasses
|
17
|
+
from typing import Any, List
|
18
|
+
from google.protobuf import any_pb2
|
19
|
+
from mediapipe.calculators.core import flow_limiter_calculator_pb2
|
20
|
+
from mediapipe.framework import calculator_options_pb2
|
21
|
+
from mediapipe.framework import calculator_pb2
|
22
|
+
from mediapipe.tasks.python.core.optional_dependencies import doc_controls
|
23
|
+
|
24
|
+
|
25
|
+
@doc_controls.do_not_generate_docs
|
26
|
+
@dataclasses.dataclass
|
27
|
+
class TaskInfo:
|
28
|
+
"""Specifications of a MediaPipe task graph.
|
29
|
+
|
30
|
+
Attributes:
|
31
|
+
task_graph: The MediaPipe task graph name.
|
32
|
+
input_streams: The list of graph input stream info strings in the form
|
33
|
+
TAG:name.
|
34
|
+
output_streams: The list of graph output stream info strings in the form
|
35
|
+
TAG:name.
|
36
|
+
task_options: The task-specific options object that can be converted to a
|
37
|
+
protobuf object.
|
38
|
+
"""
|
39
|
+
task_graph: str
|
40
|
+
input_streams: List[str]
|
41
|
+
output_streams: List[str]
|
42
|
+
task_options: Any
|
43
|
+
|
44
|
+
def generate_graph_config(
|
45
|
+
self,
|
46
|
+
enable_flow_limiting: bool = False
|
47
|
+
) -> calculator_pb2.CalculatorGraphConfig:
|
48
|
+
"""Generates a MediaPipe Task CalculatorGraphConfig proto from TaskInfo.
|
49
|
+
|
50
|
+
Args:
|
51
|
+
enable_flow_limiting: Whether to add a flow limiter calculator into the
|
52
|
+
graph config to lower the overall graph latency for live streaming use
|
53
|
+
case.
|
54
|
+
|
55
|
+
Raises:
|
56
|
+
ValueError: Any required data fields (namely, `task_graph`,
|
57
|
+
`task_options`, `input_streams`, and `output_streams`) is not
|
58
|
+
specified or `task_options` is not able to be converted to a protobuf
|
59
|
+
object.
|
60
|
+
|
61
|
+
Returns:
|
62
|
+
A CalculatorGraphConfig proto of the task graph.
|
63
|
+
"""
|
64
|
+
|
65
|
+
def strip_tag_index(tag_index_name):
|
66
|
+
return tag_index_name.split(':')[-1]
|
67
|
+
|
68
|
+
def add_stream_name_prefix(tag_index_name):
|
69
|
+
splitted = tag_index_name.split(':')
|
70
|
+
splitted[-1] = 'throttled_' + splitted[-1]
|
71
|
+
return ':'.join(splitted)
|
72
|
+
|
73
|
+
if not self.task_graph or not self.task_options:
|
74
|
+
raise ValueError('Please provide both `task_graph` and `task_options`.')
|
75
|
+
if not self.input_streams or not self.output_streams:
|
76
|
+
raise ValueError(
|
77
|
+
'Both `input_streams` and `output_streams` must be non-empty.')
|
78
|
+
if not hasattr(self.task_options, 'to_pb2'):
|
79
|
+
raise ValueError(
|
80
|
+
'`task_options` doesn`t provide `to_pb2()` method to convert itself to be a protobuf object.'
|
81
|
+
)
|
82
|
+
|
83
|
+
task_options_proto = self.task_options.to_pb2()
|
84
|
+
|
85
|
+
node_config = calculator_pb2.CalculatorGraphConfig.Node(
|
86
|
+
calculator=self.task_graph,
|
87
|
+
input_stream=self.input_streams,
|
88
|
+
output_stream=self.output_streams,
|
89
|
+
)
|
90
|
+
|
91
|
+
if hasattr(task_options_proto, 'ext'):
|
92
|
+
# Use the extension mechanism for task_subgraph_options (proto2)
|
93
|
+
task_subgraph_options = calculator_options_pb2.CalculatorOptions()
|
94
|
+
task_subgraph_options.Extensions[task_options_proto.ext].CopyFrom(
|
95
|
+
task_options_proto
|
96
|
+
)
|
97
|
+
node_config.options.CopyFrom(task_subgraph_options)
|
98
|
+
else:
|
99
|
+
# Use the Any type for task_subgraph_options (proto3)
|
100
|
+
task_subgraph_options = any_pb2.Any()
|
101
|
+
task_subgraph_options.Pack(self.task_options.to_pb2())
|
102
|
+
node_config.node_options.append(task_subgraph_options)
|
103
|
+
|
104
|
+
if not enable_flow_limiting:
|
105
|
+
return calculator_pb2.CalculatorGraphConfig(
|
106
|
+
node=[node_config],
|
107
|
+
input_stream=self.input_streams,
|
108
|
+
output_stream=self.output_streams,
|
109
|
+
)
|
110
|
+
# When a FlowLimiterCalculator is inserted to lower the overall graph
|
111
|
+
# latency, the task doesn't guarantee that each input must have the
|
112
|
+
# corresponding output.
|
113
|
+
task_subgraph_inputs = [
|
114
|
+
add_stream_name_prefix(stream) for stream in self.input_streams
|
115
|
+
]
|
116
|
+
finished_stream = 'FINISHED:' + strip_tag_index(self.output_streams[0])
|
117
|
+
flow_limiter_options = calculator_options_pb2.CalculatorOptions()
|
118
|
+
flow_limiter_options.Extensions[
|
119
|
+
flow_limiter_calculator_pb2.FlowLimiterCalculatorOptions.ext].CopyFrom(
|
120
|
+
flow_limiter_calculator_pb2.FlowLimiterCalculatorOptions(
|
121
|
+
max_in_flight=1, max_in_queue=1))
|
122
|
+
flow_limiter = calculator_pb2.CalculatorGraphConfig.Node(
|
123
|
+
calculator='FlowLimiterCalculator',
|
124
|
+
input_stream_info=[
|
125
|
+
calculator_pb2.InputStreamInfo(
|
126
|
+
tag_index='FINISHED', back_edge=True)
|
127
|
+
],
|
128
|
+
input_stream=[strip_tag_index(stream) for stream in self.input_streams]
|
129
|
+
+ [finished_stream],
|
130
|
+
output_stream=[
|
131
|
+
strip_tag_index(stream) for stream in task_subgraph_inputs
|
132
|
+
],
|
133
|
+
options=flow_limiter_options)
|
134
|
+
config = calculator_pb2.CalculatorGraphConfig(
|
135
|
+
node=[node_config, flow_limiter],
|
136
|
+
input_stream=self.input_streams,
|
137
|
+
output_stream=self.output_streams,
|
138
|
+
)
|
139
|
+
return config
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Copyright 2024 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 GenAI Python API."""
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Copyright 2024 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
|
+
"""MediaPipe Tasks GenAI Bundler API."""
|
16
|
+
|
17
|
+
import mediapipe.tasks.python.genai.bundler.llm_bundler
|
18
|
+
|
19
|
+
BundleConfig = llm_bundler.BundleConfig
|
20
|
+
create_bundle = llm_bundler.create_bundle
|
21
|
+
|
22
|
+
# Remove unnecessary modules to avoid duplication in API docs.
|
23
|
+
del llm_bundler
|
@@ -0,0 +1,130 @@
|
|
1
|
+
# Copyright 2024 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
|
+
"""Functions to perform llm packing."""
|
16
|
+
|
17
|
+
import dataclasses
|
18
|
+
import enum
|
19
|
+
from typing import List, Optional
|
20
|
+
|
21
|
+
from mediapipe.tasks.python.metadata.metadata_writers import model_asset_bundle_utils
|
22
|
+
from mediapipe.tasks.cc.genai.inference.proto import llm_params_pb2
|
23
|
+
import sentencepiece
|
24
|
+
|
25
|
+
|
26
|
+
@dataclasses.dataclass(frozen=True)
|
27
|
+
class BundleConfig:
|
28
|
+
"""Config for LLM Bundler.
|
29
|
+
|
30
|
+
Attributes:
|
31
|
+
tflite_model: Path to the multi-signature tflite model with "prefill" and
|
32
|
+
"decode" signatures converted using ODML Transformers APIs.
|
33
|
+
tokenizer_model: Path to the tokenizer model. Currently only SentencePience
|
34
|
+
tokenizer is supported. As such, tokenizer.model proto is expected to be
|
35
|
+
passed here.
|
36
|
+
start_token: Token that will be used to signify the beginning of a sequence.
|
37
|
+
stop_tokens: Tokens that will be used to signify the end of a sequence.
|
38
|
+
output_filename: Name of the generated `.task` file containing the Bundle.
|
39
|
+
enable_bytes_to_unicode_mapping: Enables GPT-2 style bytes to unicode
|
40
|
+
mapping. For more details see:
|
41
|
+
https://github.com/openai/gpt-2/blob/master/src/encoder.py#L9
|
42
|
+
system_prompt: The starting text would be feed to the model on the start of
|
43
|
+
each session, commonly called the System prompt. This is useful for
|
44
|
+
instruction tuned models and pre-conditioning the model behavior.
|
45
|
+
prompt_prefix: The prefix that will be added to each prompt passed to the
|
46
|
+
model.
|
47
|
+
prompt_suffix: The suffix that will be added to at the end of user prompt
|
48
|
+
just before generating the response.
|
49
|
+
"""
|
50
|
+
|
51
|
+
tflite_model: str
|
52
|
+
tokenizer_model: str
|
53
|
+
start_token: str
|
54
|
+
stop_tokens: List[str]
|
55
|
+
output_filename: str
|
56
|
+
enable_bytes_to_unicode_mapping: bool = False
|
57
|
+
system_prompt: Optional[str] = None
|
58
|
+
prompt_prefix: Optional[str] = None
|
59
|
+
prompt_suffix: Optional[str] = None
|
60
|
+
|
61
|
+
|
62
|
+
class _BundleTags(enum.Enum):
|
63
|
+
"""Bundle tags."""
|
64
|
+
|
65
|
+
TF_LITE_PREFILL_DECODE = 1
|
66
|
+
TOKENIZER_MODEL = 2
|
67
|
+
METADATA = 3
|
68
|
+
|
69
|
+
|
70
|
+
def _validate_config(config: BundleConfig):
|
71
|
+
"""Validates the given config.
|
72
|
+
|
73
|
+
Args:
|
74
|
+
config: The config to validate.
|
75
|
+
|
76
|
+
Raises:
|
77
|
+
ValueError if the config is invalid. Invalid configs can be:
|
78
|
+
- tokenizer_model is not a valid SentencePiece model.
|
79
|
+
- start_token is not a valid token in the tokenizer_model.
|
80
|
+
- stop_tokens is not a list of valid tokens in the tokenizer_model.
|
81
|
+
"""
|
82
|
+
if not isinstance(config.stop_tokens, list):
|
83
|
+
raise ValueError("stop_tokens must be a list of strings.")
|
84
|
+
if not config.stop_tokens:
|
85
|
+
raise ValueError("stop_tokens must be non-empty.")
|
86
|
+
|
87
|
+
try:
|
88
|
+
sp = sentencepiece.SentencePieceProcessor()
|
89
|
+
sp.Load(config.tokenizer_model)
|
90
|
+
except Exception as e:
|
91
|
+
raise ValueError(
|
92
|
+
f"Failed to load tokenizer model from {config.tokenizer_model}. "
|
93
|
+
"Please ensure you are passing a valid SentencePiece model."
|
94
|
+
) from e
|
95
|
+
|
96
|
+
|
97
|
+
def create_bundle(config: BundleConfig):
|
98
|
+
"""Creates a bundle from the given config."""
|
99
|
+
_validate_config(config)
|
100
|
+
|
101
|
+
artifacts = {}
|
102
|
+
with open(config.tflite_model, "rb") as f:
|
103
|
+
artifacts[_BundleTags.TF_LITE_PREFILL_DECODE.name] = f.read()
|
104
|
+
|
105
|
+
with open(config.tokenizer_model, "rb") as f:
|
106
|
+
artifacts[_BundleTags.TOKENIZER_MODEL.name] = f.read()
|
107
|
+
|
108
|
+
params = llm_params_pb2.LlmParameters()
|
109
|
+
params.start_token = config.start_token
|
110
|
+
params.stop_tokens.extend(config.stop_tokens)
|
111
|
+
if config.enable_bytes_to_unicode_mapping:
|
112
|
+
params.input_output_normalizations.append(
|
113
|
+
llm_params_pb2.LlmParameters.INPUT_OUTPUT_NORMALIZATION_BYTES_TO_UNICODE
|
114
|
+
)
|
115
|
+
if config.system_prompt:
|
116
|
+
params.prompt_template.session_prefix = config.system_prompt
|
117
|
+
if config.prompt_prefix:
|
118
|
+
params.prompt_template.prompt_prefix = config.prompt_prefix
|
119
|
+
if config.prompt_suffix:
|
120
|
+
params.prompt_template.prompt_suffix = config.prompt_suffix
|
121
|
+
artifacts[_BundleTags.METADATA.name] = params.SerializeToString()
|
122
|
+
|
123
|
+
output_filename = config.output_filename
|
124
|
+
if not output_filename.endswith(".task"):
|
125
|
+
output_filename = config.output_filename + ".task"
|
126
|
+
|
127
|
+
model_asset_bundle_utils.create_model_asset_bundle(
|
128
|
+
artifacts,
|
129
|
+
output_filename,
|
130
|
+
)
|
@@ -0,0 +1,168 @@
|
|
1
|
+
# Copyright 2024 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
|
+
import os
|
16
|
+
import string
|
17
|
+
import zipfile
|
18
|
+
|
19
|
+
from absl.testing import absltest
|
20
|
+
|
21
|
+
from mediapipe.tasks.python.genai.bundler import llm_bundler
|
22
|
+
from sentencepiece import sentencepiece_model_pb2
|
23
|
+
|
24
|
+
|
25
|
+
class LlmBundlerTest(absltest.TestCase):
|
26
|
+
|
27
|
+
BOS = "[BOS]"
|
28
|
+
EOS = "[EOS]"
|
29
|
+
|
30
|
+
def _create_sp_model(self, out_dir: str, corrupt: bool = False) -> str:
|
31
|
+
"""Helper function to create test SentencePiece model."""
|
32
|
+
sp_file_path = os.path.join(out_dir, "sp.model")
|
33
|
+
if corrupt:
|
34
|
+
with open(sp_file_path, "w") as f:
|
35
|
+
f.write("sp_model")
|
36
|
+
return sp_file_path
|
37
|
+
|
38
|
+
model = sentencepiece_model_pb2.ModelProto()
|
39
|
+
# Add an unk token.
|
40
|
+
model.pieces.add(
|
41
|
+
piece="<unk>",
|
42
|
+
score=0.0,
|
43
|
+
type=sentencepiece_model_pb2.ModelProto.SentencePiece.UNKNOWN,
|
44
|
+
)
|
45
|
+
# BOS and EOS are special control tokens.
|
46
|
+
model.pieces.add(
|
47
|
+
piece=self.BOS,
|
48
|
+
score=0.0,
|
49
|
+
type=sentencepiece_model_pb2.ModelProto.SentencePiece.CONTROL,
|
50
|
+
)
|
51
|
+
model.pieces.add(
|
52
|
+
piece=self.EOS,
|
53
|
+
score=0.0,
|
54
|
+
type=sentencepiece_model_pb2.ModelProto.SentencePiece.CONTROL,
|
55
|
+
)
|
56
|
+
# Add a few user defined tokens.
|
57
|
+
model.pieces.add(
|
58
|
+
piece="[INST]",
|
59
|
+
score=0.0,
|
60
|
+
type=sentencepiece_model_pb2.ModelProto.SentencePiece.USER_DEFINED,
|
61
|
+
)
|
62
|
+
model.pieces.add(
|
63
|
+
piece="[/INST]",
|
64
|
+
score=0.0,
|
65
|
+
type=sentencepiece_model_pb2.ModelProto.SentencePiece.USER_DEFINED,
|
66
|
+
)
|
67
|
+
model.pieces.add(
|
68
|
+
piece="[SYS_S]",
|
69
|
+
score=0.0,
|
70
|
+
type=sentencepiece_model_pb2.ModelProto.SentencePiece.USER_DEFINED,
|
71
|
+
)
|
72
|
+
model.pieces.add(
|
73
|
+
piece="[SYS_E]",
|
74
|
+
score=0.0,
|
75
|
+
type=sentencepiece_model_pb2.ModelProto.SentencePiece.USER_DEFINED,
|
76
|
+
)
|
77
|
+
# Add the rest of the alphabet as tokens
|
78
|
+
for letter in string.ascii_lowercase + string.ascii_uppercase:
|
79
|
+
model.pieces.add(
|
80
|
+
piece=letter,
|
81
|
+
score=0.0,
|
82
|
+
type=sentencepiece_model_pb2.ModelProto.SentencePiece.NORMAL,
|
83
|
+
)
|
84
|
+
|
85
|
+
model.normalizer_spec.add_dummy_prefix = False
|
86
|
+
|
87
|
+
with open(sp_file_path, "wb") as f:
|
88
|
+
f.write(model.SerializeToString())
|
89
|
+
return sp_file_path
|
90
|
+
|
91
|
+
def _create_tflite_model(self, out_dir: str) -> str:
|
92
|
+
"""Helper function to create test tflite model."""
|
93
|
+
tflite_file_path = os.path.join(out_dir, "test.tflite")
|
94
|
+
with open(tflite_file_path, "w") as f:
|
95
|
+
f.write("tflite_model")
|
96
|
+
return tflite_file_path
|
97
|
+
|
98
|
+
def test_can_create_bundle(self):
|
99
|
+
tempdir = self.create_tempdir()
|
100
|
+
sp_file_path = self._create_sp_model(tempdir.full_path)
|
101
|
+
tflite_file_path = self._create_tflite_model(tempdir.full_path)
|
102
|
+
output_file = os.path.join(tempdir, "test.task")
|
103
|
+
config = llm_bundler.BundleConfig(
|
104
|
+
tflite_model=tflite_file_path,
|
105
|
+
tokenizer_model=sp_file_path,
|
106
|
+
start_token=self.BOS,
|
107
|
+
stop_tokens=[self.EOS],
|
108
|
+
output_filename=output_file,
|
109
|
+
enable_bytes_to_unicode_mapping=True,
|
110
|
+
prompt_prefix="<start_of_turn>user\n ",
|
111
|
+
prompt_suffix="<end_of_turn>\n<start_of_turn>model\n",
|
112
|
+
)
|
113
|
+
llm_bundler.create_bundle(config)
|
114
|
+
self.assertTrue(os.path.exists(output_file))
|
115
|
+
with zipfile.ZipFile(output_file) as zip_file:
|
116
|
+
self.assertLen(zip_file.filelist, 3)
|
117
|
+
self.assertEqual(zip_file.filelist[0].filename, "TF_LITE_PREFILL_DECODE")
|
118
|
+
self.assertEqual(zip_file.filelist[1].filename, "TOKENIZER_MODEL")
|
119
|
+
self.assertEqual(zip_file.filelist[2].filename, "METADATA")
|
120
|
+
|
121
|
+
def test_invalid_stop_tokens_raises_value_error(self):
|
122
|
+
tempdir = self.create_tempdir()
|
123
|
+
sp_file_path = self._create_sp_model(tempdir.full_path)
|
124
|
+
tflite_file_path = self._create_tflite_model(tempdir.full_path)
|
125
|
+
output_file = os.path.join(tempdir, "test.task")
|
126
|
+
config = llm_bundler.BundleConfig(
|
127
|
+
tflite_model=tflite_file_path,
|
128
|
+
tokenizer_model=sp_file_path,
|
129
|
+
start_token=self.BOS,
|
130
|
+
stop_tokens=self.EOS,
|
131
|
+
output_filename=output_file,
|
132
|
+
)
|
133
|
+
with self.assertRaisesRegex(
|
134
|
+
ValueError, "stop_tokens must be a list of strings"
|
135
|
+
):
|
136
|
+
llm_bundler.create_bundle(config)
|
137
|
+
|
138
|
+
config = llm_bundler.BundleConfig(
|
139
|
+
tflite_model=tflite_file_path,
|
140
|
+
tokenizer_model=sp_file_path,
|
141
|
+
start_token=self.BOS,
|
142
|
+
stop_tokens=[],
|
143
|
+
output_filename=output_file,
|
144
|
+
)
|
145
|
+
with self.assertRaisesRegex(ValueError, "stop_tokens must be non-empty"):
|
146
|
+
llm_bundler.create_bundle(config)
|
147
|
+
|
148
|
+
def test_invalid_tokenizer_model_raises_value_error(self):
|
149
|
+
tempdir = self.create_tempdir()
|
150
|
+
sp_file_path = self._create_sp_model(tempdir.full_path, corrupt=True)
|
151
|
+
tflite_file_path = self._create_tflite_model(tempdir.full_path)
|
152
|
+
output_file = os.path.join(tempdir, "test.task")
|
153
|
+
config = llm_bundler.BundleConfig(
|
154
|
+
tflite_model=tflite_file_path,
|
155
|
+
tokenizer_model=sp_file_path,
|
156
|
+
start_token=self.BOS,
|
157
|
+
stop_tokens=[self.EOS],
|
158
|
+
output_filename=output_file,
|
159
|
+
)
|
160
|
+
with self.assertRaisesRegex(
|
161
|
+
ValueError,
|
162
|
+
"Failed to load tokenizer model from",
|
163
|
+
):
|
164
|
+
llm_bundler.create_bundle(config)
|
165
|
+
|
166
|
+
|
167
|
+
if __name__ == "__main__":
|
168
|
+
absltest.main()
|
@@ -0,0 +1,24 @@
|
|
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
|
+
"""MediaPipe Tasks GenAI Converter API."""
|
16
|
+
|
17
|
+
import mediapipe.tasks.python.genai.converter.llm_converter
|
18
|
+
|
19
|
+
ConversionConfig = llm_converter.ConversionConfig
|
20
|
+
convert_checkpoint = llm_converter.convert_checkpoint
|
21
|
+
|
22
|
+
# Remove unnecessary modules to avoid duplication in API docs.
|
23
|
+
del mediapipe
|
24
|
+
del llm_converter
|