mediapipe-nightly 0.10.21.post20250114__cp311-cp311-manylinux_2_28_x86_64.whl

Sign up to get free protection for your applications and to get access to all the features.
Files changed (593) hide show
  1. mediapipe/__init__.py +26 -0
  2. mediapipe/calculators/__init__.py +0 -0
  3. mediapipe/calculators/audio/__init__.py +0 -0
  4. mediapipe/calculators/audio/mfcc_mel_calculators_pb2.py +33 -0
  5. mediapipe/calculators/audio/rational_factor_resample_calculator_pb2.py +33 -0
  6. mediapipe/calculators/audio/spectrogram_calculator_pb2.py +37 -0
  7. mediapipe/calculators/audio/stabilized_log_calculator_pb2.py +31 -0
  8. mediapipe/calculators/audio/time_series_framer_calculator_pb2.py +33 -0
  9. mediapipe/calculators/core/__init__.py +0 -0
  10. mediapipe/calculators/core/bypass_calculator_pb2.py +31 -0
  11. mediapipe/calculators/core/clip_vector_size_calculator_pb2.py +31 -0
  12. mediapipe/calculators/core/concatenate_vector_calculator_pb2.py +31 -0
  13. mediapipe/calculators/core/constant_side_packet_calculator_pb2.py +39 -0
  14. mediapipe/calculators/core/dequantize_byte_array_calculator_pb2.py +31 -0
  15. mediapipe/calculators/core/flow_limiter_calculator_pb2.py +32 -0
  16. mediapipe/calculators/core/gate_calculator_pb2.py +33 -0
  17. mediapipe/calculators/core/get_vector_item_calculator_pb2.py +31 -0
  18. mediapipe/calculators/core/graph_profile_calculator_pb2.py +31 -0
  19. mediapipe/calculators/core/packet_cloner_calculator_pb2.py +31 -0
  20. mediapipe/calculators/core/packet_resampler_calculator_pb2.py +33 -0
  21. mediapipe/calculators/core/packet_thinner_calculator_pb2.py +33 -0
  22. mediapipe/calculators/core/quantize_float_vector_calculator_pb2.py +31 -0
  23. mediapipe/calculators/core/sequence_shift_calculator_pb2.py +31 -0
  24. mediapipe/calculators/core/split_vector_calculator_pb2.py +33 -0
  25. mediapipe/calculators/image/__init__.py +0 -0
  26. mediapipe/calculators/image/bilateral_filter_calculator_pb2.py +31 -0
  27. mediapipe/calculators/image/feature_detector_calculator_pb2.py +31 -0
  28. mediapipe/calculators/image/image_clone_calculator_pb2.py +31 -0
  29. mediapipe/calculators/image/image_cropping_calculator_pb2.py +33 -0
  30. mediapipe/calculators/image/image_transformation_calculator_pb2.py +38 -0
  31. mediapipe/calculators/image/mask_overlay_calculator_pb2.py +33 -0
  32. mediapipe/calculators/image/opencv_encoded_image_to_image_frame_calculator_pb2.py +31 -0
  33. mediapipe/calculators/image/opencv_image_encoder_calculator_pb2.py +35 -0
  34. mediapipe/calculators/image/recolor_calculator_pb2.py +34 -0
  35. mediapipe/calculators/image/rotation_mode_pb2.py +29 -0
  36. mediapipe/calculators/image/scale_image_calculator_pb2.py +34 -0
  37. mediapipe/calculators/image/segmentation_smoothing_calculator_pb2.py +31 -0
  38. mediapipe/calculators/image/set_alpha_calculator_pb2.py +31 -0
  39. mediapipe/calculators/image/warp_affine_calculator_pb2.py +36 -0
  40. mediapipe/calculators/internal/__init__.py +0 -0
  41. mediapipe/calculators/internal/callback_packet_calculator_pb2.py +33 -0
  42. mediapipe/calculators/tensor/__init__.py +0 -0
  43. mediapipe/calculators/tensor/audio_to_tensor_calculator_pb2.py +35 -0
  44. mediapipe/calculators/tensor/bert_preprocessor_calculator_pb2.py +31 -0
  45. mediapipe/calculators/tensor/feedback_tensors_calculator_pb2.py +37 -0
  46. mediapipe/calculators/tensor/image_to_tensor_calculator_pb2.py +40 -0
  47. mediapipe/calculators/tensor/inference_calculator_pb2.py +63 -0
  48. mediapipe/calculators/tensor/landmarks_to_tensor_calculator_pb2.py +33 -0
  49. mediapipe/calculators/tensor/regex_preprocessor_calculator_pb2.py +31 -0
  50. mediapipe/calculators/tensor/tensor_converter_calculator_pb2.py +34 -0
  51. mediapipe/calculators/tensor/tensor_to_joints_calculator_pb2.py +31 -0
  52. mediapipe/calculators/tensor/tensors_readback_calculator_pb2.py +35 -0
  53. mediapipe/calculators/tensor/tensors_to_audio_calculator_pb2.py +33 -0
  54. mediapipe/calculators/tensor/tensors_to_classification_calculator_pb2.py +44 -0
  55. mediapipe/calculators/tensor/tensors_to_detections_calculator_pb2.py +39 -0
  56. mediapipe/calculators/tensor/tensors_to_floats_calculator_pb2.py +33 -0
  57. mediapipe/calculators/tensor/tensors_to_landmarks_calculator_pb2.py +33 -0
  58. mediapipe/calculators/tensor/tensors_to_segmentation_calculator_pb2.py +34 -0
  59. mediapipe/calculators/tensor/vector_to_tensor_calculator_pb2.py +27 -0
  60. mediapipe/calculators/tflite/__init__.py +0 -0
  61. mediapipe/calculators/tflite/ssd_anchors_calculator_pb2.py +32 -0
  62. mediapipe/calculators/tflite/tflite_converter_calculator_pb2.py +33 -0
  63. mediapipe/calculators/tflite/tflite_custom_op_resolver_calculator_pb2.py +31 -0
  64. mediapipe/calculators/tflite/tflite_inference_calculator_pb2.py +49 -0
  65. mediapipe/calculators/tflite/tflite_tensors_to_classification_calculator_pb2.py +31 -0
  66. mediapipe/calculators/tflite/tflite_tensors_to_detections_calculator_pb2.py +31 -0
  67. mediapipe/calculators/tflite/tflite_tensors_to_landmarks_calculator_pb2.py +33 -0
  68. mediapipe/calculators/tflite/tflite_tensors_to_segmentation_calculator_pb2.py +31 -0
  69. mediapipe/calculators/util/__init__.py +0 -0
  70. mediapipe/calculators/util/align_hand_to_pose_in_world_calculator_pb2.py +31 -0
  71. mediapipe/calculators/util/annotation_overlay_calculator_pb2.py +32 -0
  72. mediapipe/calculators/util/association_calculator_pb2.py +31 -0
  73. mediapipe/calculators/util/collection_has_min_size_calculator_pb2.py +31 -0
  74. mediapipe/calculators/util/combine_joints_calculator_pb2.py +36 -0
  75. mediapipe/calculators/util/detection_label_id_to_text_calculator_pb2.py +36 -0
  76. mediapipe/calculators/util/detections_to_rects_calculator_pb2.py +33 -0
  77. mediapipe/calculators/util/detections_to_render_data_calculator_pb2.py +33 -0
  78. mediapipe/calculators/util/face_to_rect_calculator_pb2.py +26 -0
  79. mediapipe/calculators/util/filter_detections_calculator_pb2.py +31 -0
  80. mediapipe/calculators/util/flat_color_image_calculator_pb2.py +32 -0
  81. mediapipe/calculators/util/labels_to_render_data_calculator_pb2.py +34 -0
  82. mediapipe/calculators/util/landmark_projection_calculator_pb2.py +31 -0
  83. mediapipe/calculators/util/landmarks_refinement_calculator_pb2.py +41 -0
  84. mediapipe/calculators/util/landmarks_smoothing_calculator_pb2.py +33 -0
  85. mediapipe/calculators/util/landmarks_to_detection_calculator_pb2.py +31 -0
  86. mediapipe/calculators/util/landmarks_to_floats_calculator_pb2.py +31 -0
  87. mediapipe/calculators/util/landmarks_to_render_data_calculator_pb2.py +32 -0
  88. mediapipe/calculators/util/landmarks_transformation_calculator_pb2.py +37 -0
  89. mediapipe/calculators/util/latency_pb2.py +26 -0
  90. mediapipe/calculators/util/local_file_contents_calculator_pb2.py +31 -0
  91. mediapipe/calculators/util/logic_calculator_pb2.py +34 -0
  92. mediapipe/calculators/util/non_max_suppression_calculator_pb2.py +35 -0
  93. mediapipe/calculators/util/packet_frequency_calculator_pb2.py +31 -0
  94. mediapipe/calculators/util/packet_frequency_pb2.py +26 -0
  95. mediapipe/calculators/util/packet_latency_calculator_pb2.py +31 -0
  96. mediapipe/calculators/util/rect_to_render_data_calculator_pb2.py +32 -0
  97. mediapipe/calculators/util/rect_to_render_scale_calculator_pb2.py +31 -0
  98. mediapipe/calculators/util/rect_transformation_calculator_pb2.py +31 -0
  99. mediapipe/calculators/util/refine_landmarks_from_heatmap_calculator_pb2.py +31 -0
  100. mediapipe/calculators/util/resource_provider_calculator_pb2.py +28 -0
  101. mediapipe/calculators/util/set_joints_visibility_calculator_pb2.py +41 -0
  102. mediapipe/calculators/util/thresholding_calculator_pb2.py +31 -0
  103. mediapipe/calculators/util/timed_box_list_id_to_label_calculator_pb2.py +31 -0
  104. mediapipe/calculators/util/timed_box_list_to_render_data_calculator_pb2.py +32 -0
  105. mediapipe/calculators/util/top_k_scores_calculator_pb2.py +31 -0
  106. mediapipe/calculators/util/visibility_copy_calculator_pb2.py +27 -0
  107. mediapipe/calculators/util/visibility_smoothing_calculator_pb2.py +31 -0
  108. mediapipe/calculators/video/__init__.py +0 -0
  109. mediapipe/calculators/video/box_detector_calculator_pb2.py +32 -0
  110. mediapipe/calculators/video/box_tracker_calculator_pb2.py +32 -0
  111. mediapipe/calculators/video/flow_packager_calculator_pb2.py +32 -0
  112. mediapipe/calculators/video/flow_to_image_calculator_pb2.py +31 -0
  113. mediapipe/calculators/video/motion_analysis_calculator_pb2.py +42 -0
  114. mediapipe/calculators/video/opencv_video_encoder_calculator_pb2.py +31 -0
  115. mediapipe/calculators/video/tool/__init__.py +0 -0
  116. mediapipe/calculators/video/tool/flow_quantizer_model_pb2.py +26 -0
  117. mediapipe/calculators/video/tracked_detection_manager_calculator_pb2.py +32 -0
  118. mediapipe/calculators/video/video_pre_stream_calculator_pb2.py +35 -0
  119. mediapipe/examples/__init__.py +14 -0
  120. mediapipe/examples/desktop/__init__.py +14 -0
  121. mediapipe/framework/__init__.py +0 -0
  122. mediapipe/framework/calculator_options_pb2.py +29 -0
  123. mediapipe/framework/calculator_pb2.py +59 -0
  124. mediapipe/framework/calculator_profile_pb2.py +48 -0
  125. mediapipe/framework/deps/__init__.py +0 -0
  126. mediapipe/framework/deps/proto_descriptor_pb2.py +29 -0
  127. mediapipe/framework/formats/__init__.py +0 -0
  128. mediapipe/framework/formats/affine_transform_data_pb2.py +28 -0
  129. mediapipe/framework/formats/annotation/__init__.py +0 -0
  130. mediapipe/framework/formats/annotation/locus_pb2.py +32 -0
  131. mediapipe/framework/formats/annotation/rasterization_pb2.py +29 -0
  132. mediapipe/framework/formats/body_rig_pb2.py +28 -0
  133. mediapipe/framework/formats/classification_pb2.py +31 -0
  134. mediapipe/framework/formats/detection_pb2.py +36 -0
  135. mediapipe/framework/formats/image_file_properties_pb2.py +26 -0
  136. mediapipe/framework/formats/image_format_pb2.py +29 -0
  137. mediapipe/framework/formats/landmark_pb2.py +37 -0
  138. mediapipe/framework/formats/location_data_pb2.py +38 -0
  139. mediapipe/framework/formats/matrix_data_pb2.py +31 -0
  140. mediapipe/framework/formats/motion/__init__.py +0 -0
  141. mediapipe/framework/formats/motion/optical_flow_field_data_pb2.py +30 -0
  142. mediapipe/framework/formats/object_detection/__init__.py +0 -0
  143. mediapipe/framework/formats/object_detection/anchor_pb2.py +26 -0
  144. mediapipe/framework/formats/rect_pb2.py +29 -0
  145. mediapipe/framework/formats/time_series_header_pb2.py +28 -0
  146. mediapipe/framework/graph_runtime_info_pb2.py +31 -0
  147. mediapipe/framework/mediapipe_options_pb2.py +27 -0
  148. mediapipe/framework/packet_factory_pb2.py +31 -0
  149. mediapipe/framework/packet_generator_pb2.py +33 -0
  150. mediapipe/framework/status_handler_pb2.py +28 -0
  151. mediapipe/framework/stream_handler/__init__.py +0 -0
  152. mediapipe/framework/stream_handler/default_input_stream_handler_pb2.py +27 -0
  153. mediapipe/framework/stream_handler/fixed_size_input_stream_handler_pb2.py +27 -0
  154. mediapipe/framework/stream_handler/sync_set_input_stream_handler_pb2.py +29 -0
  155. mediapipe/framework/stream_handler/timestamp_align_input_stream_handler_pb2.py +27 -0
  156. mediapipe/framework/stream_handler_pb2.py +30 -0
  157. mediapipe/framework/test_calculators_pb2.py +31 -0
  158. mediapipe/framework/thread_pool_executor_pb2.py +29 -0
  159. mediapipe/framework/tool/__init__.py +0 -0
  160. mediapipe/framework/tool/calculator_graph_template_pb2.py +44 -0
  161. mediapipe/framework/tool/field_data_pb2.py +28 -0
  162. mediapipe/framework/tool/node_chain_subgraph_pb2.py +31 -0
  163. mediapipe/framework/tool/packet_generator_wrapper_calculator_pb2.py +28 -0
  164. mediapipe/framework/tool/source_pb2.py +33 -0
  165. mediapipe/framework/tool/switch_container_pb2.py +32 -0
  166. mediapipe/gpu/__init__.py +0 -0
  167. mediapipe/gpu/copy_calculator_pb2.py +33 -0
  168. mediapipe/gpu/gl_animation_overlay_calculator_pb2.py +31 -0
  169. mediapipe/gpu/gl_context_options_pb2.py +31 -0
  170. mediapipe/gpu/gl_scaler_calculator_pb2.py +32 -0
  171. mediapipe/gpu/gl_surface_sink_calculator_pb2.py +32 -0
  172. mediapipe/gpu/gpu_origin_pb2.py +29 -0
  173. mediapipe/gpu/scale_mode_pb2.py +28 -0
  174. mediapipe/model_maker/__init__.py +27 -0
  175. mediapipe/model_maker/setup.py +107 -0
  176. mediapipe/modules/__init__.py +0 -0
  177. mediapipe/modules/face_detection/__init__.py +0 -0
  178. mediapipe/modules/face_detection/face_detection_full_range_cpu.binarypb +0 -0
  179. mediapipe/modules/face_detection/face_detection_full_range_sparse.tflite +0 -0
  180. mediapipe/modules/face_detection/face_detection_pb2.py +30 -0
  181. mediapipe/modules/face_detection/face_detection_short_range.tflite +0 -0
  182. mediapipe/modules/face_detection/face_detection_short_range_cpu.binarypb +0 -0
  183. mediapipe/modules/face_geometry/__init__.py +0 -0
  184. mediapipe/modules/face_geometry/data/__init__.py +0 -0
  185. mediapipe/modules/face_geometry/effect_renderer_calculator_pb2.py +27 -0
  186. mediapipe/modules/face_geometry/env_generator_calculator_pb2.py +28 -0
  187. mediapipe/modules/face_geometry/geometry_pipeline_calculator_pb2.py +27 -0
  188. mediapipe/modules/face_geometry/libs/__init__.py +0 -0
  189. mediapipe/modules/face_geometry/protos/__init__.py +0 -0
  190. mediapipe/modules/face_geometry/protos/environment_pb2.py +31 -0
  191. mediapipe/modules/face_geometry/protos/face_geometry_pb2.py +29 -0
  192. mediapipe/modules/face_geometry/protos/geometry_pipeline_metadata_pb2.py +32 -0
  193. mediapipe/modules/face_geometry/protos/mesh_3d_pb2.py +31 -0
  194. mediapipe/modules/face_landmark/__init__.py +0 -0
  195. mediapipe/modules/face_landmark/face_landmark.tflite +0 -0
  196. mediapipe/modules/face_landmark/face_landmark_front_cpu.binarypb +0 -0
  197. mediapipe/modules/face_landmark/face_landmark_with_attention.tflite +0 -0
  198. mediapipe/modules/hand_landmark/__init__.py +0 -0
  199. mediapipe/modules/hand_landmark/calculators/__init__.py +0 -0
  200. mediapipe/modules/hand_landmark/hand_landmark_full.tflite +0 -0
  201. mediapipe/modules/hand_landmark/hand_landmark_lite.tflite +0 -0
  202. mediapipe/modules/hand_landmark/hand_landmark_tracking_cpu.binarypb +0 -0
  203. mediapipe/modules/hand_landmark/handedness.txt +2 -0
  204. mediapipe/modules/holistic_landmark/__init__.py +0 -0
  205. mediapipe/modules/holistic_landmark/calculators/__init__.py +0 -0
  206. mediapipe/modules/holistic_landmark/calculators/roi_tracking_calculator_pb2.py +37 -0
  207. mediapipe/modules/holistic_landmark/hand_recrop.tflite +0 -0
  208. mediapipe/modules/holistic_landmark/holistic_landmark_cpu.binarypb +0 -0
  209. mediapipe/modules/iris_landmark/__init__.py +0 -0
  210. mediapipe/modules/iris_landmark/iris_landmark.tflite +0 -0
  211. mediapipe/modules/objectron/__init__.py +0 -0
  212. mediapipe/modules/objectron/calculators/__init__.py +0 -0
  213. mediapipe/modules/objectron/calculators/a_r_capture_metadata_pb2.py +102 -0
  214. mediapipe/modules/objectron/calculators/annotation_data_pb2.py +38 -0
  215. mediapipe/modules/objectron/calculators/belief_decoder_config_pb2.py +28 -0
  216. mediapipe/modules/objectron/calculators/camera_parameters_pb2.py +30 -0
  217. mediapipe/modules/objectron/calculators/filter_detection_calculator_pb2.py +35 -0
  218. mediapipe/modules/objectron/calculators/frame_annotation_to_rect_calculator_pb2.py +31 -0
  219. mediapipe/modules/objectron/calculators/frame_annotation_tracker_calculator_pb2.py +31 -0
  220. mediapipe/modules/objectron/calculators/lift_2d_frame_annotation_to_3d_calculator_pb2.py +32 -0
  221. mediapipe/modules/objectron/calculators/object_pb2.py +38 -0
  222. mediapipe/modules/objectron/calculators/tensors_to_objects_calculator_pb2.py +32 -0
  223. mediapipe/modules/objectron/calculators/tflite_tensors_to_objects_calculator_pb2.py +32 -0
  224. mediapipe/modules/objectron/object_detection_oidv4_labelmap.txt +24 -0
  225. mediapipe/modules/objectron/objectron_cpu.binarypb +0 -0
  226. mediapipe/modules/palm_detection/__init__.py +0 -0
  227. mediapipe/modules/palm_detection/palm_detection_full.tflite +0 -0
  228. mediapipe/modules/palm_detection/palm_detection_lite.tflite +0 -0
  229. mediapipe/modules/pose_detection/__init__.py +0 -0
  230. mediapipe/modules/pose_detection/pose_detection.tflite +0 -0
  231. mediapipe/modules/pose_landmark/__init__.py +0 -0
  232. mediapipe/modules/pose_landmark/pose_landmark_cpu.binarypb +0 -0
  233. mediapipe/modules/pose_landmark/pose_landmark_full.tflite +0 -0
  234. mediapipe/modules/selfie_segmentation/__init__.py +0 -0
  235. mediapipe/modules/selfie_segmentation/selfie_segmentation.tflite +0 -0
  236. mediapipe/modules/selfie_segmentation/selfie_segmentation_cpu.binarypb +0 -0
  237. mediapipe/modules/selfie_segmentation/selfie_segmentation_landscape.tflite +0 -0
  238. mediapipe/python/__init__.py +29 -0
  239. mediapipe/python/_framework_bindings.cpython-311-x86_64-linux-gnu.so +0 -0
  240. mediapipe/python/calculator_graph_test.py +251 -0
  241. mediapipe/python/image_frame_test.py +194 -0
  242. mediapipe/python/image_test.py +218 -0
  243. mediapipe/python/packet_creator.py +275 -0
  244. mediapipe/python/packet_getter.py +120 -0
  245. mediapipe/python/packet_test.py +533 -0
  246. mediapipe/python/solution_base.py +604 -0
  247. mediapipe/python/solution_base_test.py +396 -0
  248. mediapipe/python/solutions/__init__.py +27 -0
  249. mediapipe/python/solutions/download_utils.py +37 -0
  250. mediapipe/python/solutions/drawing_styles.py +249 -0
  251. mediapipe/python/solutions/drawing_utils.py +320 -0
  252. mediapipe/python/solutions/drawing_utils_test.py +258 -0
  253. mediapipe/python/solutions/face_detection.py +105 -0
  254. mediapipe/python/solutions/face_detection_test.py +92 -0
  255. mediapipe/python/solutions/face_mesh.py +125 -0
  256. mediapipe/python/solutions/face_mesh_connections.py +500 -0
  257. mediapipe/python/solutions/face_mesh_test.py +170 -0
  258. mediapipe/python/solutions/hands.py +153 -0
  259. mediapipe/python/solutions/hands_connections.py +32 -0
  260. mediapipe/python/solutions/hands_test.py +219 -0
  261. mediapipe/python/solutions/holistic.py +167 -0
  262. mediapipe/python/solutions/holistic_test.py +142 -0
  263. mediapipe/python/solutions/objectron.py +288 -0
  264. mediapipe/python/solutions/objectron_test.py +81 -0
  265. mediapipe/python/solutions/pose.py +192 -0
  266. mediapipe/python/solutions/pose_connections.py +22 -0
  267. mediapipe/python/solutions/pose_test.py +262 -0
  268. mediapipe/python/solutions/selfie_segmentation.py +76 -0
  269. mediapipe/python/solutions/selfie_segmentation_test.py +68 -0
  270. mediapipe/python/timestamp_test.py +78 -0
  271. mediapipe/tasks/__init__.py +14 -0
  272. mediapipe/tasks/cc/__init__.py +0 -0
  273. mediapipe/tasks/cc/audio/__init__.py +0 -0
  274. mediapipe/tasks/cc/audio/audio_classifier/__init__.py +0 -0
  275. mediapipe/tasks/cc/audio/audio_classifier/proto/__init__.py +0 -0
  276. mediapipe/tasks/cc/audio/audio_classifier/proto/audio_classifier_graph_options_pb2.py +35 -0
  277. mediapipe/tasks/cc/audio/audio_embedder/__init__.py +0 -0
  278. mediapipe/tasks/cc/audio/audio_embedder/proto/__init__.py +0 -0
  279. mediapipe/tasks/cc/audio/audio_embedder/proto/audio_embedder_graph_options_pb2.py +35 -0
  280. mediapipe/tasks/cc/audio/core/__init__.py +0 -0
  281. mediapipe/tasks/cc/audio/utils/__init__.py +0 -0
  282. mediapipe/tasks/cc/components/__init__.py +0 -0
  283. mediapipe/tasks/cc/components/calculators/__init__.py +0 -0
  284. mediapipe/tasks/cc/components/calculators/classification_aggregation_calculator_pb2.py +31 -0
  285. mediapipe/tasks/cc/components/calculators/score_calibration_calculator_pb2.py +35 -0
  286. mediapipe/tasks/cc/components/calculators/tensors_to_embeddings_calculator_pb2.py +32 -0
  287. mediapipe/tasks/cc/components/containers/__init__.py +0 -0
  288. mediapipe/tasks/cc/components/containers/proto/__init__.py +0 -0
  289. mediapipe/tasks/cc/components/containers/proto/classifications_pb2.py +30 -0
  290. mediapipe/tasks/cc/components/containers/proto/embeddings_pb2.py +35 -0
  291. mediapipe/tasks/cc/components/containers/proto/landmarks_detection_result_pb2.py +32 -0
  292. mediapipe/tasks/cc/components/processors/__init__.py +0 -0
  293. mediapipe/tasks/cc/components/processors/proto/__init__.py +0 -0
  294. mediapipe/tasks/cc/components/processors/proto/classification_postprocessing_graph_options_pb2.py +38 -0
  295. mediapipe/tasks/cc/components/processors/proto/classifier_options_pb2.py +27 -0
  296. mediapipe/tasks/cc/components/processors/proto/detection_postprocessing_graph_options_pb2.py +36 -0
  297. mediapipe/tasks/cc/components/processors/proto/detector_options_pb2.py +27 -0
  298. mediapipe/tasks/cc/components/processors/proto/embedder_options_pb2.py +27 -0
  299. mediapipe/tasks/cc/components/processors/proto/embedding_postprocessing_graph_options_pb2.py +32 -0
  300. mediapipe/tasks/cc/components/processors/proto/image_preprocessing_graph_options_pb2.py +34 -0
  301. mediapipe/tasks/cc/components/processors/proto/text_model_type_pb2.py +28 -0
  302. mediapipe/tasks/cc/components/processors/proto/text_preprocessing_graph_options_pb2.py +32 -0
  303. mediapipe/tasks/cc/components/utils/__init__.py +0 -0
  304. mediapipe/tasks/cc/core/__init__.py +0 -0
  305. mediapipe/tasks/cc/core/proto/__init__.py +0 -0
  306. mediapipe/tasks/cc/core/proto/acceleration_pb2.py +28 -0
  307. mediapipe/tasks/cc/core/proto/base_options_pb2.py +30 -0
  308. mediapipe/tasks/cc/core/proto/external_file_pb2.py +31 -0
  309. mediapipe/tasks/cc/core/proto/inference_subgraph_pb2.py +32 -0
  310. mediapipe/tasks/cc/core/proto/model_resources_calculator_pb2.py +32 -0
  311. mediapipe/tasks/cc/genai/__init__.py +0 -0
  312. mediapipe/tasks/cc/genai/inference/__init__.py +0 -0
  313. mediapipe/tasks/cc/genai/inference/c/__init__.py +0 -0
  314. mediapipe/tasks/cc/genai/inference/calculators/__init__.py +0 -0
  315. mediapipe/tasks/cc/genai/inference/calculators/detokenizer_calculator_pb2.py +27 -0
  316. mediapipe/tasks/cc/genai/inference/calculators/llm_gpu_calculator_pb2.py +32 -0
  317. mediapipe/tasks/cc/genai/inference/calculators/model_data_calculator_pb2.py +27 -0
  318. mediapipe/tasks/cc/genai/inference/calculators/tokenizer_calculator_pb2.py +29 -0
  319. mediapipe/tasks/cc/genai/inference/common/__init__.py +0 -0
  320. mediapipe/tasks/cc/genai/inference/proto/__init__.py +0 -0
  321. mediapipe/tasks/cc/genai/inference/proto/llm_file_metadata_pb2.py +32 -0
  322. mediapipe/tasks/cc/genai/inference/proto/llm_params_pb2.py +33 -0
  323. mediapipe/tasks/cc/genai/inference/proto/prompt_template_pb2.py +27 -0
  324. mediapipe/tasks/cc/genai/inference/proto/sampler_params_pb2.py +29 -0
  325. mediapipe/tasks/cc/genai/inference/proto/transformer_params_pb2.py +45 -0
  326. mediapipe/tasks/cc/genai/inference/utils/__init__.py +0 -0
  327. mediapipe/tasks/cc/genai/inference/utils/llm_utils/__init__.py +0 -0
  328. mediapipe/tasks/cc/genai/inference/utils/xnn_utils/__init__.py +0 -0
  329. mediapipe/tasks/cc/metadata/__init__.py +0 -0
  330. mediapipe/tasks/cc/metadata/python/__init__.py +0 -0
  331. mediapipe/tasks/cc/metadata/python/_pywrap_metadata_version.cpython-311-x86_64-linux-gnu.so +0 -0
  332. mediapipe/tasks/cc/metadata/tests/__init__.py +0 -0
  333. mediapipe/tasks/cc/metadata/utils/__init__.py +0 -0
  334. mediapipe/tasks/cc/text/__init__.py +0 -0
  335. mediapipe/tasks/cc/text/custom_ops/__init__.py +0 -0
  336. mediapipe/tasks/cc/text/custom_ops/ragged/__init__.py +0 -0
  337. mediapipe/tasks/cc/text/custom_ops/sentencepiece/__init__.py +0 -0
  338. mediapipe/tasks/cc/text/custom_ops/sentencepiece/testdata/__init__.py +0 -0
  339. mediapipe/tasks/cc/text/language_detector/__init__.py +0 -0
  340. mediapipe/tasks/cc/text/language_detector/custom_ops/__init__.py +0 -0
  341. mediapipe/tasks/cc/text/language_detector/custom_ops/utils/__init__.py +0 -0
  342. mediapipe/tasks/cc/text/language_detector/custom_ops/utils/hash/__init__.py +0 -0
  343. mediapipe/tasks/cc/text/language_detector/custom_ops/utils/utf/__init__.py +0 -0
  344. mediapipe/tasks/cc/text/text_classifier/__init__.py +0 -0
  345. mediapipe/tasks/cc/text/text_classifier/proto/__init__.py +0 -0
  346. mediapipe/tasks/cc/text/text_classifier/proto/text_classifier_graph_options_pb2.py +35 -0
  347. mediapipe/tasks/cc/text/text_embedder/__init__.py +0 -0
  348. mediapipe/tasks/cc/text/text_embedder/proto/__init__.py +0 -0
  349. mediapipe/tasks/cc/text/text_embedder/proto/text_embedder_graph_options_pb2.py +35 -0
  350. mediapipe/tasks/cc/text/tokenizers/__init__.py +0 -0
  351. mediapipe/tasks/cc/text/utils/__init__.py +0 -0
  352. mediapipe/tasks/cc/vision/__init__.py +0 -0
  353. mediapipe/tasks/cc/vision/core/__init__.py +0 -0
  354. mediapipe/tasks/cc/vision/custom_ops/__init__.py +0 -0
  355. mediapipe/tasks/cc/vision/face_detector/__init__.py +0 -0
  356. mediapipe/tasks/cc/vision/face_detector/proto/__init__.py +0 -0
  357. mediapipe/tasks/cc/vision/face_detector/proto/face_detector_graph_options_pb2.py +34 -0
  358. mediapipe/tasks/cc/vision/face_geometry/__init__.py +0 -0
  359. mediapipe/tasks/cc/vision/face_geometry/calculators/__init__.py +0 -0
  360. mediapipe/tasks/cc/vision/face_geometry/calculators/env_generator_calculator_pb2.py +28 -0
  361. mediapipe/tasks/cc/vision/face_geometry/calculators/geometry_pipeline_calculator_pb2.py +29 -0
  362. mediapipe/tasks/cc/vision/face_geometry/data/__init__.py +0 -0
  363. mediapipe/tasks/cc/vision/face_geometry/libs/__init__.py +0 -0
  364. mediapipe/tasks/cc/vision/face_geometry/proto/__init__.py +0 -0
  365. mediapipe/tasks/cc/vision/face_geometry/proto/environment_pb2.py +31 -0
  366. mediapipe/tasks/cc/vision/face_geometry/proto/face_geometry_graph_options_pb2.py +29 -0
  367. mediapipe/tasks/cc/vision/face_geometry/proto/face_geometry_pb2.py +29 -0
  368. mediapipe/tasks/cc/vision/face_geometry/proto/geometry_pipeline_metadata_pb2.py +32 -0
  369. mediapipe/tasks/cc/vision/face_geometry/proto/mesh_3d_pb2.py +31 -0
  370. mediapipe/tasks/cc/vision/face_landmarker/__init__.py +0 -0
  371. mediapipe/tasks/cc/vision/face_landmarker/proto/__init__.py +0 -0
  372. mediapipe/tasks/cc/vision/face_landmarker/proto/face_blendshapes_graph_options_pb2.py +34 -0
  373. mediapipe/tasks/cc/vision/face_landmarker/proto/face_landmarker_graph_options_pb2.py +37 -0
  374. mediapipe/tasks/cc/vision/face_landmarker/proto/face_landmarks_detector_graph_options_pb2.py +35 -0
  375. mediapipe/tasks/cc/vision/face_landmarker/proto/tensors_to_face_landmarks_graph_options_pb2.py +32 -0
  376. mediapipe/tasks/cc/vision/face_stylizer/__init__.py +0 -0
  377. mediapipe/tasks/cc/vision/face_stylizer/calculators/__init__.py +0 -0
  378. mediapipe/tasks/cc/vision/face_stylizer/calculators/tensors_to_image_calculator_pb2.py +36 -0
  379. mediapipe/tasks/cc/vision/face_stylizer/proto/__init__.py +0 -0
  380. mediapipe/tasks/cc/vision/face_stylizer/proto/face_stylizer_graph_options_pb2.py +35 -0
  381. mediapipe/tasks/cc/vision/gesture_recognizer/__init__.py +0 -0
  382. mediapipe/tasks/cc/vision/gesture_recognizer/calculators/__init__.py +0 -0
  383. mediapipe/tasks/cc/vision/gesture_recognizer/calculators/combined_prediction_calculator_pb2.py +33 -0
  384. mediapipe/tasks/cc/vision/gesture_recognizer/calculators/landmarks_to_matrix_calculator_pb2.py +31 -0
  385. mediapipe/tasks/cc/vision/gesture_recognizer/proto/__init__.py +0 -0
  386. mediapipe/tasks/cc/vision/gesture_recognizer/proto/gesture_classifier_graph_options_pb2.py +35 -0
  387. mediapipe/tasks/cc/vision/gesture_recognizer/proto/gesture_embedder_graph_options_pb2.py +34 -0
  388. mediapipe/tasks/cc/vision/gesture_recognizer/proto/gesture_recognizer_graph_options_pb2.py +36 -0
  389. mediapipe/tasks/cc/vision/gesture_recognizer/proto/hand_gesture_recognizer_graph_options_pb2.py +36 -0
  390. mediapipe/tasks/cc/vision/hand_detector/__init__.py +0 -0
  391. mediapipe/tasks/cc/vision/hand_detector/proto/__init__.py +0 -0
  392. mediapipe/tasks/cc/vision/hand_detector/proto/hand_detector_graph_options_pb2.py +34 -0
  393. mediapipe/tasks/cc/vision/hand_detector/proto/hand_detector_result_pb2.py +30 -0
  394. mediapipe/tasks/cc/vision/hand_landmarker/__init__.py +0 -0
  395. mediapipe/tasks/cc/vision/hand_landmarker/calculators/__init__.py +0 -0
  396. mediapipe/tasks/cc/vision/hand_landmarker/calculators/hand_association_calculator_pb2.py +31 -0
  397. mediapipe/tasks/cc/vision/hand_landmarker/proto/__init__.py +0 -0
  398. mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarker_graph_options_pb2.py +36 -0
  399. mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_landmarks_detector_graph_options_pb2.py +34 -0
  400. mediapipe/tasks/cc/vision/hand_landmarker/proto/hand_roi_refinement_graph_options_pb2.py +28 -0
  401. mediapipe/tasks/cc/vision/holistic_landmarker/__init__.py +0 -0
  402. mediapipe/tasks/cc/vision/holistic_landmarker/proto/__init__.py +0 -0
  403. mediapipe/tasks/cc/vision/holistic_landmarker/proto/holistic_landmarker_graph_options_pb2.py +34 -0
  404. mediapipe/tasks/cc/vision/holistic_landmarker/proto/holistic_result_pb2.py +29 -0
  405. mediapipe/tasks/cc/vision/image_classifier/__init__.py +0 -0
  406. mediapipe/tasks/cc/vision/image_classifier/proto/__init__.py +0 -0
  407. mediapipe/tasks/cc/vision/image_classifier/proto/image_classifier_graph_options_pb2.py +35 -0
  408. mediapipe/tasks/cc/vision/image_embedder/__init__.py +0 -0
  409. mediapipe/tasks/cc/vision/image_embedder/proto/__init__.py +0 -0
  410. mediapipe/tasks/cc/vision/image_embedder/proto/image_embedder_graph_options_pb2.py +35 -0
  411. mediapipe/tasks/cc/vision/image_generator/__init__.py +0 -0
  412. mediapipe/tasks/cc/vision/image_generator/diffuser/__init__.py +0 -0
  413. mediapipe/tasks/cc/vision/image_generator/diffuser/stable_diffusion_iterate_calculator_pb2.py +40 -0
  414. mediapipe/tasks/cc/vision/image_generator/proto/__init__.py +0 -0
  415. mediapipe/tasks/cc/vision/image_generator/proto/conditioned_image_graph_options_pb2.py +40 -0
  416. mediapipe/tasks/cc/vision/image_generator/proto/control_plugin_graph_options_pb2.py +34 -0
  417. mediapipe/tasks/cc/vision/image_generator/proto/image_generator_graph_options_pb2.py +30 -0
  418. mediapipe/tasks/cc/vision/image_segmenter/__init__.py +0 -0
  419. mediapipe/tasks/cc/vision/image_segmenter/calculators/__init__.py +0 -0
  420. mediapipe/tasks/cc/vision/image_segmenter/calculators/tensors_to_segmentation_calculator_pb2.py +34 -0
  421. mediapipe/tasks/cc/vision/image_segmenter/proto/__init__.py +0 -0
  422. mediapipe/tasks/cc/vision/image_segmenter/proto/image_segmenter_graph_options_pb2.py +35 -0
  423. mediapipe/tasks/cc/vision/image_segmenter/proto/segmenter_options_pb2.py +33 -0
  424. mediapipe/tasks/cc/vision/interactive_segmenter/__init__.py +0 -0
  425. mediapipe/tasks/cc/vision/object_detector/__init__.py +0 -0
  426. mediapipe/tasks/cc/vision/object_detector/proto/__init__.py +0 -0
  427. mediapipe/tasks/cc/vision/object_detector/proto/object_detector_options_pb2.py +34 -0
  428. mediapipe/tasks/cc/vision/pose_detector/__init__.py +0 -0
  429. mediapipe/tasks/cc/vision/pose_detector/proto/__init__.py +0 -0
  430. mediapipe/tasks/cc/vision/pose_detector/proto/pose_detector_graph_options_pb2.py +34 -0
  431. mediapipe/tasks/cc/vision/pose_landmarker/__init__.py +0 -0
  432. mediapipe/tasks/cc/vision/pose_landmarker/proto/__init__.py +0 -0
  433. mediapipe/tasks/cc/vision/pose_landmarker/proto/pose_landmarker_graph_options_pb2.py +36 -0
  434. mediapipe/tasks/cc/vision/pose_landmarker/proto/pose_landmarks_detector_graph_options_pb2.py +34 -0
  435. mediapipe/tasks/cc/vision/utils/__init__.py +0 -0
  436. mediapipe/tasks/cc/vision/utils/ghum/__init__.py +0 -0
  437. mediapipe/tasks/metadata/image_segmenter_metadata_schema.fbs +59 -0
  438. mediapipe/tasks/metadata/image_segmenter_metadata_schema_py_generated.py +108 -0
  439. mediapipe/tasks/metadata/metadata_schema.fbs +732 -0
  440. mediapipe/tasks/metadata/metadata_schema_py_generated.py +3251 -0
  441. mediapipe/tasks/metadata/object_detector_metadata_schema.fbs +98 -0
  442. mediapipe/tasks/metadata/object_detector_metadata_schema_py_generated.py +674 -0
  443. mediapipe/tasks/metadata/schema_py_generated.py +18438 -0
  444. mediapipe/tasks/python/__init__.py +27 -0
  445. mediapipe/tasks/python/audio/__init__.py +33 -0
  446. mediapipe/tasks/python/audio/audio_classifier.py +324 -0
  447. mediapipe/tasks/python/audio/audio_embedder.py +285 -0
  448. mediapipe/tasks/python/audio/core/__init__.py +16 -0
  449. mediapipe/tasks/python/audio/core/audio_record.py +125 -0
  450. mediapipe/tasks/python/audio/core/audio_task_running_mode.py +29 -0
  451. mediapipe/tasks/python/audio/core/base_audio_task_api.py +181 -0
  452. mediapipe/tasks/python/benchmark/__init__.py +13 -0
  453. mediapipe/tasks/python/benchmark/benchmark_utils.py +70 -0
  454. mediapipe/tasks/python/benchmark/vision/__init__.py +13 -0
  455. mediapipe/tasks/python/benchmark/vision/benchmark.py +99 -0
  456. mediapipe/tasks/python/benchmark/vision/core/__init__.py +14 -0
  457. mediapipe/tasks/python/benchmark/vision/core/base_vision_benchmark_api.py +40 -0
  458. mediapipe/tasks/python/components/__init__.py +13 -0
  459. mediapipe/tasks/python/components/containers/__init__.py +53 -0
  460. mediapipe/tasks/python/components/containers/audio_data.py +137 -0
  461. mediapipe/tasks/python/components/containers/bounding_box.py +73 -0
  462. mediapipe/tasks/python/components/containers/category.py +78 -0
  463. mediapipe/tasks/python/components/containers/classification_result.py +111 -0
  464. mediapipe/tasks/python/components/containers/detections.py +181 -0
  465. mediapipe/tasks/python/components/containers/embedding_result.py +89 -0
  466. mediapipe/tasks/python/components/containers/keypoint.py +77 -0
  467. mediapipe/tasks/python/components/containers/landmark.py +122 -0
  468. mediapipe/tasks/python/components/containers/landmark_detection_result.py +106 -0
  469. mediapipe/tasks/python/components/containers/rect.py +109 -0
  470. mediapipe/tasks/python/components/processors/__init__.py +23 -0
  471. mediapipe/tasks/python/components/processors/classifier_options.py +86 -0
  472. mediapipe/tasks/python/components/utils/__init__.py +13 -0
  473. mediapipe/tasks/python/components/utils/cosine_similarity.py +68 -0
  474. mediapipe/tasks/python/core/__init__.py +13 -0
  475. mediapipe/tasks/python/core/base_options.py +121 -0
  476. mediapipe/tasks/python/core/optional_dependencies.py +25 -0
  477. mediapipe/tasks/python/core/task_info.py +139 -0
  478. mediapipe/tasks/python/genai/__init__.py +14 -0
  479. mediapipe/tasks/python/genai/bundler/__init__.py +23 -0
  480. mediapipe/tasks/python/genai/bundler/llm_bundler.py +130 -0
  481. mediapipe/tasks/python/genai/bundler/llm_bundler_test.py +168 -0
  482. mediapipe/tasks/python/genai/converter/__init__.py +24 -0
  483. mediapipe/tasks/python/genai/converter/converter_base.py +179 -0
  484. mediapipe/tasks/python/genai/converter/converter_factory.py +79 -0
  485. mediapipe/tasks/python/genai/converter/llm_converter.py +374 -0
  486. mediapipe/tasks/python/genai/converter/llm_converter_test.py +63 -0
  487. mediapipe/tasks/python/genai/converter/pytorch_converter.py +318 -0
  488. mediapipe/tasks/python/genai/converter/pytorch_converter_test.py +86 -0
  489. mediapipe/tasks/python/genai/converter/quantization_util.py +516 -0
  490. mediapipe/tasks/python/genai/converter/quantization_util_test.py +259 -0
  491. mediapipe/tasks/python/genai/converter/safetensors_converter.py +580 -0
  492. mediapipe/tasks/python/genai/converter/safetensors_converter_test.py +83 -0
  493. mediapipe/tasks/python/genai/converter/weight_bins_writer.py +120 -0
  494. mediapipe/tasks/python/genai/converter/weight_bins_writer_test.py +95 -0
  495. mediapipe/tasks/python/metadata/__init__.py +13 -0
  496. mediapipe/tasks/python/metadata/flatbuffers_lib/_pywrap_flatbuffers.cpython-311-x86_64-linux-gnu.so +0 -0
  497. mediapipe/tasks/python/metadata/metadata.py +928 -0
  498. mediapipe/tasks/python/metadata/metadata_displayer_cli.py +34 -0
  499. mediapipe/tasks/python/metadata/metadata_writers/__init__.py +13 -0
  500. mediapipe/tasks/python/metadata/metadata_writers/face_stylizer.py +138 -0
  501. mediapipe/tasks/python/metadata/metadata_writers/image_classifier.py +71 -0
  502. mediapipe/tasks/python/metadata/metadata_writers/image_segmenter.py +170 -0
  503. mediapipe/tasks/python/metadata/metadata_writers/metadata_info.py +1166 -0
  504. mediapipe/tasks/python/metadata/metadata_writers/metadata_writer.py +845 -0
  505. mediapipe/tasks/python/metadata/metadata_writers/model_asset_bundle_utils.py +71 -0
  506. mediapipe/tasks/python/metadata/metadata_writers/object_detector.py +331 -0
  507. mediapipe/tasks/python/metadata/metadata_writers/text_classifier.py +119 -0
  508. mediapipe/tasks/python/metadata/metadata_writers/writer_utils.py +91 -0
  509. mediapipe/tasks/python/test/__init__.py +13 -0
  510. mediapipe/tasks/python/test/audio/__init__.py +13 -0
  511. mediapipe/tasks/python/test/audio/audio_classifier_test.py +387 -0
  512. mediapipe/tasks/python/test/audio/audio_embedder_test.py +297 -0
  513. mediapipe/tasks/python/test/test_utils.py +196 -0
  514. mediapipe/tasks/python/test/text/__init__.py +13 -0
  515. mediapipe/tasks/python/test/text/language_detector_test.py +228 -0
  516. mediapipe/tasks/python/test/text/text_classifier_test.py +235 -0
  517. mediapipe/tasks/python/test/text/text_embedder_test.py +326 -0
  518. mediapipe/tasks/python/test/vision/__init__.py +13 -0
  519. mediapipe/tasks/python/test/vision/face_aligner_test.py +190 -0
  520. mediapipe/tasks/python/test/vision/face_detector_test.py +523 -0
  521. mediapipe/tasks/python/test/vision/face_landmarker_test.py +565 -0
  522. mediapipe/tasks/python/test/vision/face_stylizer_test.py +191 -0
  523. mediapipe/tasks/python/test/vision/hand_landmarker_test.py +437 -0
  524. mediapipe/tasks/python/test/vision/holistic_landmarker_test.py +544 -0
  525. mediapipe/tasks/python/test/vision/image_classifier_test.py +657 -0
  526. mediapipe/tasks/python/test/vision/image_embedder_test.py +423 -0
  527. mediapipe/tasks/python/test/vision/image_segmenter_test.py +512 -0
  528. mediapipe/tasks/python/test/vision/interactive_segmenter_test.py +341 -0
  529. mediapipe/tasks/python/test/vision/object_detector_test.py +493 -0
  530. mediapipe/tasks/python/test/vision/pose_landmarker_test.py +518 -0
  531. mediapipe/tasks/python/text/__init__.py +35 -0
  532. mediapipe/tasks/python/text/core/__init__.py +16 -0
  533. mediapipe/tasks/python/text/core/base_text_task_api.py +54 -0
  534. mediapipe/tasks/python/text/language_detector.py +220 -0
  535. mediapipe/tasks/python/text/text_classifier.py +187 -0
  536. mediapipe/tasks/python/text/text_embedder.py +188 -0
  537. mediapipe/tasks/python/vision/__init__.py +90 -0
  538. mediapipe/tasks/python/vision/core/__init__.py +14 -0
  539. mediapipe/tasks/python/vision/core/base_vision_task_api.py +226 -0
  540. mediapipe/tasks/python/vision/core/image_processing_options.py +39 -0
  541. mediapipe/tasks/python/vision/core/vision_task_running_mode.py +31 -0
  542. mediapipe/tasks/python/vision/face_aligner.py +158 -0
  543. mediapipe/tasks/python/vision/face_detector.py +332 -0
  544. mediapipe/tasks/python/vision/face_landmarker.py +3244 -0
  545. mediapipe/tasks/python/vision/face_stylizer.py +158 -0
  546. mediapipe/tasks/python/vision/gesture_recognizer.py +480 -0
  547. mediapipe/tasks/python/vision/hand_landmarker.py +504 -0
  548. mediapipe/tasks/python/vision/holistic_landmarker.py +576 -0
  549. mediapipe/tasks/python/vision/image_classifier.py +358 -0
  550. mediapipe/tasks/python/vision/image_embedder.py +362 -0
  551. mediapipe/tasks/python/vision/image_segmenter.py +433 -0
  552. mediapipe/tasks/python/vision/interactive_segmenter.py +285 -0
  553. mediapipe/tasks/python/vision/object_detector.py +389 -0
  554. mediapipe/tasks/python/vision/pose_landmarker.py +455 -0
  555. mediapipe/util/__init__.py +0 -0
  556. mediapipe/util/analytics/__init__.py +0 -0
  557. mediapipe/util/analytics/mediapipe_log_extension_pb2.py +44 -0
  558. mediapipe/util/analytics/mediapipe_logging_enums_pb2.py +37 -0
  559. mediapipe/util/audio_decoder_pb2.py +33 -0
  560. mediapipe/util/color_pb2.py +33 -0
  561. mediapipe/util/label_map_pb2.py +27 -0
  562. mediapipe/util/render_data_pb2.py +58 -0
  563. mediapipe/util/sequence/__init__.py +14 -0
  564. mediapipe/util/sequence/media_sequence.py +716 -0
  565. mediapipe/util/sequence/media_sequence_test.py +290 -0
  566. mediapipe/util/sequence/media_sequence_util.py +800 -0
  567. mediapipe/util/sequence/media_sequence_util_test.py +389 -0
  568. mediapipe/util/tracking/__init__.py +0 -0
  569. mediapipe/util/tracking/box_detector_pb2.py +39 -0
  570. mediapipe/util/tracking/box_tracker_pb2.py +32 -0
  571. mediapipe/util/tracking/camera_motion_pb2.py +31 -0
  572. mediapipe/util/tracking/flow_packager_pb2.py +60 -0
  573. mediapipe/util/tracking/frame_selection_pb2.py +35 -0
  574. mediapipe/util/tracking/frame_selection_solution_evaluator_pb2.py +28 -0
  575. mediapipe/util/tracking/motion_analysis_pb2.py +35 -0
  576. mediapipe/util/tracking/motion_estimation_pb2.py +66 -0
  577. mediapipe/util/tracking/motion_models_pb2.py +42 -0
  578. mediapipe/util/tracking/motion_saliency_pb2.py +26 -0
  579. mediapipe/util/tracking/push_pull_filtering_pb2.py +26 -0
  580. mediapipe/util/tracking/region_flow_computation_pb2.py +59 -0
  581. mediapipe/util/tracking/region_flow_pb2.py +49 -0
  582. mediapipe/util/tracking/tone_estimation_pb2.py +45 -0
  583. mediapipe/util/tracking/tone_models_pb2.py +32 -0
  584. mediapipe/util/tracking/tracked_detection_manager_config_pb2.py +26 -0
  585. mediapipe/util/tracking/tracking_pb2.py +73 -0
  586. mediapipe_nightly-0.10.21.post20250114.dist-info/LICENSE +218 -0
  587. mediapipe_nightly-0.10.21.post20250114.dist-info/METADATA +199 -0
  588. mediapipe_nightly-0.10.21.post20250114.dist-info/RECORD +593 -0
  589. mediapipe_nightly-0.10.21.post20250114.dist-info/WHEEL +5 -0
  590. mediapipe_nightly-0.10.21.post20250114.dist-info/top_level.txt +4 -0
  591. mediapipe_nightly.libs/libEGL-48f73270.so.1.1.0 +0 -0
  592. mediapipe_nightly.libs/libGLESv2-ed5eda4f.so.2.1.0 +0 -0
  593. mediapipe_nightly.libs/libGLdispatch-64b28464.so.0.0.0 +0 -0
@@ -0,0 +1,120 @@
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
+
15
+ """The public facing packet getter APIs."""
16
+
17
+ from typing import List
18
+
19
+ from google.protobuf import message
20
+ from google.protobuf import message_factory
21
+ from google.protobuf import symbol_database
22
+ from mediapipe.python._framework_bindings import _packet_getter
23
+ from mediapipe.python._framework_bindings import packet as mp_packet
24
+
25
+ get_str = _packet_getter.get_str
26
+ get_bytes = _packet_getter.get_bytes
27
+ get_bool = _packet_getter.get_bool
28
+ get_int = _packet_getter.get_int
29
+ get_uint = _packet_getter.get_uint
30
+ get_float = _packet_getter.get_float
31
+ get_int_list = _packet_getter.get_int_list
32
+ get_bool_list = _packet_getter.get_bool_list
33
+ get_float_list = _packet_getter.get_float_list
34
+ get_str_list = _packet_getter.get_str_list
35
+ get_image_list = _packet_getter.get_image_list
36
+ get_packet_list = _packet_getter.get_packet_list
37
+ get_str_to_packet_dict = _packet_getter.get_str_to_packet_dict
38
+ get_image = _packet_getter.get_image
39
+ get_image_frame = _packet_getter.get_image_frame
40
+ get_matrix = _packet_getter.get_matrix
41
+
42
+
43
+ def get_proto(packet: mp_packet.Packet) -> message.Message:
44
+ """Get the content of a MediaPipe proto Packet as a proto message.
45
+
46
+ Args:
47
+ packet: A MediaPipe proto Packet.
48
+
49
+ Returns:
50
+ A proto message.
51
+
52
+ Raises:
53
+ TypeError: If the message descriptor can't be found by type name.
54
+
55
+ Examples:
56
+ detection = detection_pb2.Detection()
57
+ text_format.Parse('score: 0.5', detection)
58
+ proto_packet = mp.packet_creator.create_proto(detection)
59
+ output_proto = mp.packet_getter.get_proto(proto_packet)
60
+ """
61
+ # pylint:disable=protected-access
62
+ proto_type_name = _packet_getter._get_proto_type_name(packet)
63
+ # pylint:enable=protected-access
64
+ try:
65
+ descriptor = symbol_database.Default().pool.FindMessageTypeByName(
66
+ proto_type_name)
67
+ except KeyError:
68
+ raise TypeError('Can not find message descriptor by type name: %s' %
69
+ proto_type_name)
70
+
71
+ message_class = message_factory.GetMessageClass(descriptor)
72
+ # pylint:disable=protected-access
73
+ serialized_proto = _packet_getter._get_serialized_proto(packet)
74
+ # pylint:enable=protected-access
75
+ proto_message = message_class()
76
+ proto_message.ParseFromString(serialized_proto)
77
+ return proto_message
78
+
79
+
80
+ def get_proto_list(packet: mp_packet.Packet) -> List[message.Message]:
81
+ """Get the content of a MediaPipe proto vector Packet as a proto message list.
82
+
83
+ Args:
84
+ packet: A MediaPipe proto vector Packet.
85
+
86
+ Returns:
87
+ A proto message list.
88
+
89
+ Raises:
90
+ TypeError: If the message descriptor can't be found by type name.
91
+
92
+ Examples:
93
+ proto_list = mp.packet_getter.get_proto_list(protos_packet)
94
+ """
95
+ # pylint:disable=protected-access
96
+ vector_size = _packet_getter._get_proto_vector_size(packet)
97
+ # pylint:enable=protected-access
98
+ # Return empty list if the proto vector is empty.
99
+ if vector_size == 0:
100
+ return []
101
+
102
+ # pylint:disable=protected-access
103
+ proto_type_name = _packet_getter._get_proto_vector_element_type_name(packet)
104
+ # pylint:enable=protected-access
105
+ try:
106
+ descriptor = symbol_database.Default().pool.FindMessageTypeByName(
107
+ proto_type_name)
108
+ except KeyError:
109
+ raise TypeError('Can not find message descriptor by type name: %s' %
110
+ proto_type_name)
111
+ message_class = message_factory.GetMessageClass(descriptor)
112
+ # pylint:disable=protected-access
113
+ serialized_protos = _packet_getter._get_serialized_proto_list(packet)
114
+ # pylint:enable=protected-access
115
+ proto_message_list = []
116
+ for serialized_proto in serialized_protos:
117
+ proto_message = message_class()
118
+ proto_message.ParseFromString(serialized_proto)
119
+ proto_message_list.append(proto_message)
120
+ return proto_message_list
@@ -0,0 +1,533 @@
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
+
15
+ """Tests for mediapipe.python._framework_bindings.packet."""
16
+
17
+ import gc
18
+ import random
19
+ import sys
20
+ from absl.testing import absltest
21
+ import numpy as np
22
+
23
+ from google.protobuf import text_format
24
+ from mediapipe.framework.formats import detection_pb2
25
+ from mediapipe.python import packet_creator
26
+ from mediapipe.python import packet_getter
27
+ from mediapipe.python._framework_bindings import calculator_graph
28
+ from mediapipe.python._framework_bindings import image
29
+ from mediapipe.python._framework_bindings import image_frame
30
+ from mediapipe.python._framework_bindings import packet
31
+
32
+ CalculatorGraph = calculator_graph.CalculatorGraph
33
+ Image = image.Image
34
+ ImageFormat = image_frame.ImageFormat
35
+ ImageFrame = image_frame.ImageFrame
36
+
37
+
38
+ class PacketTest(absltest.TestCase):
39
+
40
+ def test_empty_packet(self):
41
+ p = packet.Packet()
42
+ self.assertTrue(p.is_empty())
43
+
44
+ def test_boolean_packet(self):
45
+ p = packet_creator.create_bool(True)
46
+ p.timestamp = 0
47
+ self.assertEqual(packet_getter.get_bool(p), True)
48
+ self.assertEqual(p.timestamp, 0)
49
+
50
+ def test_int_packet(self):
51
+ with self.assertRaisesRegex(OverflowError, 'execeeds the maximum value'):
52
+ p = packet_creator.create_int(2**32)
53
+ p = packet_creator.create_int(42)
54
+ p.timestamp = 0
55
+ self.assertEqual(packet_getter.get_int(p), 42)
56
+ self.assertEqual(p.timestamp, 0)
57
+ p2 = packet_creator.create_int(np.intc(1))
58
+ p2.timestamp = 0
59
+ self.assertEqual(packet_getter.get_int(p2), 1)
60
+ self.assertEqual(p2.timestamp, 0)
61
+
62
+ def test_int8_packet(self):
63
+ with self.assertRaisesRegex(OverflowError, 'execeeds the maximum value'):
64
+ p = packet_creator.create_int8(2**7)
65
+ p = packet_creator.create_int8(2**7 - 1)
66
+ p.timestamp = 0
67
+ self.assertEqual(packet_getter.get_int(p), 2**7 - 1)
68
+ self.assertEqual(p.timestamp, 0)
69
+ p2 = packet_creator.create_int8(np.int8(1))
70
+ p2.timestamp = 0
71
+ self.assertEqual(packet_getter.get_int(p2), 1)
72
+ self.assertEqual(p2.timestamp, 0)
73
+
74
+ def test_int16_packet(self):
75
+ with self.assertRaisesRegex(OverflowError, 'execeeds the maximum value'):
76
+ p = packet_creator.create_int16(2**15)
77
+ p = packet_creator.create_int16(2**15 - 1)
78
+ p.timestamp = 0
79
+ self.assertEqual(packet_getter.get_int(p), 2**15 - 1)
80
+ self.assertEqual(p.timestamp, 0)
81
+ p2 = packet_creator.create_int16(np.int16(1))
82
+ p2.timestamp = 0
83
+ self.assertEqual(packet_getter.get_int(p2), 1)
84
+ self.assertEqual(p2.timestamp, 0)
85
+
86
+ def test_int32_packet(self):
87
+ with self.assertRaisesRegex(OverflowError, 'execeeds the maximum value'):
88
+ p = packet_creator.create_int32(2**31)
89
+
90
+ p = packet_creator.create_int32(2**31 - 1)
91
+ p.timestamp = 0
92
+ self.assertEqual(packet_getter.get_int(p), 2**31 - 1)
93
+ self.assertEqual(p.timestamp, 0)
94
+ p2 = packet_creator.create_int32(np.int32(1))
95
+ p2.timestamp = 0
96
+ self.assertEqual(packet_getter.get_int(p2), 1)
97
+ self.assertEqual(p2.timestamp, 0)
98
+
99
+ def test_int64_packet(self):
100
+ p = packet_creator.create_int64(2**63 - 1)
101
+ p.timestamp = 0
102
+ self.assertEqual(packet_getter.get_int(p), 2**63 - 1)
103
+ self.assertEqual(p.timestamp, 0)
104
+ p2 = packet_creator.create_int64(np.int64(1))
105
+ p2.timestamp = 0
106
+ self.assertEqual(packet_getter.get_int(p2), 1)
107
+ self.assertEqual(p2.timestamp, 0)
108
+
109
+ def test_uint8_packet(self):
110
+ with self.assertRaisesRegex(OverflowError, 'execeeds the maximum value'):
111
+ p = packet_creator.create_uint8(2**8)
112
+ p = packet_creator.create_uint8(2**8 - 1)
113
+ p.timestamp = 0
114
+ self.assertEqual(packet_getter.get_uint(p), 2**8 - 1)
115
+ self.assertEqual(p.timestamp, 0)
116
+ p2 = packet_creator.create_uint8(np.uint8(1))
117
+ p2.timestamp = 0
118
+ self.assertEqual(packet_getter.get_uint(p2), 1)
119
+ self.assertEqual(p2.timestamp, 0)
120
+
121
+ def test_uint16_packet(self):
122
+ with self.assertRaisesRegex(OverflowError, 'execeeds the maximum value'):
123
+ p = packet_creator.create_uint16(2**16)
124
+ p = packet_creator.create_uint16(2**16 - 1)
125
+ p.timestamp = 0
126
+ self.assertEqual(packet_getter.get_uint(p), 2**16 - 1)
127
+ self.assertEqual(p.timestamp, 0)
128
+ p2 = packet_creator.create_uint16(np.uint16(1))
129
+ p2.timestamp = 0
130
+ self.assertEqual(packet_getter.get_uint(p2), 1)
131
+ self.assertEqual(p2.timestamp, 0)
132
+
133
+ def test_uint32_packet(self):
134
+ with self.assertRaisesRegex(OverflowError, 'execeeds the maximum value'):
135
+ p = packet_creator.create_uint32(2**32)
136
+ p = packet_creator.create_uint32(2**32 - 1)
137
+ p.timestamp = 0
138
+ self.assertEqual(packet_getter.get_uint(p), 2**32 - 1)
139
+ self.assertEqual(p.timestamp, 0)
140
+ p2 = packet_creator.create_uint32(np.uint32(1))
141
+ p2.timestamp = 0
142
+ self.assertEqual(packet_getter.get_uint(p2), 1)
143
+ self.assertEqual(p2.timestamp, 0)
144
+
145
+ def test_uint64_packet(self):
146
+ p = packet_creator.create_uint64(2**64 - 1)
147
+ p.timestamp = 0
148
+ self.assertEqual(packet_getter.get_uint(p), 2**64 - 1)
149
+ self.assertEqual(p.timestamp, 0)
150
+ p2 = packet_creator.create_uint64(np.uint64(1))
151
+ p2.timestamp = 0
152
+ self.assertEqual(packet_getter.get_uint(p2), 1)
153
+ self.assertEqual(p2.timestamp, 0)
154
+
155
+ def test_float_packet(self):
156
+ p = packet_creator.create_float(0.42)
157
+ p.timestamp = 0
158
+ self.assertAlmostEqual(packet_getter.get_float(p), 0.42)
159
+ self.assertEqual(p.timestamp, 0)
160
+ p2 = packet_creator.create_float(float(0.42))
161
+ p2.timestamp = 0
162
+ self.assertAlmostEqual(packet_getter.get_float(p2), 0.42)
163
+ self.assertEqual(p2.timestamp, 0)
164
+
165
+ def test_double_packet(self):
166
+ p = packet_creator.create_double(0.42)
167
+ p.timestamp = 0
168
+ self.assertAlmostEqual(packet_getter.get_float(p), 0.42)
169
+ self.assertEqual(p.timestamp, 0)
170
+ p2 = packet_creator.create_double(np.double(0.42))
171
+ p2.timestamp = 0
172
+ self.assertAlmostEqual(packet_getter.get_float(p2), 0.42)
173
+ self.assertEqual(p2.timestamp, 0)
174
+
175
+ def test_detection_proto_packet(self):
176
+ detection = detection_pb2.Detection()
177
+ text_format.Parse('score: 0.5', detection)
178
+ p = packet_creator.create_proto(detection).at(100)
179
+
180
+ def test_string_packet(self):
181
+ p = packet_creator.create_string('abc').at(100)
182
+ self.assertEqual(packet_getter.get_str(p), 'abc')
183
+ self.assertEqual(p.timestamp, 100)
184
+ p.timestamp = 200
185
+ self.assertEqual(p.timestamp, 200)
186
+
187
+ def test_bytes_packet(self):
188
+ p = packet_creator.create_string(b'xd0\xba\xd0').at(300)
189
+ self.assertEqual(packet_getter.get_bytes(p), b'xd0\xba\xd0')
190
+ self.assertEqual(p.timestamp, 300)
191
+
192
+ def test_int_array_packet(self):
193
+ p = packet_creator.create_int_array([1, 2, 3]).at(100)
194
+ self.assertEqual(p.timestamp, 100)
195
+
196
+ def test_float_array_packet(self):
197
+ p = packet_creator.create_float_array([0.1, 0.2, 0.3]).at(100)
198
+ self.assertEqual(p.timestamp, 100)
199
+
200
+ def test_int_vector_packet(self):
201
+ p = packet_creator.create_int_vector([1, 2, 3]).at(100)
202
+ self.assertEqual(packet_getter.get_int_list(p), [1, 2, 3])
203
+ self.assertEqual(p.timestamp, 100)
204
+
205
+ def test_float_vector_packet(self):
206
+ p = packet_creator.create_float_vector([0.1, 0.2, 0.3]).at(100)
207
+ output_list = packet_getter.get_float_list(p)
208
+ self.assertAlmostEqual(output_list[0], 0.1)
209
+ self.assertAlmostEqual(output_list[1], 0.2)
210
+ self.assertAlmostEqual(output_list[2], 0.3)
211
+ self.assertEqual(p.timestamp, 100)
212
+
213
+ def test_image_vector_packet(self):
214
+ w, h, offset = 80, 40, 10
215
+ mat = np.random.randint(2**8 - 1, size=(h, w, 3), dtype=np.uint8)
216
+ p = packet_creator.create_image_vector([
217
+ Image(image_format=ImageFormat.SRGB, data=mat),
218
+ Image(
219
+ image_format=ImageFormat.SRGB,
220
+ data=np.ascontiguousarray(mat[offset:-offset, offset:-offset, :]))
221
+ ]).at(100)
222
+ output_list = packet_getter.get_image_list(p)
223
+ self.assertLen(output_list, 2)
224
+ self.assertTrue(np.array_equal(output_list[0].numpy_view(), mat))
225
+ self.assertTrue(
226
+ np.array_equal(output_list[1].numpy_view(), mat[offset:-offset,
227
+ offset:-offset, :]))
228
+ self.assertEqual(p.timestamp, 100)
229
+
230
+ def test_string_vector_packet(self):
231
+ p = packet_creator.create_string_vector(['a', 'b', 'c']).at(100)
232
+ output_list = packet_getter.get_str_list(p)
233
+ self.assertEqual(output_list[0], 'a')
234
+ self.assertEqual(output_list[1], 'b')
235
+ self.assertEqual(output_list[2], 'c')
236
+ self.assertEqual(p.timestamp, 100)
237
+
238
+ def test_packet_vector_packet(self):
239
+ p = packet_creator.create_packet_vector([
240
+ packet_creator.create_float(0.42),
241
+ packet_creator.create_int(42),
242
+ packet_creator.create_string('42')
243
+ ]).at(100)
244
+ output_list = packet_getter.get_packet_list(p)
245
+ self.assertAlmostEqual(packet_getter.get_float(output_list[0]), 0.42)
246
+ self.assertEqual(packet_getter.get_int(output_list[1]), 42)
247
+ self.assertEqual(packet_getter.get_str(output_list[2]), '42')
248
+ self.assertEqual(p.timestamp, 100)
249
+
250
+ def test_string_to_packet_map_packet(self):
251
+ p = packet_creator.create_string_to_packet_map({
252
+ 'float': packet_creator.create_float(0.42),
253
+ 'int': packet_creator.create_int(42),
254
+ 'string': packet_creator.create_string('42')
255
+ }).at(100)
256
+ output_list = packet_getter.get_str_to_packet_dict(p)
257
+ self.assertAlmostEqual(packet_getter.get_float(output_list['float']), 0.42)
258
+ self.assertEqual(packet_getter.get_int(output_list['int']), 42)
259
+ self.assertEqual(packet_getter.get_str(output_list['string']), '42')
260
+ self.assertEqual(p.timestamp, 100)
261
+
262
+ def test_uint8_image_packet(self):
263
+ uint8_img = np.random.randint(
264
+ 2**8 - 1,
265
+ size=(random.randrange(3, 100), random.randrange(3, 100), 3),
266
+ dtype=np.uint8)
267
+ image_frame_packet = packet_creator.create_image_frame(
268
+ image_frame.ImageFrame(
269
+ image_format=image_frame.ImageFormat.SRGB, data=uint8_img))
270
+ output_image_frame = packet_getter.get_image_frame(image_frame_packet)
271
+ self.assertTrue(np.array_equal(output_image_frame.numpy_view(), uint8_img))
272
+ image_packet = packet_creator.create_image(
273
+ Image(image_format=ImageFormat.SRGB, data=uint8_img))
274
+ output_image = packet_getter.get_image(image_packet)
275
+ self.assertTrue(np.array_equal(output_image.numpy_view(), uint8_img))
276
+
277
+ def test_uint16_image_packet(self):
278
+ uint16_img = np.random.randint(
279
+ 2**16 - 1,
280
+ size=(random.randrange(3, 100), random.randrange(3, 100), 4),
281
+ dtype=np.uint16)
282
+ image_frame_packet = packet_creator.create_image_frame(
283
+ ImageFrame(image_format=ImageFormat.SRGBA64, data=uint16_img))
284
+ output_image_frame = packet_getter.get_image_frame(image_frame_packet)
285
+ self.assertTrue(np.array_equal(output_image_frame.numpy_view(), uint16_img))
286
+ image_packet = packet_creator.create_image(
287
+ Image(image_format=ImageFormat.SRGBA64, data=uint16_img))
288
+ output_image = packet_getter.get_image(image_packet)
289
+ self.assertTrue(np.array_equal(output_image.numpy_view(), uint16_img))
290
+
291
+ def test_float_image_frame_packet(self):
292
+ float_img = np.float32(
293
+ np.random.random_sample(
294
+ (random.randrange(3, 100), random.randrange(3, 100), 2)))
295
+ image_frame_packet = packet_creator.create_image_frame(
296
+ ImageFrame(image_format=ImageFormat.VEC32F2, data=float_img))
297
+ output_image_frame = packet_getter.get_image_frame(image_frame_packet)
298
+ self.assertTrue(np.allclose(output_image_frame.numpy_view(), float_img))
299
+ image_packet = packet_creator.create_image(
300
+ Image(image_format=ImageFormat.VEC32F2, data=float_img))
301
+ output_image = packet_getter.get_image(image_packet)
302
+ self.assertTrue(np.array_equal(output_image.numpy_view(), float_img))
303
+
304
+ def test_image_frame_packet_creation_copy_mode(self):
305
+ w, h, channels = random.randrange(3, 100), random.randrange(3, 100), 3
306
+ rgb_data = np.random.randint(255, size=(h, w, channels), dtype=np.uint8)
307
+ # rgb_data is c_contiguous.
308
+ self.assertTrue(rgb_data.flags.c_contiguous)
309
+ initial_ref_count = sys.getrefcount(rgb_data)
310
+ p = packet_creator.create_image_frame(
311
+ image_format=ImageFormat.SRGB, data=rgb_data)
312
+ # copy mode doesn't increase the ref count of the data.
313
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
314
+
315
+ rgb_data = rgb_data[:, :, ::-1]
316
+ # rgb_data is now not c_contiguous. But, copy mode shouldn't be affected.
317
+ self.assertFalse(rgb_data.flags.c_contiguous)
318
+ initial_ref_count = sys.getrefcount(rgb_data)
319
+ p = packet_creator.create_image_frame(
320
+ image_format=ImageFormat.SRGB, data=rgb_data)
321
+ # copy mode doesn't increase the ref count of the data.
322
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
323
+
324
+ output_frame = packet_getter.get_image_frame(p)
325
+ self.assertEqual(output_frame.height, h)
326
+ self.assertEqual(output_frame.width, w)
327
+ self.assertEqual(output_frame.channels, channels)
328
+ self.assertTrue(np.array_equal(output_frame.numpy_view(), rgb_data))
329
+
330
+ del p
331
+ del output_frame
332
+ gc.collect()
333
+ # Destroying the packet also doesn't affect the ref count becuase of the
334
+ # copy mode.
335
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
336
+
337
+ def test_image_frame_packet_creation_reference_mode(self):
338
+ w, h, channels = random.randrange(3, 100), random.randrange(3, 100), 3
339
+ rgb_data = np.random.randint(255, size=(h, w, channels), dtype=np.uint8)
340
+ rgb_data.flags.writeable = False
341
+ initial_ref_count = sys.getrefcount(rgb_data)
342
+ image_frame_packet = packet_creator.create_image_frame(
343
+ image_format=ImageFormat.SRGB, data=rgb_data)
344
+ # Reference mode increase the ref count of the rgb_data by 1.
345
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count + 1)
346
+ del image_frame_packet
347
+ gc.collect()
348
+ # Deleting image_frame_packet should decrese the ref count of rgb_data by 1.
349
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
350
+ rgb_data_copy = np.copy(rgb_data)
351
+ # rgb_data_copy is a copy of rgb_data and should not increase the ref count.
352
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
353
+ text_config = """
354
+ node {
355
+ calculator: 'PassThroughCalculator'
356
+ input_side_packet: "in"
357
+ output_side_packet: "out"
358
+ }
359
+ """
360
+ graph = CalculatorGraph(graph_config=text_config)
361
+ graph.start_run(
362
+ input_side_packets={
363
+ 'in':
364
+ packet_creator.create_image_frame(
365
+ image_format=ImageFormat.SRGB, data=rgb_data)
366
+ })
367
+ # reference mode increase the ref count of the rgb_data by 1.
368
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count + 1)
369
+ graph.wait_until_done()
370
+ output_packet = graph.get_output_side_packet('out')
371
+ del rgb_data
372
+ del graph
373
+ gc.collect()
374
+ # The pixel data of the output image frame packet should still be valid
375
+ # after the graph and the original rgb_data data are deleted.
376
+ self.assertTrue(
377
+ np.array_equal(
378
+ packet_getter.get_image_frame(output_packet).numpy_view(),
379
+ rgb_data_copy))
380
+
381
+ def test_image_frame_packet_copy_creation_with_cropping(self):
382
+ w, h, channels = random.randrange(40, 100), random.randrange(40, 100), 3
383
+ channels, offset = 3, 10
384
+ rgb_data = np.random.randint(255, size=(h, w, channels), dtype=np.uint8)
385
+ initial_ref_count = sys.getrefcount(rgb_data)
386
+ p = packet_creator.create_image_frame(
387
+ image_format=ImageFormat.SRGB,
388
+ data=rgb_data[offset:-offset, offset:-offset, :])
389
+ # copy mode doesn't increase the ref count of the data.
390
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
391
+ output_frame = packet_getter.get_image_frame(p)
392
+ self.assertEqual(output_frame.height, h - 2 * offset)
393
+ self.assertEqual(output_frame.width, w - 2 * offset)
394
+ self.assertEqual(output_frame.channels, channels)
395
+ self.assertTrue(
396
+ np.array_equal(rgb_data[offset:-offset, offset:-offset, :],
397
+ output_frame.numpy_view()))
398
+ del p
399
+ del output_frame
400
+ gc.collect()
401
+ # Destroying the packet also doesn't affect the ref count becuase of the
402
+ # copy mode.
403
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
404
+
405
+ def test_image_packet_creation_copy_mode(self):
406
+ w, h, channels = random.randrange(3, 100), random.randrange(3, 100), 3
407
+ rgb_data = np.random.randint(255, size=(h, w, channels), dtype=np.uint8)
408
+ # rgb_data is c_contiguous.
409
+ self.assertTrue(rgb_data.flags.c_contiguous)
410
+ initial_ref_count = sys.getrefcount(rgb_data)
411
+ p = packet_creator.create_image(
412
+ image_format=ImageFormat.SRGB, data=rgb_data)
413
+ # copy mode doesn't increase the ref count of the data.
414
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
415
+
416
+ rgb_data = rgb_data[:, :, ::-1]
417
+ # rgb_data is now not c_contiguous. But, copy mode shouldn't be affected.
418
+ self.assertFalse(rgb_data.flags.c_contiguous)
419
+ initial_ref_count = sys.getrefcount(rgb_data)
420
+ p = packet_creator.create_image(
421
+ image_format=ImageFormat.SRGB, data=rgb_data)
422
+ # copy mode doesn't increase the ref count of the data.
423
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
424
+
425
+ output_image = packet_getter.get_image(p)
426
+ self.assertEqual(output_image.height, h)
427
+ self.assertEqual(output_image.width, w)
428
+ self.assertEqual(output_image.channels, channels)
429
+ self.assertTrue(np.array_equal(output_image.numpy_view(), rgb_data))
430
+
431
+ del p
432
+ del output_image
433
+ gc.collect()
434
+ # Destroying the packet also doesn't affect the ref count becuase of the
435
+ # copy mode.
436
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
437
+
438
+ def test_image_packet_creation_reference_mode(self):
439
+ w, h, channels = random.randrange(3, 100), random.randrange(3, 100), 3
440
+ rgb_data = np.random.randint(255, size=(h, w, channels), dtype=np.uint8)
441
+ rgb_data.flags.writeable = False
442
+ initial_ref_count = sys.getrefcount(rgb_data)
443
+ image_packet = packet_creator.create_image(
444
+ image_format=ImageFormat.SRGB, data=rgb_data)
445
+ # Reference mode increase the ref count of the rgb_data by 1.
446
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count + 1)
447
+ del image_packet
448
+ gc.collect()
449
+ # Deleting image_packet should decrese the ref count of rgb_data by 1.
450
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
451
+ rgb_data_copy = np.copy(rgb_data)
452
+ # rgb_data_copy is a copy of rgb_data and should not increase the ref count.
453
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
454
+ text_config = """
455
+ node {
456
+ calculator: 'PassThroughCalculator'
457
+ input_side_packet: "in"
458
+ output_side_packet: "out"
459
+ }
460
+ """
461
+ graph = CalculatorGraph(graph_config=text_config)
462
+ graph.start_run(
463
+ input_side_packets={
464
+ 'in':
465
+ packet_creator.create_image(
466
+ image_format=ImageFormat.SRGB, data=rgb_data)
467
+ })
468
+ # reference mode increase the ref count of the rgb_data by 1.
469
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count + 1)
470
+ graph.wait_until_done()
471
+ output_packet = graph.get_output_side_packet('out')
472
+ del rgb_data
473
+ del graph
474
+ gc.collect()
475
+ # The pixel data of the output image frame packet should still be valid
476
+ # after the graph and the original rgb_data data are deleted.
477
+ self.assertTrue(
478
+ np.array_equal(
479
+ packet_getter.get_image(output_packet).numpy_view(), rgb_data_copy))
480
+
481
+ def test_image_packet_copy_creation_with_cropping(self):
482
+ w, h, channels = random.randrange(40, 100), random.randrange(40, 100), 3
483
+ channels, offset = 3, 10
484
+ rgb_data = np.random.randint(255, size=(h, w, channels), dtype=np.uint8)
485
+ initial_ref_count = sys.getrefcount(rgb_data)
486
+ p = packet_creator.create_image(
487
+ image_format=ImageFormat.SRGB,
488
+ data=rgb_data[offset:-offset, offset:-offset, :])
489
+ # copy mode doesn't increase the ref count of the data.
490
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
491
+ output_image = packet_getter.get_image(p)
492
+ self.assertEqual(output_image.height, h - 2 * offset)
493
+ self.assertEqual(output_image.width, w - 2 * offset)
494
+ self.assertEqual(output_image.channels, channels)
495
+ self.assertTrue(
496
+ np.array_equal(rgb_data[offset:-offset, offset:-offset, :],
497
+ output_image.numpy_view()))
498
+ del p
499
+ del output_image
500
+ gc.collect()
501
+ # Destroying the packet also doesn't affect the ref count becuase of the
502
+ # copy mode.
503
+ self.assertEqual(sys.getrefcount(rgb_data), initial_ref_count)
504
+
505
+ def test_matrix_packet(self):
506
+ np_matrix = np.array([[.1, .2, .3], [.4, .5, .6]])
507
+ initial_ref_count = sys.getrefcount(np_matrix)
508
+ p = packet_creator.create_matrix(np_matrix)
509
+ # Copy mode should not increase the ref count of np_matrix.
510
+ self.assertEqual(initial_ref_count, sys.getrefcount(np_matrix))
511
+ output_matrix = packet_getter.get_matrix(p)
512
+ del np_matrix
513
+ gc.collect()
514
+ self.assertTrue(
515
+ np.allclose(output_matrix, np.array([[.1, .2, .3], [.4, .5, .6]])))
516
+
517
+ def test_matrix_packet_with_non_c_contiguous_data(self):
518
+ np_matrix = np.array([[.1, .2, .3], [.4, .5, .6]])[:, ::-1]
519
+ # np_matrix is not c_contiguous.
520
+ self.assertFalse(np_matrix.flags.c_contiguous)
521
+ p = packet_creator.create_matrix(np_matrix)
522
+ initial_ref_count = sys.getrefcount(np_matrix)
523
+ # Copy mode should not increase the ref count of np_matrix.
524
+ self.assertEqual(initial_ref_count, sys.getrefcount(np_matrix))
525
+ output_matrix = packet_getter.get_matrix(p)
526
+ del np_matrix
527
+ gc.collect()
528
+ self.assertTrue(
529
+ np.allclose(output_matrix,
530
+ np.array([[.1, .2, .3], [.4, .5, .6]])[:, ::-1]))
531
+
532
+ if __name__ == '__main__':
533
+ absltest.main()