mediapipe-nightly 0.10.21.post20241223__cp39-cp39-manylinux_2_28_x86_64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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-39-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-39-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-39-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.post20241223.dist-info/LICENSE +218 -0
  587. mediapipe_nightly-0.10.21.post20241223.dist-info/METADATA +199 -0
  588. mediapipe_nightly-0.10.21.post20241223.dist-info/RECORD +593 -0
  589. mediapipe_nightly-0.10.21.post20241223.dist-info/WHEEL +5 -0
  590. mediapipe_nightly-0.10.21.post20241223.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,3251 @@
1
+ import flatbuffers
2
+
3
+ # automatically generated by the FlatBuffers compiler, do not modify
4
+
5
+ # namespace: tflite
6
+
7
+ from flatbuffers.compat import import_numpy
8
+ np = import_numpy()
9
+
10
+ class AssociatedFileType(object):
11
+ UNKNOWN = 0
12
+ DESCRIPTIONS = 1
13
+ TENSOR_AXIS_LABELS = 2
14
+ TENSOR_VALUE_LABELS = 3
15
+ TENSOR_AXIS_SCORE_CALIBRATION = 4
16
+ VOCABULARY = 5
17
+ SCANN_INDEX_FILE = 6
18
+
19
+
20
+ class ColorSpaceType(object):
21
+ UNKNOWN = 0
22
+ RGB = 1
23
+ GRAYSCALE = 2
24
+
25
+
26
+ class BoundingBoxType(object):
27
+ UNKNOWN = 0
28
+ BOUNDARIES = 1
29
+ UPPER_LEFT = 2
30
+ CENTER = 3
31
+
32
+
33
+ class CoordinateType(object):
34
+ RATIO = 0
35
+ PIXEL = 1
36
+
37
+
38
+ class ContentProperties(object):
39
+ NONE = 0
40
+ FeatureProperties = 1
41
+ ImageProperties = 2
42
+ BoundingBoxProperties = 3
43
+ AudioProperties = 4
44
+
45
+ def ContentPropertiesCreator(unionType, table):
46
+ from flatbuffers.table import Table
47
+ if not isinstance(table, Table):
48
+ return None
49
+ if unionType == ContentProperties().FeatureProperties:
50
+ return FeaturePropertiesT.InitFromBuf(table.Bytes, table.Pos)
51
+ if unionType == ContentProperties().ImageProperties:
52
+ return ImagePropertiesT.InitFromBuf(table.Bytes, table.Pos)
53
+ if unionType == ContentProperties().BoundingBoxProperties:
54
+ return BoundingBoxPropertiesT.InitFromBuf(table.Bytes, table.Pos)
55
+ if unionType == ContentProperties().AudioProperties:
56
+ return AudioPropertiesT.InitFromBuf(table.Bytes, table.Pos)
57
+ return None
58
+
59
+
60
+ class ScoreTransformationType(object):
61
+ IDENTITY = 0
62
+ LOG = 1
63
+ INVERSE_LOGISTIC = 2
64
+
65
+
66
+ class ProcessUnitOptions(object):
67
+ NONE = 0
68
+ NormalizationOptions = 1
69
+ ScoreCalibrationOptions = 2
70
+ ScoreThresholdingOptions = 3
71
+ BertTokenizerOptions = 4
72
+ SentencePieceTokenizerOptions = 5
73
+ RegexTokenizerOptions = 6
74
+
75
+ def ProcessUnitOptionsCreator(unionType, table):
76
+ from flatbuffers.table import Table
77
+ if not isinstance(table, Table):
78
+ return None
79
+ if unionType == ProcessUnitOptions().NormalizationOptions:
80
+ return NormalizationOptionsT.InitFromBuf(table.Bytes, table.Pos)
81
+ if unionType == ProcessUnitOptions().ScoreCalibrationOptions:
82
+ return ScoreCalibrationOptionsT.InitFromBuf(table.Bytes, table.Pos)
83
+ if unionType == ProcessUnitOptions().ScoreThresholdingOptions:
84
+ return ScoreThresholdingOptionsT.InitFromBuf(table.Bytes, table.Pos)
85
+ if unionType == ProcessUnitOptions().BertTokenizerOptions:
86
+ return BertTokenizerOptionsT.InitFromBuf(table.Bytes, table.Pos)
87
+ if unionType == ProcessUnitOptions().SentencePieceTokenizerOptions:
88
+ return SentencePieceTokenizerOptionsT.InitFromBuf(table.Bytes, table.Pos)
89
+ if unionType == ProcessUnitOptions().RegexTokenizerOptions:
90
+ return RegexTokenizerOptionsT.InitFromBuf(table.Bytes, table.Pos)
91
+ return None
92
+
93
+
94
+ class AssociatedFile(object):
95
+ __slots__ = ['_tab']
96
+
97
+ @classmethod
98
+ def GetRootAs(cls, buf, offset=0):
99
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
100
+ x = AssociatedFile()
101
+ x.Init(buf, n + offset)
102
+ return x
103
+
104
+ @classmethod
105
+ def GetRootAsAssociatedFile(cls, buf, offset=0):
106
+ """This method is deprecated. Please switch to GetRootAs."""
107
+ return cls.GetRootAs(buf, offset)
108
+ @classmethod
109
+ def AssociatedFileBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
110
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
111
+
112
+ # AssociatedFile
113
+ def Init(self, buf, pos):
114
+ self._tab = flatbuffers.table.Table(buf, pos)
115
+
116
+ # AssociatedFile
117
+ def Name(self):
118
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
119
+ if o != 0:
120
+ return self._tab.String(o + self._tab.Pos)
121
+ return None
122
+
123
+ # AssociatedFile
124
+ def Description(self):
125
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
126
+ if o != 0:
127
+ return self._tab.String(o + self._tab.Pos)
128
+ return None
129
+
130
+ # AssociatedFile
131
+ def Type(self):
132
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
133
+ if o != 0:
134
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
135
+ return 0
136
+
137
+ # AssociatedFile
138
+ def Locale(self):
139
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
140
+ if o != 0:
141
+ return self._tab.String(o + self._tab.Pos)
142
+ return None
143
+
144
+ # AssociatedFile
145
+ def Version(self):
146
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
147
+ if o != 0:
148
+ return self._tab.String(o + self._tab.Pos)
149
+ return None
150
+
151
+ def AssociatedFileStart(builder):
152
+ builder.StartObject(5)
153
+
154
+ def AssociatedFileAddName(builder, name):
155
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
156
+
157
+ def AssociatedFileAddDescription(builder, description):
158
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(description), 0)
159
+
160
+ def AssociatedFileAddType(builder, type):
161
+ builder.PrependInt8Slot(2, type, 0)
162
+
163
+ def AssociatedFileAddLocale(builder, locale):
164
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(locale), 0)
165
+
166
+ def AssociatedFileAddVersion(builder, version):
167
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(version), 0)
168
+
169
+ def AssociatedFileEnd(builder):
170
+ return builder.EndObject()
171
+
172
+
173
+
174
+ class AssociatedFileT(object):
175
+
176
+ # AssociatedFileT
177
+ def __init__(self):
178
+ self.name = None # type: str
179
+ self.description = None # type: str
180
+ self.type = 0 # type: int
181
+ self.locale = None # type: str
182
+ self.version = None # type: str
183
+
184
+ @classmethod
185
+ def InitFromBuf(cls, buf, pos):
186
+ associatedFile = AssociatedFile()
187
+ associatedFile.Init(buf, pos)
188
+ return cls.InitFromObj(associatedFile)
189
+
190
+ @classmethod
191
+ def InitFromPackedBuf(cls, buf, pos=0):
192
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
193
+ return cls.InitFromBuf(buf, pos+n)
194
+
195
+ @classmethod
196
+ def InitFromObj(cls, associatedFile):
197
+ x = AssociatedFileT()
198
+ x._UnPack(associatedFile)
199
+ return x
200
+
201
+ # AssociatedFileT
202
+ def _UnPack(self, associatedFile):
203
+ if associatedFile is None:
204
+ return
205
+ self.name = associatedFile.Name()
206
+ self.description = associatedFile.Description()
207
+ self.type = associatedFile.Type()
208
+ self.locale = associatedFile.Locale()
209
+ self.version = associatedFile.Version()
210
+
211
+ # AssociatedFileT
212
+ def Pack(self, builder):
213
+ if self.name is not None:
214
+ name = builder.CreateString(self.name)
215
+ if self.description is not None:
216
+ description = builder.CreateString(self.description)
217
+ if self.locale is not None:
218
+ locale = builder.CreateString(self.locale)
219
+ if self.version is not None:
220
+ version = builder.CreateString(self.version)
221
+ AssociatedFileStart(builder)
222
+ if self.name is not None:
223
+ AssociatedFileAddName(builder, name)
224
+ if self.description is not None:
225
+ AssociatedFileAddDescription(builder, description)
226
+ AssociatedFileAddType(builder, self.type)
227
+ if self.locale is not None:
228
+ AssociatedFileAddLocale(builder, locale)
229
+ if self.version is not None:
230
+ AssociatedFileAddVersion(builder, version)
231
+ associatedFile = AssociatedFileEnd(builder)
232
+ return associatedFile
233
+
234
+
235
+ class FeatureProperties(object):
236
+ __slots__ = ['_tab']
237
+
238
+ @classmethod
239
+ def GetRootAs(cls, buf, offset=0):
240
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
241
+ x = FeatureProperties()
242
+ x.Init(buf, n + offset)
243
+ return x
244
+
245
+ @classmethod
246
+ def GetRootAsFeatureProperties(cls, buf, offset=0):
247
+ """This method is deprecated. Please switch to GetRootAs."""
248
+ return cls.GetRootAs(buf, offset)
249
+ @classmethod
250
+ def FeaturePropertiesBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
251
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
252
+
253
+ # FeatureProperties
254
+ def Init(self, buf, pos):
255
+ self._tab = flatbuffers.table.Table(buf, pos)
256
+
257
+ def FeaturePropertiesStart(builder):
258
+ builder.StartObject(0)
259
+
260
+ def FeaturePropertiesEnd(builder):
261
+ return builder.EndObject()
262
+
263
+
264
+
265
+ class FeaturePropertiesT(object):
266
+
267
+ # FeaturePropertiesT
268
+ def __init__(self):
269
+ pass
270
+
271
+ @classmethod
272
+ def InitFromBuf(cls, buf, pos):
273
+ featureProperties = FeatureProperties()
274
+ featureProperties.Init(buf, pos)
275
+ return cls.InitFromObj(featureProperties)
276
+
277
+ @classmethod
278
+ def InitFromPackedBuf(cls, buf, pos=0):
279
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
280
+ return cls.InitFromBuf(buf, pos+n)
281
+
282
+ @classmethod
283
+ def InitFromObj(cls, featureProperties):
284
+ x = FeaturePropertiesT()
285
+ x._UnPack(featureProperties)
286
+ return x
287
+
288
+ # FeaturePropertiesT
289
+ def _UnPack(self, featureProperties):
290
+ if featureProperties is None:
291
+ return
292
+
293
+ # FeaturePropertiesT
294
+ def Pack(self, builder):
295
+ FeaturePropertiesStart(builder)
296
+ featureProperties = FeaturePropertiesEnd(builder)
297
+ return featureProperties
298
+
299
+
300
+ class ImageSize(object):
301
+ __slots__ = ['_tab']
302
+
303
+ @classmethod
304
+ def GetRootAs(cls, buf, offset=0):
305
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
306
+ x = ImageSize()
307
+ x.Init(buf, n + offset)
308
+ return x
309
+
310
+ @classmethod
311
+ def GetRootAsImageSize(cls, buf, offset=0):
312
+ """This method is deprecated. Please switch to GetRootAs."""
313
+ return cls.GetRootAs(buf, offset)
314
+ @classmethod
315
+ def ImageSizeBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
316
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
317
+
318
+ # ImageSize
319
+ def Init(self, buf, pos):
320
+ self._tab = flatbuffers.table.Table(buf, pos)
321
+
322
+ # ImageSize
323
+ def Width(self):
324
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
325
+ if o != 0:
326
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
327
+ return 0
328
+
329
+ # ImageSize
330
+ def Height(self):
331
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
332
+ if o != 0:
333
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
334
+ return 0
335
+
336
+ def ImageSizeStart(builder):
337
+ builder.StartObject(2)
338
+
339
+ def ImageSizeAddWidth(builder, width):
340
+ builder.PrependUint32Slot(0, width, 0)
341
+
342
+ def ImageSizeAddHeight(builder, height):
343
+ builder.PrependUint32Slot(1, height, 0)
344
+
345
+ def ImageSizeEnd(builder):
346
+ return builder.EndObject()
347
+
348
+
349
+
350
+ class ImageSizeT(object):
351
+
352
+ # ImageSizeT
353
+ def __init__(self):
354
+ self.width = 0 # type: int
355
+ self.height = 0 # type: int
356
+
357
+ @classmethod
358
+ def InitFromBuf(cls, buf, pos):
359
+ imageSize = ImageSize()
360
+ imageSize.Init(buf, pos)
361
+ return cls.InitFromObj(imageSize)
362
+
363
+ @classmethod
364
+ def InitFromPackedBuf(cls, buf, pos=0):
365
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
366
+ return cls.InitFromBuf(buf, pos+n)
367
+
368
+ @classmethod
369
+ def InitFromObj(cls, imageSize):
370
+ x = ImageSizeT()
371
+ x._UnPack(imageSize)
372
+ return x
373
+
374
+ # ImageSizeT
375
+ def _UnPack(self, imageSize):
376
+ if imageSize is None:
377
+ return
378
+ self.width = imageSize.Width()
379
+ self.height = imageSize.Height()
380
+
381
+ # ImageSizeT
382
+ def Pack(self, builder):
383
+ ImageSizeStart(builder)
384
+ ImageSizeAddWidth(builder, self.width)
385
+ ImageSizeAddHeight(builder, self.height)
386
+ imageSize = ImageSizeEnd(builder)
387
+ return imageSize
388
+
389
+
390
+ class ImageProperties(object):
391
+ __slots__ = ['_tab']
392
+
393
+ @classmethod
394
+ def GetRootAs(cls, buf, offset=0):
395
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
396
+ x = ImageProperties()
397
+ x.Init(buf, n + offset)
398
+ return x
399
+
400
+ @classmethod
401
+ def GetRootAsImageProperties(cls, buf, offset=0):
402
+ """This method is deprecated. Please switch to GetRootAs."""
403
+ return cls.GetRootAs(buf, offset)
404
+ @classmethod
405
+ def ImagePropertiesBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
406
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
407
+
408
+ # ImageProperties
409
+ def Init(self, buf, pos):
410
+ self._tab = flatbuffers.table.Table(buf, pos)
411
+
412
+ # ImageProperties
413
+ def ColorSpace(self):
414
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
415
+ if o != 0:
416
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
417
+ return 0
418
+
419
+ # ImageProperties
420
+ def DefaultSize(self):
421
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
422
+ if o != 0:
423
+ x = self._tab.Indirect(o + self._tab.Pos)
424
+ obj = ImageSize()
425
+ obj.Init(self._tab.Bytes, x)
426
+ return obj
427
+ return None
428
+
429
+ def ImagePropertiesStart(builder):
430
+ builder.StartObject(2)
431
+
432
+ def ImagePropertiesAddColorSpace(builder, colorSpace):
433
+ builder.PrependInt8Slot(0, colorSpace, 0)
434
+
435
+ def ImagePropertiesAddDefaultSize(builder, defaultSize):
436
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(defaultSize), 0)
437
+
438
+ def ImagePropertiesEnd(builder):
439
+ return builder.EndObject()
440
+
441
+
442
+ try:
443
+ from typing import Optional
444
+ except:
445
+ pass
446
+
447
+ class ImagePropertiesT(object):
448
+
449
+ # ImagePropertiesT
450
+ def __init__(self):
451
+ self.colorSpace = 0 # type: int
452
+ self.defaultSize = None # type: Optional[ImageSizeT]
453
+
454
+ @classmethod
455
+ def InitFromBuf(cls, buf, pos):
456
+ imageProperties = ImageProperties()
457
+ imageProperties.Init(buf, pos)
458
+ return cls.InitFromObj(imageProperties)
459
+
460
+ @classmethod
461
+ def InitFromPackedBuf(cls, buf, pos=0):
462
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
463
+ return cls.InitFromBuf(buf, pos+n)
464
+
465
+ @classmethod
466
+ def InitFromObj(cls, imageProperties):
467
+ x = ImagePropertiesT()
468
+ x._UnPack(imageProperties)
469
+ return x
470
+
471
+ # ImagePropertiesT
472
+ def _UnPack(self, imageProperties):
473
+ if imageProperties is None:
474
+ return
475
+ self.colorSpace = imageProperties.ColorSpace()
476
+ if imageProperties.DefaultSize() is not None:
477
+ self.defaultSize = ImageSizeT.InitFromObj(imageProperties.DefaultSize())
478
+
479
+ # ImagePropertiesT
480
+ def Pack(self, builder):
481
+ if self.defaultSize is not None:
482
+ defaultSize = self.defaultSize.Pack(builder)
483
+ ImagePropertiesStart(builder)
484
+ ImagePropertiesAddColorSpace(builder, self.colorSpace)
485
+ if self.defaultSize is not None:
486
+ ImagePropertiesAddDefaultSize(builder, defaultSize)
487
+ imageProperties = ImagePropertiesEnd(builder)
488
+ return imageProperties
489
+
490
+
491
+ class AudioProperties(object):
492
+ __slots__ = ['_tab']
493
+
494
+ @classmethod
495
+ def GetRootAs(cls, buf, offset=0):
496
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
497
+ x = AudioProperties()
498
+ x.Init(buf, n + offset)
499
+ return x
500
+
501
+ @classmethod
502
+ def GetRootAsAudioProperties(cls, buf, offset=0):
503
+ """This method is deprecated. Please switch to GetRootAs."""
504
+ return cls.GetRootAs(buf, offset)
505
+ @classmethod
506
+ def AudioPropertiesBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
507
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
508
+
509
+ # AudioProperties
510
+ def Init(self, buf, pos):
511
+ self._tab = flatbuffers.table.Table(buf, pos)
512
+
513
+ # AudioProperties
514
+ def SampleRate(self):
515
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
516
+ if o != 0:
517
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
518
+ return 0
519
+
520
+ # AudioProperties
521
+ def Channels(self):
522
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
523
+ if o != 0:
524
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, o + self._tab.Pos)
525
+ return 0
526
+
527
+ def AudioPropertiesStart(builder):
528
+ builder.StartObject(2)
529
+
530
+ def AudioPropertiesAddSampleRate(builder, sampleRate):
531
+ builder.PrependUint32Slot(0, sampleRate, 0)
532
+
533
+ def AudioPropertiesAddChannels(builder, channels):
534
+ builder.PrependUint32Slot(1, channels, 0)
535
+
536
+ def AudioPropertiesEnd(builder):
537
+ return builder.EndObject()
538
+
539
+
540
+
541
+ class AudioPropertiesT(object):
542
+
543
+ # AudioPropertiesT
544
+ def __init__(self):
545
+ self.sampleRate = 0 # type: int
546
+ self.channels = 0 # type: int
547
+
548
+ @classmethod
549
+ def InitFromBuf(cls, buf, pos):
550
+ audioProperties = AudioProperties()
551
+ audioProperties.Init(buf, pos)
552
+ return cls.InitFromObj(audioProperties)
553
+
554
+ @classmethod
555
+ def InitFromPackedBuf(cls, buf, pos=0):
556
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
557
+ return cls.InitFromBuf(buf, pos+n)
558
+
559
+ @classmethod
560
+ def InitFromObj(cls, audioProperties):
561
+ x = AudioPropertiesT()
562
+ x._UnPack(audioProperties)
563
+ return x
564
+
565
+ # AudioPropertiesT
566
+ def _UnPack(self, audioProperties):
567
+ if audioProperties is None:
568
+ return
569
+ self.sampleRate = audioProperties.SampleRate()
570
+ self.channels = audioProperties.Channels()
571
+
572
+ # AudioPropertiesT
573
+ def Pack(self, builder):
574
+ AudioPropertiesStart(builder)
575
+ AudioPropertiesAddSampleRate(builder, self.sampleRate)
576
+ AudioPropertiesAddChannels(builder, self.channels)
577
+ audioProperties = AudioPropertiesEnd(builder)
578
+ return audioProperties
579
+
580
+
581
+ class BoundingBoxProperties(object):
582
+ __slots__ = ['_tab']
583
+
584
+ @classmethod
585
+ def GetRootAs(cls, buf, offset=0):
586
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
587
+ x = BoundingBoxProperties()
588
+ x.Init(buf, n + offset)
589
+ return x
590
+
591
+ @classmethod
592
+ def GetRootAsBoundingBoxProperties(cls, buf, offset=0):
593
+ """This method is deprecated. Please switch to GetRootAs."""
594
+ return cls.GetRootAs(buf, offset)
595
+ @classmethod
596
+ def BoundingBoxPropertiesBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
597
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
598
+
599
+ # BoundingBoxProperties
600
+ def Init(self, buf, pos):
601
+ self._tab = flatbuffers.table.Table(buf, pos)
602
+
603
+ # BoundingBoxProperties
604
+ def Index(self, j):
605
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
606
+ if o != 0:
607
+ a = self._tab.Vector(o)
608
+ return self._tab.Get(flatbuffers.number_types.Uint32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
609
+ return 0
610
+
611
+ # BoundingBoxProperties
612
+ def IndexAsNumpy(self):
613
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
614
+ if o != 0:
615
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint32Flags, o)
616
+ return 0
617
+
618
+ # BoundingBoxProperties
619
+ def IndexLength(self):
620
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
621
+ if o != 0:
622
+ return self._tab.VectorLen(o)
623
+ return 0
624
+
625
+ # BoundingBoxProperties
626
+ def IndexIsNone(self):
627
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
628
+ return o == 0
629
+
630
+ # BoundingBoxProperties
631
+ def Type(self):
632
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
633
+ if o != 0:
634
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
635
+ return 0
636
+
637
+ # BoundingBoxProperties
638
+ def CoordinateType(self):
639
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
640
+ if o != 0:
641
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
642
+ return 0
643
+
644
+ def BoundingBoxPropertiesStart(builder):
645
+ builder.StartObject(3)
646
+
647
+ def BoundingBoxPropertiesAddIndex(builder, index):
648
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(index), 0)
649
+
650
+ def BoundingBoxPropertiesStartIndexVector(builder, numElems):
651
+ return builder.StartVector(4, numElems, 4)
652
+
653
+ def BoundingBoxPropertiesAddType(builder, type):
654
+ builder.PrependInt8Slot(1, type, 0)
655
+
656
+ def BoundingBoxPropertiesAddCoordinateType(builder, coordinateType):
657
+ builder.PrependInt8Slot(2, coordinateType, 0)
658
+
659
+ def BoundingBoxPropertiesEnd(builder):
660
+ return builder.EndObject()
661
+
662
+
663
+ try:
664
+ from typing import List
665
+ except:
666
+ pass
667
+
668
+ class BoundingBoxPropertiesT(object):
669
+
670
+ # BoundingBoxPropertiesT
671
+ def __init__(self):
672
+ self.index = None # type: List[int]
673
+ self.type = 0 # type: int
674
+ self.coordinateType = 0 # type: int
675
+
676
+ @classmethod
677
+ def InitFromBuf(cls, buf, pos):
678
+ boundingBoxProperties = BoundingBoxProperties()
679
+ boundingBoxProperties.Init(buf, pos)
680
+ return cls.InitFromObj(boundingBoxProperties)
681
+
682
+ @classmethod
683
+ def InitFromPackedBuf(cls, buf, pos=0):
684
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
685
+ return cls.InitFromBuf(buf, pos+n)
686
+
687
+ @classmethod
688
+ def InitFromObj(cls, boundingBoxProperties):
689
+ x = BoundingBoxPropertiesT()
690
+ x._UnPack(boundingBoxProperties)
691
+ return x
692
+
693
+ # BoundingBoxPropertiesT
694
+ def _UnPack(self, boundingBoxProperties):
695
+ if boundingBoxProperties is None:
696
+ return
697
+ if not boundingBoxProperties.IndexIsNone():
698
+ if np is None:
699
+ self.index = []
700
+ for i in range(boundingBoxProperties.IndexLength()):
701
+ self.index.append(boundingBoxProperties.Index(i))
702
+ else:
703
+ self.index = boundingBoxProperties.IndexAsNumpy()
704
+ self.type = boundingBoxProperties.Type()
705
+ self.coordinateType = boundingBoxProperties.CoordinateType()
706
+
707
+ # BoundingBoxPropertiesT
708
+ def Pack(self, builder):
709
+ if self.index is not None:
710
+ if np is not None and type(self.index) is np.ndarray:
711
+ index = builder.CreateNumpyVector(self.index)
712
+ else:
713
+ BoundingBoxPropertiesStartIndexVector(builder, len(self.index))
714
+ for i in reversed(range(len(self.index))):
715
+ builder.PrependUint32(self.index[i])
716
+ index = builder.EndVector()
717
+ BoundingBoxPropertiesStart(builder)
718
+ if self.index is not None:
719
+ BoundingBoxPropertiesAddIndex(builder, index)
720
+ BoundingBoxPropertiesAddType(builder, self.type)
721
+ BoundingBoxPropertiesAddCoordinateType(builder, self.coordinateType)
722
+ boundingBoxProperties = BoundingBoxPropertiesEnd(builder)
723
+ return boundingBoxProperties
724
+
725
+
726
+ class ValueRange(object):
727
+ __slots__ = ['_tab']
728
+
729
+ @classmethod
730
+ def GetRootAs(cls, buf, offset=0):
731
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
732
+ x = ValueRange()
733
+ x.Init(buf, n + offset)
734
+ return x
735
+
736
+ @classmethod
737
+ def GetRootAsValueRange(cls, buf, offset=0):
738
+ """This method is deprecated. Please switch to GetRootAs."""
739
+ return cls.GetRootAs(buf, offset)
740
+ @classmethod
741
+ def ValueRangeBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
742
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
743
+
744
+ # ValueRange
745
+ def Init(self, buf, pos):
746
+ self._tab = flatbuffers.table.Table(buf, pos)
747
+
748
+ # ValueRange
749
+ def Min(self):
750
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
751
+ if o != 0:
752
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
753
+ return 0
754
+
755
+ # ValueRange
756
+ def Max(self):
757
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
758
+ if o != 0:
759
+ return self._tab.Get(flatbuffers.number_types.Int32Flags, o + self._tab.Pos)
760
+ return 0
761
+
762
+ def ValueRangeStart(builder):
763
+ builder.StartObject(2)
764
+
765
+ def ValueRangeAddMin(builder, min):
766
+ builder.PrependInt32Slot(0, min, 0)
767
+
768
+ def ValueRangeAddMax(builder, max):
769
+ builder.PrependInt32Slot(1, max, 0)
770
+
771
+ def ValueRangeEnd(builder):
772
+ return builder.EndObject()
773
+
774
+
775
+
776
+ class ValueRangeT(object):
777
+
778
+ # ValueRangeT
779
+ def __init__(self):
780
+ self.min = 0 # type: int
781
+ self.max = 0 # type: int
782
+
783
+ @classmethod
784
+ def InitFromBuf(cls, buf, pos):
785
+ valueRange = ValueRange()
786
+ valueRange.Init(buf, pos)
787
+ return cls.InitFromObj(valueRange)
788
+
789
+ @classmethod
790
+ def InitFromPackedBuf(cls, buf, pos=0):
791
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
792
+ return cls.InitFromBuf(buf, pos+n)
793
+
794
+ @classmethod
795
+ def InitFromObj(cls, valueRange):
796
+ x = ValueRangeT()
797
+ x._UnPack(valueRange)
798
+ return x
799
+
800
+ # ValueRangeT
801
+ def _UnPack(self, valueRange):
802
+ if valueRange is None:
803
+ return
804
+ self.min = valueRange.Min()
805
+ self.max = valueRange.Max()
806
+
807
+ # ValueRangeT
808
+ def Pack(self, builder):
809
+ ValueRangeStart(builder)
810
+ ValueRangeAddMin(builder, self.min)
811
+ ValueRangeAddMax(builder, self.max)
812
+ valueRange = ValueRangeEnd(builder)
813
+ return valueRange
814
+
815
+
816
+ class Content(object):
817
+ __slots__ = ['_tab']
818
+
819
+ @classmethod
820
+ def GetRootAs(cls, buf, offset=0):
821
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
822
+ x = Content()
823
+ x.Init(buf, n + offset)
824
+ return x
825
+
826
+ @classmethod
827
+ def GetRootAsContent(cls, buf, offset=0):
828
+ """This method is deprecated. Please switch to GetRootAs."""
829
+ return cls.GetRootAs(buf, offset)
830
+ @classmethod
831
+ def ContentBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
832
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
833
+
834
+ # Content
835
+ def Init(self, buf, pos):
836
+ self._tab = flatbuffers.table.Table(buf, pos)
837
+
838
+ # Content
839
+ def ContentPropertiesType(self):
840
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
841
+ if o != 0:
842
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
843
+ return 0
844
+
845
+ # Content
846
+ def ContentProperties(self):
847
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
848
+ if o != 0:
849
+ from flatbuffers.table import Table
850
+ obj = Table(bytearray(), 0)
851
+ self._tab.Union(obj, o)
852
+ return obj
853
+ return None
854
+
855
+ # Content
856
+ def Range(self):
857
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
858
+ if o != 0:
859
+ x = self._tab.Indirect(o + self._tab.Pos)
860
+ obj = ValueRange()
861
+ obj.Init(self._tab.Bytes, x)
862
+ return obj
863
+ return None
864
+
865
+ def ContentStart(builder):
866
+ builder.StartObject(3)
867
+
868
+ def ContentAddContentPropertiesType(builder, contentPropertiesType):
869
+ builder.PrependUint8Slot(0, contentPropertiesType, 0)
870
+
871
+ def ContentAddContentProperties(builder, contentProperties):
872
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(contentProperties), 0)
873
+
874
+ def ContentAddRange(builder, range):
875
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(range), 0)
876
+
877
+ def ContentEnd(builder):
878
+ return builder.EndObject()
879
+
880
+
881
+ try:
882
+ from typing import Optional, Union
883
+ except:
884
+ pass
885
+
886
+ class ContentT(object):
887
+
888
+ # ContentT
889
+ def __init__(self):
890
+ self.contentPropertiesType = 0 # type: int
891
+ self.contentProperties = None # type: Union[None, FeaturePropertiesT, ImagePropertiesT, BoundingBoxPropertiesT, AudioPropertiesT]
892
+ self.range = None # type: Optional[ValueRangeT]
893
+
894
+ @classmethod
895
+ def InitFromBuf(cls, buf, pos):
896
+ content = Content()
897
+ content.Init(buf, pos)
898
+ return cls.InitFromObj(content)
899
+
900
+ @classmethod
901
+ def InitFromPackedBuf(cls, buf, pos=0):
902
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
903
+ return cls.InitFromBuf(buf, pos+n)
904
+
905
+ @classmethod
906
+ def InitFromObj(cls, content):
907
+ x = ContentT()
908
+ x._UnPack(content)
909
+ return x
910
+
911
+ # ContentT
912
+ def _UnPack(self, content):
913
+ if content is None:
914
+ return
915
+ self.contentPropertiesType = content.ContentPropertiesType()
916
+ self.contentProperties = ContentPropertiesCreator(self.contentPropertiesType, content.ContentProperties())
917
+ if content.Range() is not None:
918
+ self.range = ValueRangeT.InitFromObj(content.Range())
919
+
920
+ # ContentT
921
+ def Pack(self, builder):
922
+ if self.contentProperties is not None:
923
+ contentProperties = self.contentProperties.Pack(builder)
924
+ if self.range is not None:
925
+ range = self.range.Pack(builder)
926
+ ContentStart(builder)
927
+ ContentAddContentPropertiesType(builder, self.contentPropertiesType)
928
+ if self.contentProperties is not None:
929
+ ContentAddContentProperties(builder, contentProperties)
930
+ if self.range is not None:
931
+ ContentAddRange(builder, range)
932
+ content = ContentEnd(builder)
933
+ return content
934
+
935
+
936
+ class NormalizationOptions(object):
937
+ __slots__ = ['_tab']
938
+
939
+ @classmethod
940
+ def GetRootAs(cls, buf, offset=0):
941
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
942
+ x = NormalizationOptions()
943
+ x.Init(buf, n + offset)
944
+ return x
945
+
946
+ @classmethod
947
+ def GetRootAsNormalizationOptions(cls, buf, offset=0):
948
+ """This method is deprecated. Please switch to GetRootAs."""
949
+ return cls.GetRootAs(buf, offset)
950
+ @classmethod
951
+ def NormalizationOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
952
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
953
+
954
+ # NormalizationOptions
955
+ def Init(self, buf, pos):
956
+ self._tab = flatbuffers.table.Table(buf, pos)
957
+
958
+ # NormalizationOptions
959
+ def Mean(self, j):
960
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
961
+ if o != 0:
962
+ a = self._tab.Vector(o)
963
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
964
+ return 0
965
+
966
+ # NormalizationOptions
967
+ def MeanAsNumpy(self):
968
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
969
+ if o != 0:
970
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o)
971
+ return 0
972
+
973
+ # NormalizationOptions
974
+ def MeanLength(self):
975
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
976
+ if o != 0:
977
+ return self._tab.VectorLen(o)
978
+ return 0
979
+
980
+ # NormalizationOptions
981
+ def MeanIsNone(self):
982
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
983
+ return o == 0
984
+
985
+ # NormalizationOptions
986
+ def Std(self, j):
987
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
988
+ if o != 0:
989
+ a = self._tab.Vector(o)
990
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
991
+ return 0
992
+
993
+ # NormalizationOptions
994
+ def StdAsNumpy(self):
995
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
996
+ if o != 0:
997
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o)
998
+ return 0
999
+
1000
+ # NormalizationOptions
1001
+ def StdLength(self):
1002
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1003
+ if o != 0:
1004
+ return self._tab.VectorLen(o)
1005
+ return 0
1006
+
1007
+ # NormalizationOptions
1008
+ def StdIsNone(self):
1009
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1010
+ return o == 0
1011
+
1012
+ def NormalizationOptionsStart(builder):
1013
+ builder.StartObject(2)
1014
+
1015
+ def NormalizationOptionsAddMean(builder, mean):
1016
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(mean), 0)
1017
+
1018
+ def NormalizationOptionsStartMeanVector(builder, numElems):
1019
+ return builder.StartVector(4, numElems, 4)
1020
+
1021
+ def NormalizationOptionsAddStd(builder, std):
1022
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(std), 0)
1023
+
1024
+ def NormalizationOptionsStartStdVector(builder, numElems):
1025
+ return builder.StartVector(4, numElems, 4)
1026
+
1027
+ def NormalizationOptionsEnd(builder):
1028
+ return builder.EndObject()
1029
+
1030
+
1031
+ try:
1032
+ from typing import List
1033
+ except:
1034
+ pass
1035
+
1036
+ class NormalizationOptionsT(object):
1037
+
1038
+ # NormalizationOptionsT
1039
+ def __init__(self):
1040
+ self.mean = None # type: List[float]
1041
+ self.std = None # type: List[float]
1042
+
1043
+ @classmethod
1044
+ def InitFromBuf(cls, buf, pos):
1045
+ normalizationOptions = NormalizationOptions()
1046
+ normalizationOptions.Init(buf, pos)
1047
+ return cls.InitFromObj(normalizationOptions)
1048
+
1049
+ @classmethod
1050
+ def InitFromPackedBuf(cls, buf, pos=0):
1051
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
1052
+ return cls.InitFromBuf(buf, pos+n)
1053
+
1054
+ @classmethod
1055
+ def InitFromObj(cls, normalizationOptions):
1056
+ x = NormalizationOptionsT()
1057
+ x._UnPack(normalizationOptions)
1058
+ return x
1059
+
1060
+ # NormalizationOptionsT
1061
+ def _UnPack(self, normalizationOptions):
1062
+ if normalizationOptions is None:
1063
+ return
1064
+ if not normalizationOptions.MeanIsNone():
1065
+ if np is None:
1066
+ self.mean = []
1067
+ for i in range(normalizationOptions.MeanLength()):
1068
+ self.mean.append(normalizationOptions.Mean(i))
1069
+ else:
1070
+ self.mean = normalizationOptions.MeanAsNumpy()
1071
+ if not normalizationOptions.StdIsNone():
1072
+ if np is None:
1073
+ self.std = []
1074
+ for i in range(normalizationOptions.StdLength()):
1075
+ self.std.append(normalizationOptions.Std(i))
1076
+ else:
1077
+ self.std = normalizationOptions.StdAsNumpy()
1078
+
1079
+ # NormalizationOptionsT
1080
+ def Pack(self, builder):
1081
+ if self.mean is not None:
1082
+ if np is not None and type(self.mean) is np.ndarray:
1083
+ mean = builder.CreateNumpyVector(self.mean)
1084
+ else:
1085
+ NormalizationOptionsStartMeanVector(builder, len(self.mean))
1086
+ for i in reversed(range(len(self.mean))):
1087
+ builder.PrependFloat32(self.mean[i])
1088
+ mean = builder.EndVector()
1089
+ if self.std is not None:
1090
+ if np is not None and type(self.std) is np.ndarray:
1091
+ std = builder.CreateNumpyVector(self.std)
1092
+ else:
1093
+ NormalizationOptionsStartStdVector(builder, len(self.std))
1094
+ for i in reversed(range(len(self.std))):
1095
+ builder.PrependFloat32(self.std[i])
1096
+ std = builder.EndVector()
1097
+ NormalizationOptionsStart(builder)
1098
+ if self.mean is not None:
1099
+ NormalizationOptionsAddMean(builder, mean)
1100
+ if self.std is not None:
1101
+ NormalizationOptionsAddStd(builder, std)
1102
+ normalizationOptions = NormalizationOptionsEnd(builder)
1103
+ return normalizationOptions
1104
+
1105
+
1106
+ class ScoreCalibrationOptions(object):
1107
+ __slots__ = ['_tab']
1108
+
1109
+ @classmethod
1110
+ def GetRootAs(cls, buf, offset=0):
1111
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1112
+ x = ScoreCalibrationOptions()
1113
+ x.Init(buf, n + offset)
1114
+ return x
1115
+
1116
+ @classmethod
1117
+ def GetRootAsScoreCalibrationOptions(cls, buf, offset=0):
1118
+ """This method is deprecated. Please switch to GetRootAs."""
1119
+ return cls.GetRootAs(buf, offset)
1120
+ @classmethod
1121
+ def ScoreCalibrationOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
1122
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
1123
+
1124
+ # ScoreCalibrationOptions
1125
+ def Init(self, buf, pos):
1126
+ self._tab = flatbuffers.table.Table(buf, pos)
1127
+
1128
+ # ScoreCalibrationOptions
1129
+ def ScoreTransformation(self):
1130
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1131
+ if o != 0:
1132
+ return self._tab.Get(flatbuffers.number_types.Int8Flags, o + self._tab.Pos)
1133
+ return 0
1134
+
1135
+ # ScoreCalibrationOptions
1136
+ def DefaultScore(self):
1137
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1138
+ if o != 0:
1139
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
1140
+ return 0.0
1141
+
1142
+ def ScoreCalibrationOptionsStart(builder):
1143
+ builder.StartObject(2)
1144
+
1145
+ def ScoreCalibrationOptionsAddScoreTransformation(builder, scoreTransformation):
1146
+ builder.PrependInt8Slot(0, scoreTransformation, 0)
1147
+
1148
+ def ScoreCalibrationOptionsAddDefaultScore(builder, defaultScore):
1149
+ builder.PrependFloat32Slot(1, defaultScore, 0.0)
1150
+
1151
+ def ScoreCalibrationOptionsEnd(builder):
1152
+ return builder.EndObject()
1153
+
1154
+
1155
+
1156
+ class ScoreCalibrationOptionsT(object):
1157
+
1158
+ # ScoreCalibrationOptionsT
1159
+ def __init__(self):
1160
+ self.scoreTransformation = 0 # type: int
1161
+ self.defaultScore = 0.0 # type: float
1162
+
1163
+ @classmethod
1164
+ def InitFromBuf(cls, buf, pos):
1165
+ scoreCalibrationOptions = ScoreCalibrationOptions()
1166
+ scoreCalibrationOptions.Init(buf, pos)
1167
+ return cls.InitFromObj(scoreCalibrationOptions)
1168
+
1169
+ @classmethod
1170
+ def InitFromPackedBuf(cls, buf, pos=0):
1171
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
1172
+ return cls.InitFromBuf(buf, pos+n)
1173
+
1174
+ @classmethod
1175
+ def InitFromObj(cls, scoreCalibrationOptions):
1176
+ x = ScoreCalibrationOptionsT()
1177
+ x._UnPack(scoreCalibrationOptions)
1178
+ return x
1179
+
1180
+ # ScoreCalibrationOptionsT
1181
+ def _UnPack(self, scoreCalibrationOptions):
1182
+ if scoreCalibrationOptions is None:
1183
+ return
1184
+ self.scoreTransformation = scoreCalibrationOptions.ScoreTransformation()
1185
+ self.defaultScore = scoreCalibrationOptions.DefaultScore()
1186
+
1187
+ # ScoreCalibrationOptionsT
1188
+ def Pack(self, builder):
1189
+ ScoreCalibrationOptionsStart(builder)
1190
+ ScoreCalibrationOptionsAddScoreTransformation(builder, self.scoreTransformation)
1191
+ ScoreCalibrationOptionsAddDefaultScore(builder, self.defaultScore)
1192
+ scoreCalibrationOptions = ScoreCalibrationOptionsEnd(builder)
1193
+ return scoreCalibrationOptions
1194
+
1195
+
1196
+ class ScoreThresholdingOptions(object):
1197
+ __slots__ = ['_tab']
1198
+
1199
+ @classmethod
1200
+ def GetRootAs(cls, buf, offset=0):
1201
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1202
+ x = ScoreThresholdingOptions()
1203
+ x.Init(buf, n + offset)
1204
+ return x
1205
+
1206
+ @classmethod
1207
+ def GetRootAsScoreThresholdingOptions(cls, buf, offset=0):
1208
+ """This method is deprecated. Please switch to GetRootAs."""
1209
+ return cls.GetRootAs(buf, offset)
1210
+ @classmethod
1211
+ def ScoreThresholdingOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
1212
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
1213
+
1214
+ # ScoreThresholdingOptions
1215
+ def Init(self, buf, pos):
1216
+ self._tab = flatbuffers.table.Table(buf, pos)
1217
+
1218
+ # ScoreThresholdingOptions
1219
+ def GlobalScoreThreshold(self):
1220
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1221
+ if o != 0:
1222
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, o + self._tab.Pos)
1223
+ return 0.0
1224
+
1225
+ def ScoreThresholdingOptionsStart(builder):
1226
+ builder.StartObject(1)
1227
+
1228
+ def ScoreThresholdingOptionsAddGlobalScoreThreshold(builder, globalScoreThreshold):
1229
+ builder.PrependFloat32Slot(0, globalScoreThreshold, 0.0)
1230
+
1231
+ def ScoreThresholdingOptionsEnd(builder):
1232
+ return builder.EndObject()
1233
+
1234
+
1235
+
1236
+ class ScoreThresholdingOptionsT(object):
1237
+
1238
+ # ScoreThresholdingOptionsT
1239
+ def __init__(self):
1240
+ self.globalScoreThreshold = 0.0 # type: float
1241
+
1242
+ @classmethod
1243
+ def InitFromBuf(cls, buf, pos):
1244
+ scoreThresholdingOptions = ScoreThresholdingOptions()
1245
+ scoreThresholdingOptions.Init(buf, pos)
1246
+ return cls.InitFromObj(scoreThresholdingOptions)
1247
+
1248
+ @classmethod
1249
+ def InitFromPackedBuf(cls, buf, pos=0):
1250
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
1251
+ return cls.InitFromBuf(buf, pos+n)
1252
+
1253
+ @classmethod
1254
+ def InitFromObj(cls, scoreThresholdingOptions):
1255
+ x = ScoreThresholdingOptionsT()
1256
+ x._UnPack(scoreThresholdingOptions)
1257
+ return x
1258
+
1259
+ # ScoreThresholdingOptionsT
1260
+ def _UnPack(self, scoreThresholdingOptions):
1261
+ if scoreThresholdingOptions is None:
1262
+ return
1263
+ self.globalScoreThreshold = scoreThresholdingOptions.GlobalScoreThreshold()
1264
+
1265
+ # ScoreThresholdingOptionsT
1266
+ def Pack(self, builder):
1267
+ ScoreThresholdingOptionsStart(builder)
1268
+ ScoreThresholdingOptionsAddGlobalScoreThreshold(builder, self.globalScoreThreshold)
1269
+ scoreThresholdingOptions = ScoreThresholdingOptionsEnd(builder)
1270
+ return scoreThresholdingOptions
1271
+
1272
+
1273
+ class BertTokenizerOptions(object):
1274
+ __slots__ = ['_tab']
1275
+
1276
+ @classmethod
1277
+ def GetRootAs(cls, buf, offset=0):
1278
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1279
+ x = BertTokenizerOptions()
1280
+ x.Init(buf, n + offset)
1281
+ return x
1282
+
1283
+ @classmethod
1284
+ def GetRootAsBertTokenizerOptions(cls, buf, offset=0):
1285
+ """This method is deprecated. Please switch to GetRootAs."""
1286
+ return cls.GetRootAs(buf, offset)
1287
+ @classmethod
1288
+ def BertTokenizerOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
1289
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
1290
+
1291
+ # BertTokenizerOptions
1292
+ def Init(self, buf, pos):
1293
+ self._tab = flatbuffers.table.Table(buf, pos)
1294
+
1295
+ # BertTokenizerOptions
1296
+ def VocabFile(self, j):
1297
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1298
+ if o != 0:
1299
+ x = self._tab.Vector(o)
1300
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1301
+ x = self._tab.Indirect(x)
1302
+ obj = AssociatedFile()
1303
+ obj.Init(self._tab.Bytes, x)
1304
+ return obj
1305
+ return None
1306
+
1307
+ # BertTokenizerOptions
1308
+ def VocabFileLength(self):
1309
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1310
+ if o != 0:
1311
+ return self._tab.VectorLen(o)
1312
+ return 0
1313
+
1314
+ # BertTokenizerOptions
1315
+ def VocabFileIsNone(self):
1316
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1317
+ return o == 0
1318
+
1319
+ def BertTokenizerOptionsStart(builder):
1320
+ builder.StartObject(1)
1321
+
1322
+ def BertTokenizerOptionsAddVocabFile(builder, vocabFile):
1323
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(vocabFile), 0)
1324
+
1325
+ def BertTokenizerOptionsStartVocabFileVector(builder, numElems):
1326
+ return builder.StartVector(4, numElems, 4)
1327
+
1328
+ def BertTokenizerOptionsEnd(builder):
1329
+ return builder.EndObject()
1330
+
1331
+
1332
+ try:
1333
+ from typing import List
1334
+ except:
1335
+ pass
1336
+
1337
+ class BertTokenizerOptionsT(object):
1338
+
1339
+ # BertTokenizerOptionsT
1340
+ def __init__(self):
1341
+ self.vocabFile = None # type: List[AssociatedFileT]
1342
+
1343
+ @classmethod
1344
+ def InitFromBuf(cls, buf, pos):
1345
+ bertTokenizerOptions = BertTokenizerOptions()
1346
+ bertTokenizerOptions.Init(buf, pos)
1347
+ return cls.InitFromObj(bertTokenizerOptions)
1348
+
1349
+ @classmethod
1350
+ def InitFromPackedBuf(cls, buf, pos=0):
1351
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
1352
+ return cls.InitFromBuf(buf, pos+n)
1353
+
1354
+ @classmethod
1355
+ def InitFromObj(cls, bertTokenizerOptions):
1356
+ x = BertTokenizerOptionsT()
1357
+ x._UnPack(bertTokenizerOptions)
1358
+ return x
1359
+
1360
+ # BertTokenizerOptionsT
1361
+ def _UnPack(self, bertTokenizerOptions):
1362
+ if bertTokenizerOptions is None:
1363
+ return
1364
+ if not bertTokenizerOptions.VocabFileIsNone():
1365
+ self.vocabFile = []
1366
+ for i in range(bertTokenizerOptions.VocabFileLength()):
1367
+ if bertTokenizerOptions.VocabFile(i) is None:
1368
+ self.vocabFile.append(None)
1369
+ else:
1370
+ associatedFile_ = AssociatedFileT.InitFromObj(bertTokenizerOptions.VocabFile(i))
1371
+ self.vocabFile.append(associatedFile_)
1372
+
1373
+ # BertTokenizerOptionsT
1374
+ def Pack(self, builder):
1375
+ if self.vocabFile is not None:
1376
+ vocabFilelist = []
1377
+ for i in range(len(self.vocabFile)):
1378
+ vocabFilelist.append(self.vocabFile[i].Pack(builder))
1379
+ BertTokenizerOptionsStartVocabFileVector(builder, len(self.vocabFile))
1380
+ for i in reversed(range(len(self.vocabFile))):
1381
+ builder.PrependUOffsetTRelative(vocabFilelist[i])
1382
+ vocabFile = builder.EndVector()
1383
+ BertTokenizerOptionsStart(builder)
1384
+ if self.vocabFile is not None:
1385
+ BertTokenizerOptionsAddVocabFile(builder, vocabFile)
1386
+ bertTokenizerOptions = BertTokenizerOptionsEnd(builder)
1387
+ return bertTokenizerOptions
1388
+
1389
+
1390
+ class SentencePieceTokenizerOptions(object):
1391
+ __slots__ = ['_tab']
1392
+
1393
+ @classmethod
1394
+ def GetRootAs(cls, buf, offset=0):
1395
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1396
+ x = SentencePieceTokenizerOptions()
1397
+ x.Init(buf, n + offset)
1398
+ return x
1399
+
1400
+ @classmethod
1401
+ def GetRootAsSentencePieceTokenizerOptions(cls, buf, offset=0):
1402
+ """This method is deprecated. Please switch to GetRootAs."""
1403
+ return cls.GetRootAs(buf, offset)
1404
+ @classmethod
1405
+ def SentencePieceTokenizerOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
1406
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
1407
+
1408
+ # SentencePieceTokenizerOptions
1409
+ def Init(self, buf, pos):
1410
+ self._tab = flatbuffers.table.Table(buf, pos)
1411
+
1412
+ # SentencePieceTokenizerOptions
1413
+ def SentencePieceModel(self, j):
1414
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1415
+ if o != 0:
1416
+ x = self._tab.Vector(o)
1417
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1418
+ x = self._tab.Indirect(x)
1419
+ obj = AssociatedFile()
1420
+ obj.Init(self._tab.Bytes, x)
1421
+ return obj
1422
+ return None
1423
+
1424
+ # SentencePieceTokenizerOptions
1425
+ def SentencePieceModelLength(self):
1426
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1427
+ if o != 0:
1428
+ return self._tab.VectorLen(o)
1429
+ return 0
1430
+
1431
+ # SentencePieceTokenizerOptions
1432
+ def SentencePieceModelIsNone(self):
1433
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1434
+ return o == 0
1435
+
1436
+ # SentencePieceTokenizerOptions
1437
+ def VocabFile(self, j):
1438
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1439
+ if o != 0:
1440
+ x = self._tab.Vector(o)
1441
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1442
+ x = self._tab.Indirect(x)
1443
+ obj = AssociatedFile()
1444
+ obj.Init(self._tab.Bytes, x)
1445
+ return obj
1446
+ return None
1447
+
1448
+ # SentencePieceTokenizerOptions
1449
+ def VocabFileLength(self):
1450
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1451
+ if o != 0:
1452
+ return self._tab.VectorLen(o)
1453
+ return 0
1454
+
1455
+ # SentencePieceTokenizerOptions
1456
+ def VocabFileIsNone(self):
1457
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1458
+ return o == 0
1459
+
1460
+ def SentencePieceTokenizerOptionsStart(builder):
1461
+ builder.StartObject(2)
1462
+
1463
+ def SentencePieceTokenizerOptionsAddSentencePieceModel(builder, sentencePieceModel):
1464
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(sentencePieceModel), 0)
1465
+
1466
+ def SentencePieceTokenizerOptionsStartSentencePieceModelVector(builder, numElems):
1467
+ return builder.StartVector(4, numElems, 4)
1468
+
1469
+ def SentencePieceTokenizerOptionsAddVocabFile(builder, vocabFile):
1470
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(vocabFile), 0)
1471
+
1472
+ def SentencePieceTokenizerOptionsStartVocabFileVector(builder, numElems):
1473
+ return builder.StartVector(4, numElems, 4)
1474
+
1475
+ def SentencePieceTokenizerOptionsEnd(builder):
1476
+ return builder.EndObject()
1477
+
1478
+
1479
+ try:
1480
+ from typing import List
1481
+ except:
1482
+ pass
1483
+
1484
+ class SentencePieceTokenizerOptionsT(object):
1485
+
1486
+ # SentencePieceTokenizerOptionsT
1487
+ def __init__(self):
1488
+ self.sentencePieceModel = None # type: List[AssociatedFileT]
1489
+ self.vocabFile = None # type: List[AssociatedFileT]
1490
+
1491
+ @classmethod
1492
+ def InitFromBuf(cls, buf, pos):
1493
+ sentencePieceTokenizerOptions = SentencePieceTokenizerOptions()
1494
+ sentencePieceTokenizerOptions.Init(buf, pos)
1495
+ return cls.InitFromObj(sentencePieceTokenizerOptions)
1496
+
1497
+ @classmethod
1498
+ def InitFromPackedBuf(cls, buf, pos=0):
1499
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
1500
+ return cls.InitFromBuf(buf, pos+n)
1501
+
1502
+ @classmethod
1503
+ def InitFromObj(cls, sentencePieceTokenizerOptions):
1504
+ x = SentencePieceTokenizerOptionsT()
1505
+ x._UnPack(sentencePieceTokenizerOptions)
1506
+ return x
1507
+
1508
+ # SentencePieceTokenizerOptionsT
1509
+ def _UnPack(self, sentencePieceTokenizerOptions):
1510
+ if sentencePieceTokenizerOptions is None:
1511
+ return
1512
+ if not sentencePieceTokenizerOptions.SentencePieceModelIsNone():
1513
+ self.sentencePieceModel = []
1514
+ for i in range(sentencePieceTokenizerOptions.SentencePieceModelLength()):
1515
+ if sentencePieceTokenizerOptions.SentencePieceModel(i) is None:
1516
+ self.sentencePieceModel.append(None)
1517
+ else:
1518
+ associatedFile_ = AssociatedFileT.InitFromObj(sentencePieceTokenizerOptions.SentencePieceModel(i))
1519
+ self.sentencePieceModel.append(associatedFile_)
1520
+ if not sentencePieceTokenizerOptions.VocabFileIsNone():
1521
+ self.vocabFile = []
1522
+ for i in range(sentencePieceTokenizerOptions.VocabFileLength()):
1523
+ if sentencePieceTokenizerOptions.VocabFile(i) is None:
1524
+ self.vocabFile.append(None)
1525
+ else:
1526
+ associatedFile_ = AssociatedFileT.InitFromObj(sentencePieceTokenizerOptions.VocabFile(i))
1527
+ self.vocabFile.append(associatedFile_)
1528
+
1529
+ # SentencePieceTokenizerOptionsT
1530
+ def Pack(self, builder):
1531
+ if self.sentencePieceModel is not None:
1532
+ sentencePieceModellist = []
1533
+ for i in range(len(self.sentencePieceModel)):
1534
+ sentencePieceModellist.append(self.sentencePieceModel[i].Pack(builder))
1535
+ SentencePieceTokenizerOptionsStartSentencePieceModelVector(builder, len(self.sentencePieceModel))
1536
+ for i in reversed(range(len(self.sentencePieceModel))):
1537
+ builder.PrependUOffsetTRelative(sentencePieceModellist[i])
1538
+ sentencePieceModel = builder.EndVector()
1539
+ if self.vocabFile is not None:
1540
+ vocabFilelist = []
1541
+ for i in range(len(self.vocabFile)):
1542
+ vocabFilelist.append(self.vocabFile[i].Pack(builder))
1543
+ SentencePieceTokenizerOptionsStartVocabFileVector(builder, len(self.vocabFile))
1544
+ for i in reversed(range(len(self.vocabFile))):
1545
+ builder.PrependUOffsetTRelative(vocabFilelist[i])
1546
+ vocabFile = builder.EndVector()
1547
+ SentencePieceTokenizerOptionsStart(builder)
1548
+ if self.sentencePieceModel is not None:
1549
+ SentencePieceTokenizerOptionsAddSentencePieceModel(builder, sentencePieceModel)
1550
+ if self.vocabFile is not None:
1551
+ SentencePieceTokenizerOptionsAddVocabFile(builder, vocabFile)
1552
+ sentencePieceTokenizerOptions = SentencePieceTokenizerOptionsEnd(builder)
1553
+ return sentencePieceTokenizerOptions
1554
+
1555
+
1556
+ class RegexTokenizerOptions(object):
1557
+ __slots__ = ['_tab']
1558
+
1559
+ @classmethod
1560
+ def GetRootAs(cls, buf, offset=0):
1561
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1562
+ x = RegexTokenizerOptions()
1563
+ x.Init(buf, n + offset)
1564
+ return x
1565
+
1566
+ @classmethod
1567
+ def GetRootAsRegexTokenizerOptions(cls, buf, offset=0):
1568
+ """This method is deprecated. Please switch to GetRootAs."""
1569
+ return cls.GetRootAs(buf, offset)
1570
+ @classmethod
1571
+ def RegexTokenizerOptionsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
1572
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
1573
+
1574
+ # RegexTokenizerOptions
1575
+ def Init(self, buf, pos):
1576
+ self._tab = flatbuffers.table.Table(buf, pos)
1577
+
1578
+ # RegexTokenizerOptions
1579
+ def DelimRegexPattern(self):
1580
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1581
+ if o != 0:
1582
+ return self._tab.String(o + self._tab.Pos)
1583
+ return None
1584
+
1585
+ # RegexTokenizerOptions
1586
+ def VocabFile(self, j):
1587
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1588
+ if o != 0:
1589
+ x = self._tab.Vector(o)
1590
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
1591
+ x = self._tab.Indirect(x)
1592
+ obj = AssociatedFile()
1593
+ obj.Init(self._tab.Bytes, x)
1594
+ return obj
1595
+ return None
1596
+
1597
+ # RegexTokenizerOptions
1598
+ def VocabFileLength(self):
1599
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1600
+ if o != 0:
1601
+ return self._tab.VectorLen(o)
1602
+ return 0
1603
+
1604
+ # RegexTokenizerOptions
1605
+ def VocabFileIsNone(self):
1606
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1607
+ return o == 0
1608
+
1609
+ def RegexTokenizerOptionsStart(builder):
1610
+ builder.StartObject(2)
1611
+
1612
+ def RegexTokenizerOptionsAddDelimRegexPattern(builder, delimRegexPattern):
1613
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(delimRegexPattern), 0)
1614
+
1615
+ def RegexTokenizerOptionsAddVocabFile(builder, vocabFile):
1616
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(vocabFile), 0)
1617
+
1618
+ def RegexTokenizerOptionsStartVocabFileVector(builder, numElems):
1619
+ return builder.StartVector(4, numElems, 4)
1620
+
1621
+ def RegexTokenizerOptionsEnd(builder):
1622
+ return builder.EndObject()
1623
+
1624
+
1625
+ try:
1626
+ from typing import List
1627
+ except:
1628
+ pass
1629
+
1630
+ class RegexTokenizerOptionsT(object):
1631
+
1632
+ # RegexTokenizerOptionsT
1633
+ def __init__(self):
1634
+ self.delimRegexPattern = None # type: str
1635
+ self.vocabFile = None # type: List[AssociatedFileT]
1636
+
1637
+ @classmethod
1638
+ def InitFromBuf(cls, buf, pos):
1639
+ regexTokenizerOptions = RegexTokenizerOptions()
1640
+ regexTokenizerOptions.Init(buf, pos)
1641
+ return cls.InitFromObj(regexTokenizerOptions)
1642
+
1643
+ @classmethod
1644
+ def InitFromPackedBuf(cls, buf, pos=0):
1645
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
1646
+ return cls.InitFromBuf(buf, pos+n)
1647
+
1648
+ @classmethod
1649
+ def InitFromObj(cls, regexTokenizerOptions):
1650
+ x = RegexTokenizerOptionsT()
1651
+ x._UnPack(regexTokenizerOptions)
1652
+ return x
1653
+
1654
+ # RegexTokenizerOptionsT
1655
+ def _UnPack(self, regexTokenizerOptions):
1656
+ if regexTokenizerOptions is None:
1657
+ return
1658
+ self.delimRegexPattern = regexTokenizerOptions.DelimRegexPattern()
1659
+ if not regexTokenizerOptions.VocabFileIsNone():
1660
+ self.vocabFile = []
1661
+ for i in range(regexTokenizerOptions.VocabFileLength()):
1662
+ if regexTokenizerOptions.VocabFile(i) is None:
1663
+ self.vocabFile.append(None)
1664
+ else:
1665
+ associatedFile_ = AssociatedFileT.InitFromObj(regexTokenizerOptions.VocabFile(i))
1666
+ self.vocabFile.append(associatedFile_)
1667
+
1668
+ # RegexTokenizerOptionsT
1669
+ def Pack(self, builder):
1670
+ if self.delimRegexPattern is not None:
1671
+ delimRegexPattern = builder.CreateString(self.delimRegexPattern)
1672
+ if self.vocabFile is not None:
1673
+ vocabFilelist = []
1674
+ for i in range(len(self.vocabFile)):
1675
+ vocabFilelist.append(self.vocabFile[i].Pack(builder))
1676
+ RegexTokenizerOptionsStartVocabFileVector(builder, len(self.vocabFile))
1677
+ for i in reversed(range(len(self.vocabFile))):
1678
+ builder.PrependUOffsetTRelative(vocabFilelist[i])
1679
+ vocabFile = builder.EndVector()
1680
+ RegexTokenizerOptionsStart(builder)
1681
+ if self.delimRegexPattern is not None:
1682
+ RegexTokenizerOptionsAddDelimRegexPattern(builder, delimRegexPattern)
1683
+ if self.vocabFile is not None:
1684
+ RegexTokenizerOptionsAddVocabFile(builder, vocabFile)
1685
+ regexTokenizerOptions = RegexTokenizerOptionsEnd(builder)
1686
+ return regexTokenizerOptions
1687
+
1688
+
1689
+ class ProcessUnit(object):
1690
+ __slots__ = ['_tab']
1691
+
1692
+ @classmethod
1693
+ def GetRootAs(cls, buf, offset=0):
1694
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1695
+ x = ProcessUnit()
1696
+ x.Init(buf, n + offset)
1697
+ return x
1698
+
1699
+ @classmethod
1700
+ def GetRootAsProcessUnit(cls, buf, offset=0):
1701
+ """This method is deprecated. Please switch to GetRootAs."""
1702
+ return cls.GetRootAs(buf, offset)
1703
+ @classmethod
1704
+ def ProcessUnitBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
1705
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
1706
+
1707
+ # ProcessUnit
1708
+ def Init(self, buf, pos):
1709
+ self._tab = flatbuffers.table.Table(buf, pos)
1710
+
1711
+ # ProcessUnit
1712
+ def OptionsType(self):
1713
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1714
+ if o != 0:
1715
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, o + self._tab.Pos)
1716
+ return 0
1717
+
1718
+ # ProcessUnit
1719
+ def Options(self):
1720
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1721
+ if o != 0:
1722
+ from flatbuffers.table import Table
1723
+ obj = Table(bytearray(), 0)
1724
+ self._tab.Union(obj, o)
1725
+ return obj
1726
+ return None
1727
+
1728
+ def ProcessUnitStart(builder):
1729
+ builder.StartObject(2)
1730
+
1731
+ def ProcessUnitAddOptionsType(builder, optionsType):
1732
+ builder.PrependUint8Slot(0, optionsType, 0)
1733
+
1734
+ def ProcessUnitAddOptions(builder, options):
1735
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(options), 0)
1736
+
1737
+ def ProcessUnitEnd(builder):
1738
+ return builder.EndObject()
1739
+
1740
+
1741
+ try:
1742
+ from typing import Union
1743
+ except:
1744
+ pass
1745
+
1746
+ class ProcessUnitT(object):
1747
+
1748
+ # ProcessUnitT
1749
+ def __init__(self):
1750
+ self.optionsType = 0 # type: int
1751
+ self.options = None # type: Union[None, NormalizationOptionsT, ScoreCalibrationOptionsT, ScoreThresholdingOptionsT, BertTokenizerOptionsT, SentencePieceTokenizerOptionsT, RegexTokenizerOptionsT]
1752
+
1753
+ @classmethod
1754
+ def InitFromBuf(cls, buf, pos):
1755
+ processUnit = ProcessUnit()
1756
+ processUnit.Init(buf, pos)
1757
+ return cls.InitFromObj(processUnit)
1758
+
1759
+ @classmethod
1760
+ def InitFromPackedBuf(cls, buf, pos=0):
1761
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
1762
+ return cls.InitFromBuf(buf, pos+n)
1763
+
1764
+ @classmethod
1765
+ def InitFromObj(cls, processUnit):
1766
+ x = ProcessUnitT()
1767
+ x._UnPack(processUnit)
1768
+ return x
1769
+
1770
+ # ProcessUnitT
1771
+ def _UnPack(self, processUnit):
1772
+ if processUnit is None:
1773
+ return
1774
+ self.optionsType = processUnit.OptionsType()
1775
+ self.options = ProcessUnitOptionsCreator(self.optionsType, processUnit.Options())
1776
+
1777
+ # ProcessUnitT
1778
+ def Pack(self, builder):
1779
+ if self.options is not None:
1780
+ options = self.options.Pack(builder)
1781
+ ProcessUnitStart(builder)
1782
+ ProcessUnitAddOptionsType(builder, self.optionsType)
1783
+ if self.options is not None:
1784
+ ProcessUnitAddOptions(builder, options)
1785
+ processUnit = ProcessUnitEnd(builder)
1786
+ return processUnit
1787
+
1788
+
1789
+ class Stats(object):
1790
+ __slots__ = ['_tab']
1791
+
1792
+ @classmethod
1793
+ def GetRootAs(cls, buf, offset=0):
1794
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1795
+ x = Stats()
1796
+ x.Init(buf, n + offset)
1797
+ return x
1798
+
1799
+ @classmethod
1800
+ def GetRootAsStats(cls, buf, offset=0):
1801
+ """This method is deprecated. Please switch to GetRootAs."""
1802
+ return cls.GetRootAs(buf, offset)
1803
+ @classmethod
1804
+ def StatsBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
1805
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
1806
+
1807
+ # Stats
1808
+ def Init(self, buf, pos):
1809
+ self._tab = flatbuffers.table.Table(buf, pos)
1810
+
1811
+ # Stats
1812
+ def Max(self, j):
1813
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1814
+ if o != 0:
1815
+ a = self._tab.Vector(o)
1816
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
1817
+ return 0
1818
+
1819
+ # Stats
1820
+ def MaxAsNumpy(self):
1821
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1822
+ if o != 0:
1823
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o)
1824
+ return 0
1825
+
1826
+ # Stats
1827
+ def MaxLength(self):
1828
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1829
+ if o != 0:
1830
+ return self._tab.VectorLen(o)
1831
+ return 0
1832
+
1833
+ # Stats
1834
+ def MaxIsNone(self):
1835
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1836
+ return o == 0
1837
+
1838
+ # Stats
1839
+ def Min(self, j):
1840
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1841
+ if o != 0:
1842
+ a = self._tab.Vector(o)
1843
+ return self._tab.Get(flatbuffers.number_types.Float32Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
1844
+ return 0
1845
+
1846
+ # Stats
1847
+ def MinAsNumpy(self):
1848
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1849
+ if o != 0:
1850
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Float32Flags, o)
1851
+ return 0
1852
+
1853
+ # Stats
1854
+ def MinLength(self):
1855
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1856
+ if o != 0:
1857
+ return self._tab.VectorLen(o)
1858
+ return 0
1859
+
1860
+ # Stats
1861
+ def MinIsNone(self):
1862
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1863
+ return o == 0
1864
+
1865
+ def StatsStart(builder):
1866
+ builder.StartObject(2)
1867
+
1868
+ def StatsAddMax(builder, max):
1869
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(max), 0)
1870
+
1871
+ def StatsStartMaxVector(builder, numElems):
1872
+ return builder.StartVector(4, numElems, 4)
1873
+
1874
+ def StatsAddMin(builder, min):
1875
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(min), 0)
1876
+
1877
+ def StatsStartMinVector(builder, numElems):
1878
+ return builder.StartVector(4, numElems, 4)
1879
+
1880
+ def StatsEnd(builder):
1881
+ return builder.EndObject()
1882
+
1883
+
1884
+ try:
1885
+ from typing import List
1886
+ except:
1887
+ pass
1888
+
1889
+ class StatsT(object):
1890
+
1891
+ # StatsT
1892
+ def __init__(self):
1893
+ self.max = None # type: List[float]
1894
+ self.min = None # type: List[float]
1895
+
1896
+ @classmethod
1897
+ def InitFromBuf(cls, buf, pos):
1898
+ stats = Stats()
1899
+ stats.Init(buf, pos)
1900
+ return cls.InitFromObj(stats)
1901
+
1902
+ @classmethod
1903
+ def InitFromPackedBuf(cls, buf, pos=0):
1904
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
1905
+ return cls.InitFromBuf(buf, pos+n)
1906
+
1907
+ @classmethod
1908
+ def InitFromObj(cls, stats):
1909
+ x = StatsT()
1910
+ x._UnPack(stats)
1911
+ return x
1912
+
1913
+ # StatsT
1914
+ def _UnPack(self, stats):
1915
+ if stats is None:
1916
+ return
1917
+ if not stats.MaxIsNone():
1918
+ if np is None:
1919
+ self.max = []
1920
+ for i in range(stats.MaxLength()):
1921
+ self.max.append(stats.Max(i))
1922
+ else:
1923
+ self.max = stats.MaxAsNumpy()
1924
+ if not stats.MinIsNone():
1925
+ if np is None:
1926
+ self.min = []
1927
+ for i in range(stats.MinLength()):
1928
+ self.min.append(stats.Min(i))
1929
+ else:
1930
+ self.min = stats.MinAsNumpy()
1931
+
1932
+ # StatsT
1933
+ def Pack(self, builder):
1934
+ if self.max is not None:
1935
+ if np is not None and type(self.max) is np.ndarray:
1936
+ max = builder.CreateNumpyVector(self.max)
1937
+ else:
1938
+ StatsStartMaxVector(builder, len(self.max))
1939
+ for i in reversed(range(len(self.max))):
1940
+ builder.PrependFloat32(self.max[i])
1941
+ max = builder.EndVector()
1942
+ if self.min is not None:
1943
+ if np is not None and type(self.min) is np.ndarray:
1944
+ min = builder.CreateNumpyVector(self.min)
1945
+ else:
1946
+ StatsStartMinVector(builder, len(self.min))
1947
+ for i in reversed(range(len(self.min))):
1948
+ builder.PrependFloat32(self.min[i])
1949
+ min = builder.EndVector()
1950
+ StatsStart(builder)
1951
+ if self.max is not None:
1952
+ StatsAddMax(builder, max)
1953
+ if self.min is not None:
1954
+ StatsAddMin(builder, min)
1955
+ stats = StatsEnd(builder)
1956
+ return stats
1957
+
1958
+
1959
+ class TensorGroup(object):
1960
+ __slots__ = ['_tab']
1961
+
1962
+ @classmethod
1963
+ def GetRootAs(cls, buf, offset=0):
1964
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
1965
+ x = TensorGroup()
1966
+ x.Init(buf, n + offset)
1967
+ return x
1968
+
1969
+ @classmethod
1970
+ def GetRootAsTensorGroup(cls, buf, offset=0):
1971
+ """This method is deprecated. Please switch to GetRootAs."""
1972
+ return cls.GetRootAs(buf, offset)
1973
+ @classmethod
1974
+ def TensorGroupBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
1975
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
1976
+
1977
+ # TensorGroup
1978
+ def Init(self, buf, pos):
1979
+ self._tab = flatbuffers.table.Table(buf, pos)
1980
+
1981
+ # TensorGroup
1982
+ def Name(self):
1983
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
1984
+ if o != 0:
1985
+ return self._tab.String(o + self._tab.Pos)
1986
+ return None
1987
+
1988
+ # TensorGroup
1989
+ def TensorNames(self, j):
1990
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1991
+ if o != 0:
1992
+ a = self._tab.Vector(o)
1993
+ return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
1994
+ return ""
1995
+
1996
+ # TensorGroup
1997
+ def TensorNamesLength(self):
1998
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
1999
+ if o != 0:
2000
+ return self._tab.VectorLen(o)
2001
+ return 0
2002
+
2003
+ # TensorGroup
2004
+ def TensorNamesIsNone(self):
2005
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2006
+ return o == 0
2007
+
2008
+ def TensorGroupStart(builder):
2009
+ builder.StartObject(2)
2010
+
2011
+ def TensorGroupAddName(builder, name):
2012
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
2013
+
2014
+ def TensorGroupAddTensorNames(builder, tensorNames):
2015
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(tensorNames), 0)
2016
+
2017
+ def TensorGroupStartTensorNamesVector(builder, numElems):
2018
+ return builder.StartVector(4, numElems, 4)
2019
+
2020
+ def TensorGroupEnd(builder):
2021
+ return builder.EndObject()
2022
+
2023
+
2024
+ try:
2025
+ from typing import List
2026
+ except:
2027
+ pass
2028
+
2029
+ class TensorGroupT(object):
2030
+
2031
+ # TensorGroupT
2032
+ def __init__(self):
2033
+ self.name = None # type: str
2034
+ self.tensorNames = None # type: List[str]
2035
+
2036
+ @classmethod
2037
+ def InitFromBuf(cls, buf, pos):
2038
+ tensorGroup = TensorGroup()
2039
+ tensorGroup.Init(buf, pos)
2040
+ return cls.InitFromObj(tensorGroup)
2041
+
2042
+ @classmethod
2043
+ def InitFromPackedBuf(cls, buf, pos=0):
2044
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
2045
+ return cls.InitFromBuf(buf, pos+n)
2046
+
2047
+ @classmethod
2048
+ def InitFromObj(cls, tensorGroup):
2049
+ x = TensorGroupT()
2050
+ x._UnPack(tensorGroup)
2051
+ return x
2052
+
2053
+ # TensorGroupT
2054
+ def _UnPack(self, tensorGroup):
2055
+ if tensorGroup is None:
2056
+ return
2057
+ self.name = tensorGroup.Name()
2058
+ if not tensorGroup.TensorNamesIsNone():
2059
+ self.tensorNames = []
2060
+ for i in range(tensorGroup.TensorNamesLength()):
2061
+ self.tensorNames.append(tensorGroup.TensorNames(i))
2062
+
2063
+ # TensorGroupT
2064
+ def Pack(self, builder):
2065
+ if self.name is not None:
2066
+ name = builder.CreateString(self.name)
2067
+ if self.tensorNames is not None:
2068
+ tensorNameslist = []
2069
+ for i in range(len(self.tensorNames)):
2070
+ tensorNameslist.append(builder.CreateString(self.tensorNames[i]))
2071
+ TensorGroupStartTensorNamesVector(builder, len(self.tensorNames))
2072
+ for i in reversed(range(len(self.tensorNames))):
2073
+ builder.PrependUOffsetTRelative(tensorNameslist[i])
2074
+ tensorNames = builder.EndVector()
2075
+ TensorGroupStart(builder)
2076
+ if self.name is not None:
2077
+ TensorGroupAddName(builder, name)
2078
+ if self.tensorNames is not None:
2079
+ TensorGroupAddTensorNames(builder, tensorNames)
2080
+ tensorGroup = TensorGroupEnd(builder)
2081
+ return tensorGroup
2082
+
2083
+
2084
+ class TensorMetadata(object):
2085
+ __slots__ = ['_tab']
2086
+
2087
+ @classmethod
2088
+ def GetRootAs(cls, buf, offset=0):
2089
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2090
+ x = TensorMetadata()
2091
+ x.Init(buf, n + offset)
2092
+ return x
2093
+
2094
+ @classmethod
2095
+ def GetRootAsTensorMetadata(cls, buf, offset=0):
2096
+ """This method is deprecated. Please switch to GetRootAs."""
2097
+ return cls.GetRootAs(buf, offset)
2098
+ @classmethod
2099
+ def TensorMetadataBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
2100
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
2101
+
2102
+ # TensorMetadata
2103
+ def Init(self, buf, pos):
2104
+ self._tab = flatbuffers.table.Table(buf, pos)
2105
+
2106
+ # TensorMetadata
2107
+ def Name(self):
2108
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2109
+ if o != 0:
2110
+ return self._tab.String(o + self._tab.Pos)
2111
+ return None
2112
+
2113
+ # TensorMetadata
2114
+ def Description(self):
2115
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2116
+ if o != 0:
2117
+ return self._tab.String(o + self._tab.Pos)
2118
+ return None
2119
+
2120
+ # TensorMetadata
2121
+ def DimensionNames(self, j):
2122
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2123
+ if o != 0:
2124
+ a = self._tab.Vector(o)
2125
+ return self._tab.String(a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 4))
2126
+ return ""
2127
+
2128
+ # TensorMetadata
2129
+ def DimensionNamesLength(self):
2130
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2131
+ if o != 0:
2132
+ return self._tab.VectorLen(o)
2133
+ return 0
2134
+
2135
+ # TensorMetadata
2136
+ def DimensionNamesIsNone(self):
2137
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2138
+ return o == 0
2139
+
2140
+ # TensorMetadata
2141
+ def Content(self):
2142
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2143
+ if o != 0:
2144
+ x = self._tab.Indirect(o + self._tab.Pos)
2145
+ obj = Content()
2146
+ obj.Init(self._tab.Bytes, x)
2147
+ return obj
2148
+ return None
2149
+
2150
+ # TensorMetadata
2151
+ def ProcessUnits(self, j):
2152
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2153
+ if o != 0:
2154
+ x = self._tab.Vector(o)
2155
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2156
+ x = self._tab.Indirect(x)
2157
+ obj = ProcessUnit()
2158
+ obj.Init(self._tab.Bytes, x)
2159
+ return obj
2160
+ return None
2161
+
2162
+ # TensorMetadata
2163
+ def ProcessUnitsLength(self):
2164
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2165
+ if o != 0:
2166
+ return self._tab.VectorLen(o)
2167
+ return 0
2168
+
2169
+ # TensorMetadata
2170
+ def ProcessUnitsIsNone(self):
2171
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2172
+ return o == 0
2173
+
2174
+ # TensorMetadata
2175
+ def Stats(self):
2176
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
2177
+ if o != 0:
2178
+ x = self._tab.Indirect(o + self._tab.Pos)
2179
+ obj = Stats()
2180
+ obj.Init(self._tab.Bytes, x)
2181
+ return obj
2182
+ return None
2183
+
2184
+ # TensorMetadata
2185
+ def AssociatedFiles(self, j):
2186
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
2187
+ if o != 0:
2188
+ x = self._tab.Vector(o)
2189
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2190
+ x = self._tab.Indirect(x)
2191
+ obj = AssociatedFile()
2192
+ obj.Init(self._tab.Bytes, x)
2193
+ return obj
2194
+ return None
2195
+
2196
+ # TensorMetadata
2197
+ def AssociatedFilesLength(self):
2198
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
2199
+ if o != 0:
2200
+ return self._tab.VectorLen(o)
2201
+ return 0
2202
+
2203
+ # TensorMetadata
2204
+ def AssociatedFilesIsNone(self):
2205
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
2206
+ return o == 0
2207
+
2208
+ def TensorMetadataStart(builder):
2209
+ builder.StartObject(7)
2210
+
2211
+ def TensorMetadataAddName(builder, name):
2212
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
2213
+
2214
+ def TensorMetadataAddDescription(builder, description):
2215
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(description), 0)
2216
+
2217
+ def TensorMetadataAddDimensionNames(builder, dimensionNames):
2218
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(dimensionNames), 0)
2219
+
2220
+ def TensorMetadataStartDimensionNamesVector(builder, numElems):
2221
+ return builder.StartVector(4, numElems, 4)
2222
+
2223
+ def TensorMetadataAddContent(builder, content):
2224
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(content), 0)
2225
+
2226
+ def TensorMetadataAddProcessUnits(builder, processUnits):
2227
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(processUnits), 0)
2228
+
2229
+ def TensorMetadataStartProcessUnitsVector(builder, numElems):
2230
+ return builder.StartVector(4, numElems, 4)
2231
+
2232
+ def TensorMetadataAddStats(builder, stats):
2233
+ builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(stats), 0)
2234
+
2235
+ def TensorMetadataAddAssociatedFiles(builder, associatedFiles):
2236
+ builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(associatedFiles), 0)
2237
+
2238
+ def TensorMetadataStartAssociatedFilesVector(builder, numElems):
2239
+ return builder.StartVector(4, numElems, 4)
2240
+
2241
+ def TensorMetadataEnd(builder):
2242
+ return builder.EndObject()
2243
+
2244
+
2245
+ try:
2246
+ from typing import List, Optional
2247
+ except:
2248
+ pass
2249
+
2250
+ class TensorMetadataT(object):
2251
+
2252
+ # TensorMetadataT
2253
+ def __init__(self):
2254
+ self.name = None # type: str
2255
+ self.description = None # type: str
2256
+ self.dimensionNames = None # type: List[str]
2257
+ self.content = None # type: Optional[ContentT]
2258
+ self.processUnits = None # type: List[ProcessUnitT]
2259
+ self.stats = None # type: Optional[StatsT]
2260
+ self.associatedFiles = None # type: List[AssociatedFileT]
2261
+
2262
+ @classmethod
2263
+ def InitFromBuf(cls, buf, pos):
2264
+ tensorMetadata = TensorMetadata()
2265
+ tensorMetadata.Init(buf, pos)
2266
+ return cls.InitFromObj(tensorMetadata)
2267
+
2268
+ @classmethod
2269
+ def InitFromPackedBuf(cls, buf, pos=0):
2270
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
2271
+ return cls.InitFromBuf(buf, pos+n)
2272
+
2273
+ @classmethod
2274
+ def InitFromObj(cls, tensorMetadata):
2275
+ x = TensorMetadataT()
2276
+ x._UnPack(tensorMetadata)
2277
+ return x
2278
+
2279
+ # TensorMetadataT
2280
+ def _UnPack(self, tensorMetadata):
2281
+ if tensorMetadata is None:
2282
+ return
2283
+ self.name = tensorMetadata.Name()
2284
+ self.description = tensorMetadata.Description()
2285
+ if not tensorMetadata.DimensionNamesIsNone():
2286
+ self.dimensionNames = []
2287
+ for i in range(tensorMetadata.DimensionNamesLength()):
2288
+ self.dimensionNames.append(tensorMetadata.DimensionNames(i))
2289
+ if tensorMetadata.Content() is not None:
2290
+ self.content = ContentT.InitFromObj(tensorMetadata.Content())
2291
+ if not tensorMetadata.ProcessUnitsIsNone():
2292
+ self.processUnits = []
2293
+ for i in range(tensorMetadata.ProcessUnitsLength()):
2294
+ if tensorMetadata.ProcessUnits(i) is None:
2295
+ self.processUnits.append(None)
2296
+ else:
2297
+ processUnit_ = ProcessUnitT.InitFromObj(tensorMetadata.ProcessUnits(i))
2298
+ self.processUnits.append(processUnit_)
2299
+ if tensorMetadata.Stats() is not None:
2300
+ self.stats = StatsT.InitFromObj(tensorMetadata.Stats())
2301
+ if not tensorMetadata.AssociatedFilesIsNone():
2302
+ self.associatedFiles = []
2303
+ for i in range(tensorMetadata.AssociatedFilesLength()):
2304
+ if tensorMetadata.AssociatedFiles(i) is None:
2305
+ self.associatedFiles.append(None)
2306
+ else:
2307
+ associatedFile_ = AssociatedFileT.InitFromObj(tensorMetadata.AssociatedFiles(i))
2308
+ self.associatedFiles.append(associatedFile_)
2309
+
2310
+ # TensorMetadataT
2311
+ def Pack(self, builder):
2312
+ if self.name is not None:
2313
+ name = builder.CreateString(self.name)
2314
+ if self.description is not None:
2315
+ description = builder.CreateString(self.description)
2316
+ if self.dimensionNames is not None:
2317
+ dimensionNameslist = []
2318
+ for i in range(len(self.dimensionNames)):
2319
+ dimensionNameslist.append(builder.CreateString(self.dimensionNames[i]))
2320
+ TensorMetadataStartDimensionNamesVector(builder, len(self.dimensionNames))
2321
+ for i in reversed(range(len(self.dimensionNames))):
2322
+ builder.PrependUOffsetTRelative(dimensionNameslist[i])
2323
+ dimensionNames = builder.EndVector()
2324
+ if self.content is not None:
2325
+ content = self.content.Pack(builder)
2326
+ if self.processUnits is not None:
2327
+ processUnitslist = []
2328
+ for i in range(len(self.processUnits)):
2329
+ processUnitslist.append(self.processUnits[i].Pack(builder))
2330
+ TensorMetadataStartProcessUnitsVector(builder, len(self.processUnits))
2331
+ for i in reversed(range(len(self.processUnits))):
2332
+ builder.PrependUOffsetTRelative(processUnitslist[i])
2333
+ processUnits = builder.EndVector()
2334
+ if self.stats is not None:
2335
+ stats = self.stats.Pack(builder)
2336
+ if self.associatedFiles is not None:
2337
+ associatedFileslist = []
2338
+ for i in range(len(self.associatedFiles)):
2339
+ associatedFileslist.append(self.associatedFiles[i].Pack(builder))
2340
+ TensorMetadataStartAssociatedFilesVector(builder, len(self.associatedFiles))
2341
+ for i in reversed(range(len(self.associatedFiles))):
2342
+ builder.PrependUOffsetTRelative(associatedFileslist[i])
2343
+ associatedFiles = builder.EndVector()
2344
+ TensorMetadataStart(builder)
2345
+ if self.name is not None:
2346
+ TensorMetadataAddName(builder, name)
2347
+ if self.description is not None:
2348
+ TensorMetadataAddDescription(builder, description)
2349
+ if self.dimensionNames is not None:
2350
+ TensorMetadataAddDimensionNames(builder, dimensionNames)
2351
+ if self.content is not None:
2352
+ TensorMetadataAddContent(builder, content)
2353
+ if self.processUnits is not None:
2354
+ TensorMetadataAddProcessUnits(builder, processUnits)
2355
+ if self.stats is not None:
2356
+ TensorMetadataAddStats(builder, stats)
2357
+ if self.associatedFiles is not None:
2358
+ TensorMetadataAddAssociatedFiles(builder, associatedFiles)
2359
+ tensorMetadata = TensorMetadataEnd(builder)
2360
+ return tensorMetadata
2361
+
2362
+
2363
+ class CustomMetadata(object):
2364
+ __slots__ = ['_tab']
2365
+
2366
+ @classmethod
2367
+ def GetRootAs(cls, buf, offset=0):
2368
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2369
+ x = CustomMetadata()
2370
+ x.Init(buf, n + offset)
2371
+ return x
2372
+
2373
+ @classmethod
2374
+ def GetRootAsCustomMetadata(cls, buf, offset=0):
2375
+ """This method is deprecated. Please switch to GetRootAs."""
2376
+ return cls.GetRootAs(buf, offset)
2377
+ @classmethod
2378
+ def CustomMetadataBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
2379
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
2380
+
2381
+ # CustomMetadata
2382
+ def Init(self, buf, pos):
2383
+ self._tab = flatbuffers.table.Table(buf, pos)
2384
+
2385
+ # CustomMetadata
2386
+ def Name(self):
2387
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2388
+ if o != 0:
2389
+ return self._tab.String(o + self._tab.Pos)
2390
+ return None
2391
+
2392
+ # CustomMetadata
2393
+ def Data(self, j):
2394
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2395
+ if o != 0:
2396
+ a = self._tab.Vector(o)
2397
+ return self._tab.Get(flatbuffers.number_types.Uint8Flags, a + flatbuffers.number_types.UOffsetTFlags.py_type(j * 1))
2398
+ return 0
2399
+
2400
+ # CustomMetadata
2401
+ def DataAsNumpy(self):
2402
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2403
+ if o != 0:
2404
+ return self._tab.GetVectorAsNumpy(flatbuffers.number_types.Uint8Flags, o)
2405
+ return 0
2406
+
2407
+ # CustomMetadata
2408
+ def DataLength(self):
2409
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2410
+ if o != 0:
2411
+ return self._tab.VectorLen(o)
2412
+ return 0
2413
+
2414
+ # CustomMetadata
2415
+ def DataIsNone(self):
2416
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2417
+ return o == 0
2418
+
2419
+ def CustomMetadataStart(builder):
2420
+ builder.StartObject(2)
2421
+
2422
+ def CustomMetadataAddName(builder, name):
2423
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
2424
+
2425
+ def CustomMetadataAddData(builder, data):
2426
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(data), 0)
2427
+
2428
+ def CustomMetadataStartDataVector(builder, numElems):
2429
+ return builder.StartVector(1, numElems, 1)
2430
+
2431
+ def CustomMetadataEnd(builder):
2432
+ return builder.EndObject()
2433
+
2434
+
2435
+ try:
2436
+ from typing import List
2437
+ except:
2438
+ pass
2439
+
2440
+ class CustomMetadataT(object):
2441
+
2442
+ # CustomMetadataT
2443
+ def __init__(self):
2444
+ self.name = None # type: str
2445
+ self.data = None # type: List[int]
2446
+
2447
+ @classmethod
2448
+ def InitFromBuf(cls, buf, pos):
2449
+ customMetadata = CustomMetadata()
2450
+ customMetadata.Init(buf, pos)
2451
+ return cls.InitFromObj(customMetadata)
2452
+
2453
+ @classmethod
2454
+ def InitFromPackedBuf(cls, buf, pos=0):
2455
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
2456
+ return cls.InitFromBuf(buf, pos+n)
2457
+
2458
+ @classmethod
2459
+ def InitFromObj(cls, customMetadata):
2460
+ x = CustomMetadataT()
2461
+ x._UnPack(customMetadata)
2462
+ return x
2463
+
2464
+ # CustomMetadataT
2465
+ def _UnPack(self, customMetadata):
2466
+ if customMetadata is None:
2467
+ return
2468
+ self.name = customMetadata.Name()
2469
+ if not customMetadata.DataIsNone():
2470
+ if np is None:
2471
+ self.data = []
2472
+ for i in range(customMetadata.DataLength()):
2473
+ self.data.append(customMetadata.Data(i))
2474
+ else:
2475
+ self.data = customMetadata.DataAsNumpy()
2476
+
2477
+ # CustomMetadataT
2478
+ def Pack(self, builder):
2479
+ if self.name is not None:
2480
+ name = builder.CreateString(self.name)
2481
+ if self.data is not None:
2482
+ if np is not None and type(self.data) is np.ndarray:
2483
+ data = builder.CreateNumpyVector(self.data)
2484
+ else:
2485
+ CustomMetadataStartDataVector(builder, len(self.data))
2486
+ for i in reversed(range(len(self.data))):
2487
+ builder.PrependUint8(self.data[i])
2488
+ data = builder.EndVector()
2489
+ CustomMetadataStart(builder)
2490
+ if self.name is not None:
2491
+ CustomMetadataAddName(builder, name)
2492
+ if self.data is not None:
2493
+ CustomMetadataAddData(builder, data)
2494
+ customMetadata = CustomMetadataEnd(builder)
2495
+ return customMetadata
2496
+
2497
+
2498
+ class SubGraphMetadata(object):
2499
+ __slots__ = ['_tab']
2500
+
2501
+ @classmethod
2502
+ def GetRootAs(cls, buf, offset=0):
2503
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2504
+ x = SubGraphMetadata()
2505
+ x.Init(buf, n + offset)
2506
+ return x
2507
+
2508
+ @classmethod
2509
+ def GetRootAsSubGraphMetadata(cls, buf, offset=0):
2510
+ """This method is deprecated. Please switch to GetRootAs."""
2511
+ return cls.GetRootAs(buf, offset)
2512
+ @classmethod
2513
+ def SubGraphMetadataBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
2514
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
2515
+
2516
+ # SubGraphMetadata
2517
+ def Init(self, buf, pos):
2518
+ self._tab = flatbuffers.table.Table(buf, pos)
2519
+
2520
+ # SubGraphMetadata
2521
+ def Name(self):
2522
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
2523
+ if o != 0:
2524
+ return self._tab.String(o + self._tab.Pos)
2525
+ return None
2526
+
2527
+ # SubGraphMetadata
2528
+ def Description(self):
2529
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
2530
+ if o != 0:
2531
+ return self._tab.String(o + self._tab.Pos)
2532
+ return None
2533
+
2534
+ # SubGraphMetadata
2535
+ def InputTensorMetadata(self, j):
2536
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2537
+ if o != 0:
2538
+ x = self._tab.Vector(o)
2539
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2540
+ x = self._tab.Indirect(x)
2541
+ obj = TensorMetadata()
2542
+ obj.Init(self._tab.Bytes, x)
2543
+ return obj
2544
+ return None
2545
+
2546
+ # SubGraphMetadata
2547
+ def InputTensorMetadataLength(self):
2548
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2549
+ if o != 0:
2550
+ return self._tab.VectorLen(o)
2551
+ return 0
2552
+
2553
+ # SubGraphMetadata
2554
+ def InputTensorMetadataIsNone(self):
2555
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
2556
+ return o == 0
2557
+
2558
+ # SubGraphMetadata
2559
+ def OutputTensorMetadata(self, j):
2560
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2561
+ if o != 0:
2562
+ x = self._tab.Vector(o)
2563
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2564
+ x = self._tab.Indirect(x)
2565
+ obj = TensorMetadata()
2566
+ obj.Init(self._tab.Bytes, x)
2567
+ return obj
2568
+ return None
2569
+
2570
+ # SubGraphMetadata
2571
+ def OutputTensorMetadataLength(self):
2572
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2573
+ if o != 0:
2574
+ return self._tab.VectorLen(o)
2575
+ return 0
2576
+
2577
+ # SubGraphMetadata
2578
+ def OutputTensorMetadataIsNone(self):
2579
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
2580
+ return o == 0
2581
+
2582
+ # SubGraphMetadata
2583
+ def AssociatedFiles(self, j):
2584
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2585
+ if o != 0:
2586
+ x = self._tab.Vector(o)
2587
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2588
+ x = self._tab.Indirect(x)
2589
+ obj = AssociatedFile()
2590
+ obj.Init(self._tab.Bytes, x)
2591
+ return obj
2592
+ return None
2593
+
2594
+ # SubGraphMetadata
2595
+ def AssociatedFilesLength(self):
2596
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2597
+ if o != 0:
2598
+ return self._tab.VectorLen(o)
2599
+ return 0
2600
+
2601
+ # SubGraphMetadata
2602
+ def AssociatedFilesIsNone(self):
2603
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
2604
+ return o == 0
2605
+
2606
+ # SubGraphMetadata
2607
+ def InputProcessUnits(self, j):
2608
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
2609
+ if o != 0:
2610
+ x = self._tab.Vector(o)
2611
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2612
+ x = self._tab.Indirect(x)
2613
+ obj = ProcessUnit()
2614
+ obj.Init(self._tab.Bytes, x)
2615
+ return obj
2616
+ return None
2617
+
2618
+ # SubGraphMetadata
2619
+ def InputProcessUnitsLength(self):
2620
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
2621
+ if o != 0:
2622
+ return self._tab.VectorLen(o)
2623
+ return 0
2624
+
2625
+ # SubGraphMetadata
2626
+ def InputProcessUnitsIsNone(self):
2627
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
2628
+ return o == 0
2629
+
2630
+ # SubGraphMetadata
2631
+ def OutputProcessUnits(self, j):
2632
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
2633
+ if o != 0:
2634
+ x = self._tab.Vector(o)
2635
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2636
+ x = self._tab.Indirect(x)
2637
+ obj = ProcessUnit()
2638
+ obj.Init(self._tab.Bytes, x)
2639
+ return obj
2640
+ return None
2641
+
2642
+ # SubGraphMetadata
2643
+ def OutputProcessUnitsLength(self):
2644
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
2645
+ if o != 0:
2646
+ return self._tab.VectorLen(o)
2647
+ return 0
2648
+
2649
+ # SubGraphMetadata
2650
+ def OutputProcessUnitsIsNone(self):
2651
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
2652
+ return o == 0
2653
+
2654
+ # SubGraphMetadata
2655
+ def InputTensorGroups(self, j):
2656
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
2657
+ if o != 0:
2658
+ x = self._tab.Vector(o)
2659
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2660
+ x = self._tab.Indirect(x)
2661
+ obj = TensorGroup()
2662
+ obj.Init(self._tab.Bytes, x)
2663
+ return obj
2664
+ return None
2665
+
2666
+ # SubGraphMetadata
2667
+ def InputTensorGroupsLength(self):
2668
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
2669
+ if o != 0:
2670
+ return self._tab.VectorLen(o)
2671
+ return 0
2672
+
2673
+ # SubGraphMetadata
2674
+ def InputTensorGroupsIsNone(self):
2675
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
2676
+ return o == 0
2677
+
2678
+ # SubGraphMetadata
2679
+ def OutputTensorGroups(self, j):
2680
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
2681
+ if o != 0:
2682
+ x = self._tab.Vector(o)
2683
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2684
+ x = self._tab.Indirect(x)
2685
+ obj = TensorGroup()
2686
+ obj.Init(self._tab.Bytes, x)
2687
+ return obj
2688
+ return None
2689
+
2690
+ # SubGraphMetadata
2691
+ def OutputTensorGroupsLength(self):
2692
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
2693
+ if o != 0:
2694
+ return self._tab.VectorLen(o)
2695
+ return 0
2696
+
2697
+ # SubGraphMetadata
2698
+ def OutputTensorGroupsIsNone(self):
2699
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(20))
2700
+ return o == 0
2701
+
2702
+ # SubGraphMetadata
2703
+ def CustomMetadata(self, j):
2704
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
2705
+ if o != 0:
2706
+ x = self._tab.Vector(o)
2707
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
2708
+ x = self._tab.Indirect(x)
2709
+ obj = CustomMetadata()
2710
+ obj.Init(self._tab.Bytes, x)
2711
+ return obj
2712
+ return None
2713
+
2714
+ # SubGraphMetadata
2715
+ def CustomMetadataLength(self):
2716
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
2717
+ if o != 0:
2718
+ return self._tab.VectorLen(o)
2719
+ return 0
2720
+
2721
+ # SubGraphMetadata
2722
+ def CustomMetadataIsNone(self):
2723
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(22))
2724
+ return o == 0
2725
+
2726
+ def SubGraphMetadataStart(builder):
2727
+ builder.StartObject(10)
2728
+
2729
+ def SubGraphMetadataAddName(builder, name):
2730
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
2731
+
2732
+ def SubGraphMetadataAddDescription(builder, description):
2733
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(description), 0)
2734
+
2735
+ def SubGraphMetadataAddInputTensorMetadata(builder, inputTensorMetadata):
2736
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(inputTensorMetadata), 0)
2737
+
2738
+ def SubGraphMetadataStartInputTensorMetadataVector(builder, numElems):
2739
+ return builder.StartVector(4, numElems, 4)
2740
+
2741
+ def SubGraphMetadataAddOutputTensorMetadata(builder, outputTensorMetadata):
2742
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(outputTensorMetadata), 0)
2743
+
2744
+ def SubGraphMetadataStartOutputTensorMetadataVector(builder, numElems):
2745
+ return builder.StartVector(4, numElems, 4)
2746
+
2747
+ def SubGraphMetadataAddAssociatedFiles(builder, associatedFiles):
2748
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(associatedFiles), 0)
2749
+
2750
+ def SubGraphMetadataStartAssociatedFilesVector(builder, numElems):
2751
+ return builder.StartVector(4, numElems, 4)
2752
+
2753
+ def SubGraphMetadataAddInputProcessUnits(builder, inputProcessUnits):
2754
+ builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(inputProcessUnits), 0)
2755
+
2756
+ def SubGraphMetadataStartInputProcessUnitsVector(builder, numElems):
2757
+ return builder.StartVector(4, numElems, 4)
2758
+
2759
+ def SubGraphMetadataAddOutputProcessUnits(builder, outputProcessUnits):
2760
+ builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(outputProcessUnits), 0)
2761
+
2762
+ def SubGraphMetadataStartOutputProcessUnitsVector(builder, numElems):
2763
+ return builder.StartVector(4, numElems, 4)
2764
+
2765
+ def SubGraphMetadataAddInputTensorGroups(builder, inputTensorGroups):
2766
+ builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(inputTensorGroups), 0)
2767
+
2768
+ def SubGraphMetadataStartInputTensorGroupsVector(builder, numElems):
2769
+ return builder.StartVector(4, numElems, 4)
2770
+
2771
+ def SubGraphMetadataAddOutputTensorGroups(builder, outputTensorGroups):
2772
+ builder.PrependUOffsetTRelativeSlot(8, flatbuffers.number_types.UOffsetTFlags.py_type(outputTensorGroups), 0)
2773
+
2774
+ def SubGraphMetadataStartOutputTensorGroupsVector(builder, numElems):
2775
+ return builder.StartVector(4, numElems, 4)
2776
+
2777
+ def SubGraphMetadataAddCustomMetadata(builder, customMetadata):
2778
+ builder.PrependUOffsetTRelativeSlot(9, flatbuffers.number_types.UOffsetTFlags.py_type(customMetadata), 0)
2779
+
2780
+ def SubGraphMetadataStartCustomMetadataVector(builder, numElems):
2781
+ return builder.StartVector(4, numElems, 4)
2782
+
2783
+ def SubGraphMetadataEnd(builder):
2784
+ return builder.EndObject()
2785
+
2786
+
2787
+ try:
2788
+ from typing import List
2789
+ except:
2790
+ pass
2791
+
2792
+ class SubGraphMetadataT(object):
2793
+
2794
+ # SubGraphMetadataT
2795
+ def __init__(self):
2796
+ self.name = None # type: str
2797
+ self.description = None # type: str
2798
+ self.inputTensorMetadata = None # type: List[TensorMetadataT]
2799
+ self.outputTensorMetadata = None # type: List[TensorMetadataT]
2800
+ self.associatedFiles = None # type: List[AssociatedFileT]
2801
+ self.inputProcessUnits = None # type: List[ProcessUnitT]
2802
+ self.outputProcessUnits = None # type: List[ProcessUnitT]
2803
+ self.inputTensorGroups = None # type: List[TensorGroupT]
2804
+ self.outputTensorGroups = None # type: List[TensorGroupT]
2805
+ self.customMetadata = None # type: List[CustomMetadataT]
2806
+
2807
+ @classmethod
2808
+ def InitFromBuf(cls, buf, pos):
2809
+ subGraphMetadata = SubGraphMetadata()
2810
+ subGraphMetadata.Init(buf, pos)
2811
+ return cls.InitFromObj(subGraphMetadata)
2812
+
2813
+ @classmethod
2814
+ def InitFromPackedBuf(cls, buf, pos=0):
2815
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
2816
+ return cls.InitFromBuf(buf, pos+n)
2817
+
2818
+ @classmethod
2819
+ def InitFromObj(cls, subGraphMetadata):
2820
+ x = SubGraphMetadataT()
2821
+ x._UnPack(subGraphMetadata)
2822
+ return x
2823
+
2824
+ # SubGraphMetadataT
2825
+ def _UnPack(self, subGraphMetadata):
2826
+ if subGraphMetadata is None:
2827
+ return
2828
+ self.name = subGraphMetadata.Name()
2829
+ self.description = subGraphMetadata.Description()
2830
+ if not subGraphMetadata.InputTensorMetadataIsNone():
2831
+ self.inputTensorMetadata = []
2832
+ for i in range(subGraphMetadata.InputTensorMetadataLength()):
2833
+ if subGraphMetadata.InputTensorMetadata(i) is None:
2834
+ self.inputTensorMetadata.append(None)
2835
+ else:
2836
+ tensorMetadata_ = TensorMetadataT.InitFromObj(subGraphMetadata.InputTensorMetadata(i))
2837
+ self.inputTensorMetadata.append(tensorMetadata_)
2838
+ if not subGraphMetadata.OutputTensorMetadataIsNone():
2839
+ self.outputTensorMetadata = []
2840
+ for i in range(subGraphMetadata.OutputTensorMetadataLength()):
2841
+ if subGraphMetadata.OutputTensorMetadata(i) is None:
2842
+ self.outputTensorMetadata.append(None)
2843
+ else:
2844
+ tensorMetadata_ = TensorMetadataT.InitFromObj(subGraphMetadata.OutputTensorMetadata(i))
2845
+ self.outputTensorMetadata.append(tensorMetadata_)
2846
+ if not subGraphMetadata.AssociatedFilesIsNone():
2847
+ self.associatedFiles = []
2848
+ for i in range(subGraphMetadata.AssociatedFilesLength()):
2849
+ if subGraphMetadata.AssociatedFiles(i) is None:
2850
+ self.associatedFiles.append(None)
2851
+ else:
2852
+ associatedFile_ = AssociatedFileT.InitFromObj(subGraphMetadata.AssociatedFiles(i))
2853
+ self.associatedFiles.append(associatedFile_)
2854
+ if not subGraphMetadata.InputProcessUnitsIsNone():
2855
+ self.inputProcessUnits = []
2856
+ for i in range(subGraphMetadata.InputProcessUnitsLength()):
2857
+ if subGraphMetadata.InputProcessUnits(i) is None:
2858
+ self.inputProcessUnits.append(None)
2859
+ else:
2860
+ processUnit_ = ProcessUnitT.InitFromObj(subGraphMetadata.InputProcessUnits(i))
2861
+ self.inputProcessUnits.append(processUnit_)
2862
+ if not subGraphMetadata.OutputProcessUnitsIsNone():
2863
+ self.outputProcessUnits = []
2864
+ for i in range(subGraphMetadata.OutputProcessUnitsLength()):
2865
+ if subGraphMetadata.OutputProcessUnits(i) is None:
2866
+ self.outputProcessUnits.append(None)
2867
+ else:
2868
+ processUnit_ = ProcessUnitT.InitFromObj(subGraphMetadata.OutputProcessUnits(i))
2869
+ self.outputProcessUnits.append(processUnit_)
2870
+ if not subGraphMetadata.InputTensorGroupsIsNone():
2871
+ self.inputTensorGroups = []
2872
+ for i in range(subGraphMetadata.InputTensorGroupsLength()):
2873
+ if subGraphMetadata.InputTensorGroups(i) is None:
2874
+ self.inputTensorGroups.append(None)
2875
+ else:
2876
+ tensorGroup_ = TensorGroupT.InitFromObj(subGraphMetadata.InputTensorGroups(i))
2877
+ self.inputTensorGroups.append(tensorGroup_)
2878
+ if not subGraphMetadata.OutputTensorGroupsIsNone():
2879
+ self.outputTensorGroups = []
2880
+ for i in range(subGraphMetadata.OutputTensorGroupsLength()):
2881
+ if subGraphMetadata.OutputTensorGroups(i) is None:
2882
+ self.outputTensorGroups.append(None)
2883
+ else:
2884
+ tensorGroup_ = TensorGroupT.InitFromObj(subGraphMetadata.OutputTensorGroups(i))
2885
+ self.outputTensorGroups.append(tensorGroup_)
2886
+ if not subGraphMetadata.CustomMetadataIsNone():
2887
+ self.customMetadata = []
2888
+ for i in range(subGraphMetadata.CustomMetadataLength()):
2889
+ if subGraphMetadata.CustomMetadata(i) is None:
2890
+ self.customMetadata.append(None)
2891
+ else:
2892
+ customMetadata_ = CustomMetadataT.InitFromObj(subGraphMetadata.CustomMetadata(i))
2893
+ self.customMetadata.append(customMetadata_)
2894
+
2895
+ # SubGraphMetadataT
2896
+ def Pack(self, builder):
2897
+ if self.name is not None:
2898
+ name = builder.CreateString(self.name)
2899
+ if self.description is not None:
2900
+ description = builder.CreateString(self.description)
2901
+ if self.inputTensorMetadata is not None:
2902
+ inputTensorMetadatalist = []
2903
+ for i in range(len(self.inputTensorMetadata)):
2904
+ inputTensorMetadatalist.append(self.inputTensorMetadata[i].Pack(builder))
2905
+ SubGraphMetadataStartInputTensorMetadataVector(builder, len(self.inputTensorMetadata))
2906
+ for i in reversed(range(len(self.inputTensorMetadata))):
2907
+ builder.PrependUOffsetTRelative(inputTensorMetadatalist[i])
2908
+ inputTensorMetadata = builder.EndVector()
2909
+ if self.outputTensorMetadata is not None:
2910
+ outputTensorMetadatalist = []
2911
+ for i in range(len(self.outputTensorMetadata)):
2912
+ outputTensorMetadatalist.append(self.outputTensorMetadata[i].Pack(builder))
2913
+ SubGraphMetadataStartOutputTensorMetadataVector(builder, len(self.outputTensorMetadata))
2914
+ for i in reversed(range(len(self.outputTensorMetadata))):
2915
+ builder.PrependUOffsetTRelative(outputTensorMetadatalist[i])
2916
+ outputTensorMetadata = builder.EndVector()
2917
+ if self.associatedFiles is not None:
2918
+ associatedFileslist = []
2919
+ for i in range(len(self.associatedFiles)):
2920
+ associatedFileslist.append(self.associatedFiles[i].Pack(builder))
2921
+ SubGraphMetadataStartAssociatedFilesVector(builder, len(self.associatedFiles))
2922
+ for i in reversed(range(len(self.associatedFiles))):
2923
+ builder.PrependUOffsetTRelative(associatedFileslist[i])
2924
+ associatedFiles = builder.EndVector()
2925
+ if self.inputProcessUnits is not None:
2926
+ inputProcessUnitslist = []
2927
+ for i in range(len(self.inputProcessUnits)):
2928
+ inputProcessUnitslist.append(self.inputProcessUnits[i].Pack(builder))
2929
+ SubGraphMetadataStartInputProcessUnitsVector(builder, len(self.inputProcessUnits))
2930
+ for i in reversed(range(len(self.inputProcessUnits))):
2931
+ builder.PrependUOffsetTRelative(inputProcessUnitslist[i])
2932
+ inputProcessUnits = builder.EndVector()
2933
+ if self.outputProcessUnits is not None:
2934
+ outputProcessUnitslist = []
2935
+ for i in range(len(self.outputProcessUnits)):
2936
+ outputProcessUnitslist.append(self.outputProcessUnits[i].Pack(builder))
2937
+ SubGraphMetadataStartOutputProcessUnitsVector(builder, len(self.outputProcessUnits))
2938
+ for i in reversed(range(len(self.outputProcessUnits))):
2939
+ builder.PrependUOffsetTRelative(outputProcessUnitslist[i])
2940
+ outputProcessUnits = builder.EndVector()
2941
+ if self.inputTensorGroups is not None:
2942
+ inputTensorGroupslist = []
2943
+ for i in range(len(self.inputTensorGroups)):
2944
+ inputTensorGroupslist.append(self.inputTensorGroups[i].Pack(builder))
2945
+ SubGraphMetadataStartInputTensorGroupsVector(builder, len(self.inputTensorGroups))
2946
+ for i in reversed(range(len(self.inputTensorGroups))):
2947
+ builder.PrependUOffsetTRelative(inputTensorGroupslist[i])
2948
+ inputTensorGroups = builder.EndVector()
2949
+ if self.outputTensorGroups is not None:
2950
+ outputTensorGroupslist = []
2951
+ for i in range(len(self.outputTensorGroups)):
2952
+ outputTensorGroupslist.append(self.outputTensorGroups[i].Pack(builder))
2953
+ SubGraphMetadataStartOutputTensorGroupsVector(builder, len(self.outputTensorGroups))
2954
+ for i in reversed(range(len(self.outputTensorGroups))):
2955
+ builder.PrependUOffsetTRelative(outputTensorGroupslist[i])
2956
+ outputTensorGroups = builder.EndVector()
2957
+ if self.customMetadata is not None:
2958
+ customMetadatalist = []
2959
+ for i in range(len(self.customMetadata)):
2960
+ customMetadatalist.append(self.customMetadata[i].Pack(builder))
2961
+ SubGraphMetadataStartCustomMetadataVector(builder, len(self.customMetadata))
2962
+ for i in reversed(range(len(self.customMetadata))):
2963
+ builder.PrependUOffsetTRelative(customMetadatalist[i])
2964
+ customMetadata = builder.EndVector()
2965
+ SubGraphMetadataStart(builder)
2966
+ if self.name is not None:
2967
+ SubGraphMetadataAddName(builder, name)
2968
+ if self.description is not None:
2969
+ SubGraphMetadataAddDescription(builder, description)
2970
+ if self.inputTensorMetadata is not None:
2971
+ SubGraphMetadataAddInputTensorMetadata(builder, inputTensorMetadata)
2972
+ if self.outputTensorMetadata is not None:
2973
+ SubGraphMetadataAddOutputTensorMetadata(builder, outputTensorMetadata)
2974
+ if self.associatedFiles is not None:
2975
+ SubGraphMetadataAddAssociatedFiles(builder, associatedFiles)
2976
+ if self.inputProcessUnits is not None:
2977
+ SubGraphMetadataAddInputProcessUnits(builder, inputProcessUnits)
2978
+ if self.outputProcessUnits is not None:
2979
+ SubGraphMetadataAddOutputProcessUnits(builder, outputProcessUnits)
2980
+ if self.inputTensorGroups is not None:
2981
+ SubGraphMetadataAddInputTensorGroups(builder, inputTensorGroups)
2982
+ if self.outputTensorGroups is not None:
2983
+ SubGraphMetadataAddOutputTensorGroups(builder, outputTensorGroups)
2984
+ if self.customMetadata is not None:
2985
+ SubGraphMetadataAddCustomMetadata(builder, customMetadata)
2986
+ subGraphMetadata = SubGraphMetadataEnd(builder)
2987
+ return subGraphMetadata
2988
+
2989
+
2990
+ class ModelMetadata(object):
2991
+ __slots__ = ['_tab']
2992
+
2993
+ @classmethod
2994
+ def GetRootAs(cls, buf, offset=0):
2995
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, offset)
2996
+ x = ModelMetadata()
2997
+ x.Init(buf, n + offset)
2998
+ return x
2999
+
3000
+ @classmethod
3001
+ def GetRootAsModelMetadata(cls, buf, offset=0):
3002
+ """This method is deprecated. Please switch to GetRootAs."""
3003
+ return cls.GetRootAs(buf, offset)
3004
+ @classmethod
3005
+ def ModelMetadataBufferHasIdentifier(cls, buf, offset, size_prefixed=False):
3006
+ return flatbuffers.util.BufferHasIdentifier(buf, offset, b"\x4D\x30\x30\x31", size_prefixed=size_prefixed)
3007
+
3008
+ # ModelMetadata
3009
+ def Init(self, buf, pos):
3010
+ self._tab = flatbuffers.table.Table(buf, pos)
3011
+
3012
+ # ModelMetadata
3013
+ def Name(self):
3014
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(4))
3015
+ if o != 0:
3016
+ return self._tab.String(o + self._tab.Pos)
3017
+ return None
3018
+
3019
+ # ModelMetadata
3020
+ def Description(self):
3021
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(6))
3022
+ if o != 0:
3023
+ return self._tab.String(o + self._tab.Pos)
3024
+ return None
3025
+
3026
+ # ModelMetadata
3027
+ def Version(self):
3028
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(8))
3029
+ if o != 0:
3030
+ return self._tab.String(o + self._tab.Pos)
3031
+ return None
3032
+
3033
+ # ModelMetadata
3034
+ def SubgraphMetadata(self, j):
3035
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
3036
+ if o != 0:
3037
+ x = self._tab.Vector(o)
3038
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
3039
+ x = self._tab.Indirect(x)
3040
+ obj = SubGraphMetadata()
3041
+ obj.Init(self._tab.Bytes, x)
3042
+ return obj
3043
+ return None
3044
+
3045
+ # ModelMetadata
3046
+ def SubgraphMetadataLength(self):
3047
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
3048
+ if o != 0:
3049
+ return self._tab.VectorLen(o)
3050
+ return 0
3051
+
3052
+ # ModelMetadata
3053
+ def SubgraphMetadataIsNone(self):
3054
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(10))
3055
+ return o == 0
3056
+
3057
+ # ModelMetadata
3058
+ def Author(self):
3059
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(12))
3060
+ if o != 0:
3061
+ return self._tab.String(o + self._tab.Pos)
3062
+ return None
3063
+
3064
+ # ModelMetadata
3065
+ def License(self):
3066
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(14))
3067
+ if o != 0:
3068
+ return self._tab.String(o + self._tab.Pos)
3069
+ return None
3070
+
3071
+ # ModelMetadata
3072
+ def AssociatedFiles(self, j):
3073
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
3074
+ if o != 0:
3075
+ x = self._tab.Vector(o)
3076
+ x += flatbuffers.number_types.UOffsetTFlags.py_type(j) * 4
3077
+ x = self._tab.Indirect(x)
3078
+ obj = AssociatedFile()
3079
+ obj.Init(self._tab.Bytes, x)
3080
+ return obj
3081
+ return None
3082
+
3083
+ # ModelMetadata
3084
+ def AssociatedFilesLength(self):
3085
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
3086
+ if o != 0:
3087
+ return self._tab.VectorLen(o)
3088
+ return 0
3089
+
3090
+ # ModelMetadata
3091
+ def AssociatedFilesIsNone(self):
3092
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(16))
3093
+ return o == 0
3094
+
3095
+ # ModelMetadata
3096
+ def MinParserVersion(self):
3097
+ o = flatbuffers.number_types.UOffsetTFlags.py_type(self._tab.Offset(18))
3098
+ if o != 0:
3099
+ return self._tab.String(o + self._tab.Pos)
3100
+ return None
3101
+
3102
+ def ModelMetadataStart(builder):
3103
+ builder.StartObject(8)
3104
+
3105
+ def ModelMetadataAddName(builder, name):
3106
+ builder.PrependUOffsetTRelativeSlot(0, flatbuffers.number_types.UOffsetTFlags.py_type(name), 0)
3107
+
3108
+ def ModelMetadataAddDescription(builder, description):
3109
+ builder.PrependUOffsetTRelativeSlot(1, flatbuffers.number_types.UOffsetTFlags.py_type(description), 0)
3110
+
3111
+ def ModelMetadataAddVersion(builder, version):
3112
+ builder.PrependUOffsetTRelativeSlot(2, flatbuffers.number_types.UOffsetTFlags.py_type(version), 0)
3113
+
3114
+ def ModelMetadataAddSubgraphMetadata(builder, subgraphMetadata):
3115
+ builder.PrependUOffsetTRelativeSlot(3, flatbuffers.number_types.UOffsetTFlags.py_type(subgraphMetadata), 0)
3116
+
3117
+ def ModelMetadataStartSubgraphMetadataVector(builder, numElems):
3118
+ return builder.StartVector(4, numElems, 4)
3119
+
3120
+ def ModelMetadataAddAuthor(builder, author):
3121
+ builder.PrependUOffsetTRelativeSlot(4, flatbuffers.number_types.UOffsetTFlags.py_type(author), 0)
3122
+
3123
+ def ModelMetadataAddLicense(builder, license):
3124
+ builder.PrependUOffsetTRelativeSlot(5, flatbuffers.number_types.UOffsetTFlags.py_type(license), 0)
3125
+
3126
+ def ModelMetadataAddAssociatedFiles(builder, associatedFiles):
3127
+ builder.PrependUOffsetTRelativeSlot(6, flatbuffers.number_types.UOffsetTFlags.py_type(associatedFiles), 0)
3128
+
3129
+ def ModelMetadataStartAssociatedFilesVector(builder, numElems):
3130
+ return builder.StartVector(4, numElems, 4)
3131
+
3132
+ def ModelMetadataAddMinParserVersion(builder, minParserVersion):
3133
+ builder.PrependUOffsetTRelativeSlot(7, flatbuffers.number_types.UOffsetTFlags.py_type(minParserVersion), 0)
3134
+
3135
+ def ModelMetadataEnd(builder):
3136
+ return builder.EndObject()
3137
+
3138
+
3139
+ try:
3140
+ from typing import List
3141
+ except:
3142
+ pass
3143
+
3144
+ class ModelMetadataT(object):
3145
+
3146
+ # ModelMetadataT
3147
+ def __init__(self):
3148
+ self.name = None # type: str
3149
+ self.description = None # type: str
3150
+ self.version = None # type: str
3151
+ self.subgraphMetadata = None # type: List[SubGraphMetadataT]
3152
+ self.author = None # type: str
3153
+ self.license = None # type: str
3154
+ self.associatedFiles = None # type: List[AssociatedFileT]
3155
+ self.minParserVersion = None # type: str
3156
+
3157
+ @classmethod
3158
+ def InitFromBuf(cls, buf, pos):
3159
+ modelMetadata = ModelMetadata()
3160
+ modelMetadata.Init(buf, pos)
3161
+ return cls.InitFromObj(modelMetadata)
3162
+
3163
+ @classmethod
3164
+ def InitFromPackedBuf(cls, buf, pos=0):
3165
+ n = flatbuffers.encode.Get(flatbuffers.packer.uoffset, buf, pos)
3166
+ return cls.InitFromBuf(buf, pos+n)
3167
+
3168
+ @classmethod
3169
+ def InitFromObj(cls, modelMetadata):
3170
+ x = ModelMetadataT()
3171
+ x._UnPack(modelMetadata)
3172
+ return x
3173
+
3174
+ # ModelMetadataT
3175
+ def _UnPack(self, modelMetadata):
3176
+ if modelMetadata is None:
3177
+ return
3178
+ self.name = modelMetadata.Name()
3179
+ self.description = modelMetadata.Description()
3180
+ self.version = modelMetadata.Version()
3181
+ if not modelMetadata.SubgraphMetadataIsNone():
3182
+ self.subgraphMetadata = []
3183
+ for i in range(modelMetadata.SubgraphMetadataLength()):
3184
+ if modelMetadata.SubgraphMetadata(i) is None:
3185
+ self.subgraphMetadata.append(None)
3186
+ else:
3187
+ subGraphMetadata_ = SubGraphMetadataT.InitFromObj(modelMetadata.SubgraphMetadata(i))
3188
+ self.subgraphMetadata.append(subGraphMetadata_)
3189
+ self.author = modelMetadata.Author()
3190
+ self.license = modelMetadata.License()
3191
+ if not modelMetadata.AssociatedFilesIsNone():
3192
+ self.associatedFiles = []
3193
+ for i in range(modelMetadata.AssociatedFilesLength()):
3194
+ if modelMetadata.AssociatedFiles(i) is None:
3195
+ self.associatedFiles.append(None)
3196
+ else:
3197
+ associatedFile_ = AssociatedFileT.InitFromObj(modelMetadata.AssociatedFiles(i))
3198
+ self.associatedFiles.append(associatedFile_)
3199
+ self.minParserVersion = modelMetadata.MinParserVersion()
3200
+
3201
+ # ModelMetadataT
3202
+ def Pack(self, builder):
3203
+ if self.name is not None:
3204
+ name = builder.CreateString(self.name)
3205
+ if self.description is not None:
3206
+ description = builder.CreateString(self.description)
3207
+ if self.version is not None:
3208
+ version = builder.CreateString(self.version)
3209
+ if self.subgraphMetadata is not None:
3210
+ subgraphMetadatalist = []
3211
+ for i in range(len(self.subgraphMetadata)):
3212
+ subgraphMetadatalist.append(self.subgraphMetadata[i].Pack(builder))
3213
+ ModelMetadataStartSubgraphMetadataVector(builder, len(self.subgraphMetadata))
3214
+ for i in reversed(range(len(self.subgraphMetadata))):
3215
+ builder.PrependUOffsetTRelative(subgraphMetadatalist[i])
3216
+ subgraphMetadata = builder.EndVector()
3217
+ if self.author is not None:
3218
+ author = builder.CreateString(self.author)
3219
+ if self.license is not None:
3220
+ license = builder.CreateString(self.license)
3221
+ if self.associatedFiles is not None:
3222
+ associatedFileslist = []
3223
+ for i in range(len(self.associatedFiles)):
3224
+ associatedFileslist.append(self.associatedFiles[i].Pack(builder))
3225
+ ModelMetadataStartAssociatedFilesVector(builder, len(self.associatedFiles))
3226
+ for i in reversed(range(len(self.associatedFiles))):
3227
+ builder.PrependUOffsetTRelative(associatedFileslist[i])
3228
+ associatedFiles = builder.EndVector()
3229
+ if self.minParserVersion is not None:
3230
+ minParserVersion = builder.CreateString(self.minParserVersion)
3231
+ ModelMetadataStart(builder)
3232
+ if self.name is not None:
3233
+ ModelMetadataAddName(builder, name)
3234
+ if self.description is not None:
3235
+ ModelMetadataAddDescription(builder, description)
3236
+ if self.version is not None:
3237
+ ModelMetadataAddVersion(builder, version)
3238
+ if self.subgraphMetadata is not None:
3239
+ ModelMetadataAddSubgraphMetadata(builder, subgraphMetadata)
3240
+ if self.author is not None:
3241
+ ModelMetadataAddAuthor(builder, author)
3242
+ if self.license is not None:
3243
+ ModelMetadataAddLicense(builder, license)
3244
+ if self.associatedFiles is not None:
3245
+ ModelMetadataAddAssociatedFiles(builder, associatedFiles)
3246
+ if self.minParserVersion is not None:
3247
+ ModelMetadataAddMinParserVersion(builder, minParserVersion)
3248
+ modelMetadata = ModelMetadataEnd(builder)
3249
+ return modelMetadata
3250
+
3251
+