matrice 1.0.99126__tar.gz → 1.0.99128__tar.gz

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 (239) hide show
  1. {matrice-1.0.99126/src/matrice.egg-info → matrice-1.0.99128}/PKG-INFO +1 -1
  2. {matrice-1.0.99126 → matrice-1.0.99128}/setup.py +1 -1
  3. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/config.py +5 -1
  4. matrice-1.0.99128/src/matrice/deploy/utils/post_processing/usecases/banana_defect_detection.py +624 -0
  5. matrice-1.0.99128/src/matrice/deploy/utils/post_processing/usecases/weld_defect_detection.py +615 -0
  6. {matrice-1.0.99126 → matrice-1.0.99128/src/matrice.egg-info}/PKG-INFO +1 -1
  7. matrice-1.0.99126/src/matrice/deploy/utils/post_processing/usecases/banana_defect_detection.py +0 -656
  8. matrice-1.0.99126/src/matrice/deploy/utils/post_processing/usecases/weld_defect_detection.py +0 -583
  9. {matrice-1.0.99126 → matrice-1.0.99128}/LICENSE.txt +0 -0
  10. {matrice-1.0.99126 → matrice-1.0.99128}/README.md +0 -0
  11. {matrice-1.0.99126 → matrice-1.0.99128}/setup.cfg +0 -0
  12. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/__init__.py +0 -0
  13. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/action.py +0 -0
  14. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/actionTracker.py +0 -0
  15. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/action_tracker.py +0 -0
  16. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/annotation.py +0 -0
  17. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/app_store.py +0 -0
  18. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/application.py +0 -0
  19. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute.py +0 -0
  20. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/__init__.py +0 -0
  21. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/action_instance.py +0 -0
  22. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/actions_manager.py +0 -0
  23. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/actions_scaledown_manager.py +0 -0
  24. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/instance_manager.py +0 -0
  25. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/instance_utils.py +0 -0
  26. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/prechecks.py +0 -0
  27. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/resources_tracker.py +0 -0
  28. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/scaling.py +0 -0
  29. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/shutdown_manager.py +0 -0
  30. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/compute_manager/task_utils.py +0 -0
  31. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/__init__.py +0 -0
  32. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/__init__.py +0 -0
  33. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/base.py +0 -0
  34. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/__init__.py +0 -0
  35. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/bit_depth_reduction.py +0 -0
  36. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/blur.py +0 -0
  37. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/brightness_contrast.py +0 -0
  38. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/color_jitter.py +0 -0
  39. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/compression_artifacts.py +0 -0
  40. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/downscale_upscale.py +0 -0
  41. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/film_grain.py +0 -0
  42. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/flip.py +0 -0
  43. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/fog.py +0 -0
  44. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/horizontal_flip.py +0 -0
  45. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/hsv.py +0 -0
  46. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/iso_noise.py +0 -0
  47. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/low_light.py +0 -0
  48. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/posterize.py +0 -0
  49. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/rain.py +0 -0
  50. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/random_affine.py +0 -0
  51. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/salt_pepper.py +0 -0
  52. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/shadows.py +0 -0
  53. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/snow.py +0 -0
  54. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/speckle.py +0 -0
  55. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/augmentation_utils/strategies/sunflare.py +0 -0
  56. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/client.py +0 -0
  57. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/client_utils.py +0 -0
  58. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/create_dataset.py +0 -0
  59. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_augmentation.py +0 -0
  60. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_augmentor.py +0 -0
  61. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/__init__.py +0 -0
  62. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/imagenet_classification.py +0 -0
  63. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/labelbox_classification.py +0 -0
  64. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/labelbox_detection.py +0 -0
  65. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/mscoco_detection.py +0 -0
  66. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/pascalvoc_detection.py +0 -0
  67. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/unlabelled.py +0 -0
  68. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/video_davis_segmentation.py +0 -0
  69. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/video_detection_mscoco.py +0 -0
  70. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/video_imagenet_classification.py +0 -0
  71. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/video_kinetics_activity_recognition.py +0 -0
  72. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/video_mot_tracking.py +0 -0
  73. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/video_mscoco_detection.py +0 -0
  74. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/video_youtube_bb_tracking.py +0 -0
  75. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_formats/yolo_detection.py +0 -0
  76. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_labelling.py +0 -0
  77. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_prep.py +0 -0
  78. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/data_processor.py +0 -0
  79. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/image_augmentations.py +0 -0
  80. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/image_data_augmentation.py +0 -0
  81. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/new_data_augmentation.py +0 -0
  82. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/pipeline.py +0 -0
  83. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/server.py +0 -0
  84. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/server_utils.py +0 -0
  85. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/data_processing/video_server.py +0 -0
  86. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/dataset.py +0 -0
  87. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/__init__.py +0 -0
  88. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/aggregator/__init__.py +0 -0
  89. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/aggregator/aggregator.py +0 -0
  90. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/aggregator/ingestor.py +0 -0
  91. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/aggregator/pipeline.py +0 -0
  92. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/aggregator/publisher.py +0 -0
  93. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/aggregator/synchronizer.py +0 -0
  94. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/__init__.py +0 -0
  95. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/auto_streaming/__init__.py +0 -0
  96. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/auto_streaming/auto_streaming.py +0 -0
  97. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/auto_streaming/auto_streaming_utils.py +0 -0
  98. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/client.py +0 -0
  99. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/client_stream_utils.py +0 -0
  100. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/client_utils.py +0 -0
  101. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/frame_comparators.py +0 -0
  102. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/streaming_gateway/__init__.py +0 -0
  103. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/streaming_gateway/streaming_gateway.py +0 -0
  104. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/streaming_gateway/streaming_gateway_utils.py +0 -0
  105. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/client/streaming_gateway/streaming_results_handler.py +0 -0
  106. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/__init__.py +0 -0
  107. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/inference/__init__.py +0 -0
  108. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/inference/batch_manager.py +0 -0
  109. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/inference/cache_manager.py +0 -0
  110. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/inference/inference_interface.py +0 -0
  111. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/inference/model_manager.py +0 -0
  112. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/inference/triton_utils.py +0 -0
  113. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/proxy/__init__.py +0 -0
  114. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/proxy/proxy_interface.py +0 -0
  115. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/proxy/proxy_utils.py +0 -0
  116. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/server.py +0 -0
  117. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/server/stream_worker.py +0 -0
  118. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/__init__.py +0 -0
  119. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/boundary_drawing_internal/__init__.py +0 -0
  120. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/boundary_drawing_internal/boundary_drawing_internal.py +0 -0
  121. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/boundary_drawing_internal/boundary_drawing_tool.py +0 -0
  122. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/boundary_drawing_internal/example_usage.py +0 -0
  123. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/kafka_utils.py +0 -0
  124. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/__init__.py +0 -0
  125. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/advanced_tracker/__init__.py +0 -0
  126. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/advanced_tracker/base.py +0 -0
  127. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/advanced_tracker/config.py +0 -0
  128. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/advanced_tracker/kalman_filter.py +0 -0
  129. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/advanced_tracker/matching.py +0 -0
  130. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/advanced_tracker/strack.py +0 -0
  131. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/advanced_tracker/tracker.py +0 -0
  132. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/core/__init__.py +0 -0
  133. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/core/base.py +0 -0
  134. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/core/config.py +0 -0
  135. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/core/config_utils.py +0 -0
  136. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/processor.py +0 -0
  137. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/__init__.py +0 -0
  138. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/run_tests.py +0 -0
  139. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_advanced_customer_service.py +0 -0
  140. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_basic_counting_tracking.py +0 -0
  141. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_comprehensive.py +0 -0
  142. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_config.py +0 -0
  143. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_customer_service.py +0 -0
  144. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_data_generators.py +0 -0
  145. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_people_counting.py +0 -0
  146. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_processor.py +0 -0
  147. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_utilities.py +0 -0
  148. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/test_cases/test_utils.py +0 -0
  149. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/__init__.py +0 -0
  150. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/advanced_customer_service.py +0 -0
  151. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/age_detection.py +0 -0
  152. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/anti_spoofing_detection.py +0 -0
  153. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/assembly_line_detection.py +0 -0
  154. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/basic_counting_tracking.py +0 -0
  155. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/blood_cancer_detection_img.py +0 -0
  156. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/car_damage_detection.py +0 -0
  157. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/car_part_segmentation.py +0 -0
  158. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/chicken_pose_detection.py +0 -0
  159. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/child_monitoring.py +0 -0
  160. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/color_detection.py +0 -0
  161. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/color_map_utils.py +0 -0
  162. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/concrete_crack_detection.py +0 -0
  163. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/crop_weed_detection.py +0 -0
  164. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/customer_service.py +0 -0
  165. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/defect_detection_products.py +0 -0
  166. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/distracted_driver_detection.py +0 -0
  167. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/emergency_vehicle_detection.py +0 -0
  168. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/face_emotion.py +0 -0
  169. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/fashion_detection.py +0 -0
  170. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/field_mapping.py +0 -0
  171. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/fire_detection.py +0 -0
  172. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/flare_analysis.py +0 -0
  173. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/flower_segmentation.py +0 -0
  174. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/gender_detection.py +0 -0
  175. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/leaf.py +0 -0
  176. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/leaf_disease.py +0 -0
  177. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/license_plate_detection.py +0 -0
  178. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/mask_detection.py +0 -0
  179. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/parking.py +0 -0
  180. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/parking_space_detection.py +0 -0
  181. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/pedestrian_detection.py +0 -0
  182. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/people_counting.py +0 -0
  183. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/plaque_segmentation_img.py +0 -0
  184. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/pothole_segmentation.py +0 -0
  185. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/ppe_compliance.py +0 -0
  186. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/price_tag_detection.py +0 -0
  187. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/road_lane_detection.py +0 -0
  188. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/shelf_inventory_detection.py +0 -0
  189. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/shoplifting_detection.py +0 -0
  190. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/shopping_cart_analysis.py +0 -0
  191. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/skin_cancer_classification_img.py +0 -0
  192. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/solar_panel.py +0 -0
  193. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/template_usecase.py +0 -0
  194. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/theft_detection.py +0 -0
  195. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/traffic_sign_monitoring.py +0 -0
  196. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/underwater_pollution_detection.py +0 -0
  197. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/vehicle_monitoring.py +0 -0
  198. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/warehouse_object_segmentation.py +0 -0
  199. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/weapon_detection.py +0 -0
  200. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/windmill_maintenance.py +0 -0
  201. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/usecases/wound_segmentation.py +0 -0
  202. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/__init__.py +0 -0
  203. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/advanced_counting_utils.py +0 -0
  204. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/advanced_helper_utils.py +0 -0
  205. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/advanced_tracking_utils.py +0 -0
  206. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/alerting_utils.py +0 -0
  207. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/category_mapping_utils.py +0 -0
  208. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/color_utils.py +0 -0
  209. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/counting_utils.py +0 -0
  210. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/filter_utils.py +0 -0
  211. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/format_utils.py +0 -0
  212. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/geometry_utils.py +0 -0
  213. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/smoothing_utils.py +0 -0
  214. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deploy/utils/post_processing/utils/tracking_utils.py +0 -0
  215. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deployment/__init__.py +0 -0
  216. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deployment/camera_manager.py +0 -0
  217. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deployment/deployment.py +0 -0
  218. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deployment/inference_pipeline.py +0 -0
  219. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/deployment/streaming_gateway_manager.py +0 -0
  220. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/docker_utils.py +0 -0
  221. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/drift_monitor.py +0 -0
  222. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/exported_model.py +0 -0
  223. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/local_test.py +0 -0
  224. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/metrics_calculator.py +0 -0
  225. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/metrics_calculator_oop.py +0 -0
  226. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/model_store.py +0 -0
  227. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/models.py +0 -0
  228. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/pipeline.py +0 -0
  229. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/projects.py +0 -0
  230. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/rpc.py +0 -0
  231. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/scaling.py +0 -0
  232. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/session.py +0 -0
  233. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/testing.py +0 -0
  234. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/token_auth.py +0 -0
  235. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice/utils.py +0 -0
  236. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice.egg-info/SOURCES.txt +0 -0
  237. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice.egg-info/dependency_links.txt +0 -0
  238. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice.egg-info/requires.txt +0 -0
  239. {matrice-1.0.99126 → matrice-1.0.99128}/src/matrice.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: matrice
3
- Version: 1.0.99126
3
+ Version: 1.0.99128
4
4
  Summary: SDK for connecting to matrice.ai services
5
5
  Home-page: https://github.com/matrice-ai/python-sdk
6
6
  Author: Matrice.ai
@@ -14,7 +14,7 @@ long_description = (here / "README.md").read_text(encoding="utf-8")
14
14
  setup(
15
15
  name="matrice",
16
16
 
17
- version = "1.0.99126",
17
+ version = "1.0.99128",
18
18
 
19
19
  description="SDK for connecting to matrice.ai services",
20
20
  long_description=long_description,
@@ -23,6 +23,8 @@ APP_NAME_TO_USECASE = {
23
23
  "flower_segmentation": "flower_segmentation",
24
24
  "shopping_cart_analysis": "shopping_cart_analysis",
25
25
  "car_part_segmentation": "car_part_segmentation",
26
+ "weld_defect_detection" : "weld_defect_detection",
27
+ "fruit_monitoring" : "fruit_monitoring",
26
28
  }
27
29
 
28
30
  APP_NAME_TO_CATEGORY = {
@@ -49,7 +51,9 @@ APP_NAME_TO_CATEGORY = {
49
51
  "warehouse_object_segmentation": "retail",
50
52
  "flower_segmentation": "agriculture",
51
53
  "shopping_cart_analysis": "retail",
52
- "car_part_segmentation": "automobile"
54
+ "car_part_segmentation": "automobile",
55
+ "weld_defect_detection" : "weld",
56
+ "fruit_monitoring" : "agriculture",
53
57
  }
54
58
 
55
59
  def get_usecase_from_app_name(app_name: str) -> str:
@@ -0,0 +1,624 @@
1
+ from typing import Any, Dict, List, Optional
2
+ from dataclasses import asdict
3
+ import time
4
+ from datetime import datetime, timezone
5
+
6
+ from ..core.base import BaseProcessor, ProcessingContext, ProcessingResult, ConfigProtocol
7
+ from ..utils import (
8
+ filter_by_confidence,
9
+ filter_by_categories,
10
+ apply_category_mapping,
11
+ count_objects_by_category,
12
+ count_objects_in_zones,
13
+ calculate_counting_summary,
14
+ match_results_structure,
15
+ bbox_smoothing,
16
+ BBoxSmoothingConfig,
17
+ BBoxSmoothingTracker
18
+ )
19
+ from dataclasses import dataclass, field
20
+ from ..core.config import BaseConfig, AlertConfig, ZoneConfig
21
+
22
+
23
+ @dataclass
24
+ class BananaMonitoringConfig(BaseConfig):
25
+ """Configuration for banana defect detection use case."""
26
+ enable_smoothing: bool = True
27
+ smoothing_algorithm: str = "observability"
28
+ smoothing_window_size: int = 20
29
+ smoothing_cooldown_frames: int = 5
30
+ smoothing_confidence_range_factor: float = 0.5
31
+ confidence_threshold: float = 0.6
32
+ fruit_categories: List[str] = field(
33
+ default_factory=lambda: ['freshripe', 'freshunripe', 'overripe', 'ripe', 'rotten', 'unripe']
34
+ )
35
+ target_fruit_categories: List[str] = field(
36
+ default_factory=lambda: ['freshripe', 'freshunripe', 'overripe', 'ripe', 'rotten', 'unripe']
37
+ )
38
+ alert_config: Optional[AlertConfig] = None
39
+ index_to_category: Optional[Dict[int, str]] = field(
40
+ default_factory=lambda: {
41
+ 0: "overripe",
42
+ 1: "rotten",
43
+ 2: "ripe",
44
+ 3: "unripe",
45
+ 4: "freshripe",
46
+ 5: "freshunripe"
47
+ }
48
+ )
49
+
50
+
51
+ class BananaMonitoringUseCase(BaseProcessor):
52
+ CATEGORY_DISPLAY = {
53
+ "freshripe": "Fresh Ripe",
54
+ "freshunripe": "Fresh Unripe",
55
+ "overripe": "Overripe",
56
+ "ripe": "Ripe",
57
+ "rotten": "Rotten",
58
+ "unripe": "Unripe"
59
+ }
60
+
61
+ def __init__(self):
62
+ super().__init__("fruit_monitoring")
63
+ self.category = "agriculture"
64
+ self.CASE_TYPE: Optional[str] = 'banana_defect_detection'
65
+ self.CASE_VERSION: Optional[str] = '1.0'
66
+ self.target_categories = ['freshripe', 'freshunripe', 'overripe', 'ripe', 'rotten', 'unripe']
67
+ self.smoothing_tracker = None
68
+ self.tracker = None
69
+ self._total_frame_counter = 0
70
+ self._global_frame_offset = 0
71
+ self._tracking_start_time = None
72
+ self._track_aliases: Dict[Any, Any] = {}
73
+ self._canonical_tracks: Dict[Any, Dict[str, Any]] = {}
74
+ self._track_merge_iou_threshold: float = 0.05
75
+ self._track_merge_time_window: float = 7.0
76
+ self._ascending_alert_list: List[int] = []
77
+ self.current_incident_end_timestamp: str = "N/A"
78
+
79
+ def process(self, data: Any, config: ConfigProtocol, context: Optional[ProcessingContext] = None,
80
+ stream_info: Optional[Dict[str, Any]] = None) -> ProcessingResult:
81
+ start_time = time.time()
82
+ if not isinstance(config, BananaMonitoringConfig):
83
+ return self.create_error_result("Invalid config type", usecase=self.name, category=self.category, context=context)
84
+ if context is None:
85
+ context = ProcessingContext()
86
+
87
+ input_format = match_results_structure(data)
88
+ context.input_format = input_format
89
+ context.confidence_threshold = config.confidence_threshold
90
+
91
+ if config.confidence_threshold is not None:
92
+ processed_data = filter_by_confidence(data, config.confidence_threshold)
93
+ self.logger.debug(f"Applied confidence filtering with threshold {config.confidence_threshold}")
94
+ else:
95
+ processed_data = data
96
+ self.logger.debug("No confidence filtering applied")
97
+
98
+ if config.index_to_category:
99
+ processed_data = apply_category_mapping(processed_data, config.index_to_category)
100
+ self.logger.debug("Applied category mapping")
101
+
102
+ if config.target_fruit_categories:
103
+ processed_data = [d for d in processed_data if d.get('category') in self.target_categories]
104
+ self.logger.debug("Applied category filtering")
105
+
106
+ if config.enable_smoothing:
107
+ if self.smoothing_tracker is None:
108
+ smoothing_config = BBoxSmoothingConfig(
109
+ smoothing_algorithm=config.smoothing_algorithm,
110
+ window_size=config.smoothing_window_size,
111
+ cooldown_frames=config.smoothing_cooldown_frames,
112
+ confidence_threshold=config.confidence_threshold,
113
+ confidence_range_factor=config.smoothing_confidence_range_factor,
114
+ enable_smoothing=True
115
+ )
116
+ self.smoothing_tracker = BBoxSmoothingTracker(smoothing_config)
117
+ processed_data = bbox_smoothing(processed_data, self.smoothing_tracker.config, self.smoothing_tracker)
118
+
119
+ try:
120
+ from ..advanced_tracker import AdvancedTracker
121
+ from ..advanced_tracker.config import TrackerConfig
122
+ if self.tracker is None:
123
+ tracker_config = TrackerConfig()
124
+ self.tracker = AdvancedTracker(tracker_config)
125
+ self.logger.info("Initialized AdvancedTracker for Banana Monitoring")
126
+ processed_data = self.tracker.update(processed_data)
127
+ except Exception as e:
128
+ self.logger.warning(f"AdvancedTracker failed: {e}")
129
+
130
+ self._update_tracking_state(processed_data)
131
+ self._total_frame_counter += 1
132
+
133
+ frame_number = None
134
+ if stream_info:
135
+ input_settings = stream_info.get("input_settings", {})
136
+ start_frame = input_settings.get("start_frame")
137
+ end_frame = input_settings.get("end_frame")
138
+ if start_frame is not None and end_frame is not None and start_frame == end_frame:
139
+ frame_number = start_frame
140
+
141
+ general_counting_summary = calculate_counting_summary(data)
142
+ counting_summary = self._count_categories(processed_data, config)
143
+ total_counts = self.get_total_counts()
144
+ counting_summary['total_counts'] = total_counts
145
+ alerts = self._check_alerts(counting_summary, frame_number, config)
146
+ predictions = self._extract_predictions(processed_data)
147
+
148
+ incidents_list = self._generate_incidents(counting_summary, alerts, config, frame_number, stream_info)
149
+ tracking_stats_list = self._generate_tracking_stats(counting_summary, alerts, config, frame_number, stream_info)
150
+ business_analytics_list = self._generate_business_analytics(counting_summary, alerts, config, stream_info, is_empty=True)
151
+ summary_list = self._generate_summary(counting_summary, incidents_list, tracking_stats_list, business_analytics_list, alerts)
152
+
153
+ incidents = incidents_list[0] if incidents_list else {}
154
+ tracking_stats = tracking_stats_list[0] if tracking_stats_list else {}
155
+ business_analytics = business_analytics_list[0] if business_analytics_list else {}
156
+ summary = summary_list[0] if summary_list else {}
157
+ agg_summary = {str(frame_number): {
158
+ "incidents": incidents,
159
+ "tracking_stats": tracking_stats,
160
+ "business_analytics": business_analytics,
161
+ "alerts": alerts,
162
+ "human_text": summary}
163
+ }
164
+
165
+ context.mark_completed()
166
+ result = self.create_result(
167
+ data={"agg_summary": agg_summary},
168
+ usecase=self.name,
169
+ category=self.category,
170
+ context=context
171
+ )
172
+ return result
173
+
174
+ def _check_alerts(self, summary: dict, frame_number: Any, config: BananaMonitoringConfig) -> List[Dict]:
175
+ def get_trend(data, lookback=900, threshold=0.6):
176
+ window = data[-lookback:] if len(data) >= lookback else data
177
+ if len(window) < 2:
178
+ return True
179
+ increasing = 0
180
+ total = 0
181
+ for i in range(1, len(window)):
182
+ if window[i] >= window[i - 1]:
183
+ increasing += 1
184
+ total += 1
185
+ ratio = increasing / total
186
+ return ratio >= threshold
187
+
188
+ frame_key = str(frame_number) if frame_number is not None else "current_frame"
189
+ alerts = []
190
+ total_detections = summary.get("total_count", 0)
191
+ total_counts_dict = summary.get("total_counts", {})
192
+ per_category_count = summary.get("per_category_count", {})
193
+
194
+ if not config.alert_config:
195
+ return alerts
196
+
197
+ total = summary.get("total_count", 0)
198
+ if hasattr(config.alert_config, 'count_thresholds') and config.alert_config.count_thresholds:
199
+ for category, threshold in config.alert_config.count_thresholds.items():
200
+ if category == "all" and total > threshold:
201
+ alerts.append({
202
+ "alert_type": getattr(config.alert_config, 'alert_type', ['Default']),
203
+ "alert_id": f"alert_{category}_{frame_key}",
204
+ "incident_category": self.CASE_TYPE,
205
+ "threshold_level": threshold,
206
+ "ascending": get_trend(self._ascending_alert_list, lookback=900, threshold=0.8),
207
+ "settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
208
+ getattr(config.alert_config, 'alert_value', ['JSON']))}
209
+ })
210
+ elif category in per_category_count:
211
+ count = per_category_count[category]
212
+ if count > threshold:
213
+ alerts.append({
214
+ "alert_type": getattr(config.alert_config, 'alert_type', ['Default']),
215
+ "alert_id": f"alert_{category}_{frame_key}",
216
+ "incident_category": self.CASE_TYPE,
217
+ "threshold_level": threshold,
218
+ "ascending": get_trend(self._ascending_alert_list, lookback=900, threshold=0.8),
219
+ "settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
220
+ getattr(config.alert_config, 'alert_value', ['JSON']))}
221
+ })
222
+ return alerts
223
+
224
+ def _generate_incidents(self, counting_summary: Dict, alerts: List, config: BananaMonitoringConfig,
225
+ frame_number: Optional[int] = None, stream_info: Optional[Dict[str, Any]] = None) -> List[Dict]:
226
+ incidents = []
227
+ total_detections = counting_summary.get("total_count", 0)
228
+ current_timestamp = self._get_current_timestamp_str(stream_info)
229
+ camera_info = self.get_camera_info_from_stream(stream_info)
230
+
231
+ self._ascending_alert_list = self._ascending_alert_list[-900:] if len(self._ascending_alert_list) > 900 else self._ascending_alert_list
232
+
233
+ if total_detections > 0:
234
+ level = "low"
235
+ intensity = 5.0
236
+ start_timestamp = self._get_start_timestamp_str(stream_info)
237
+ if start_timestamp and self.current_incident_end_timestamp == 'N/A':
238
+ self.current_incident_end_timestamp = 'Incident still active'
239
+ elif start_timestamp and self.current_incident_end_timestamp == 'Incident still active':
240
+ if len(self._ascending_alert_list) >= 15 and sum(self._ascending_alert_list[-15:]) / 15 < 1.5:
241
+ self.current_incident_end_timestamp = current_timestamp
242
+ elif self.current_incident_end_timestamp != 'Incident still active' and self.current_incident_end_timestamp != 'N/A':
243
+ self.current_incident_end_timestamp = 'N/A'
244
+
245
+ if config.alert_config and config.alert_config.count_thresholds:
246
+ threshold = config.alert_config.count_thresholds.get("all", 15)
247
+ intensity = min(10.0, (total_detections / threshold) * 10)
248
+ if intensity >= 9:
249
+ level = "critical"
250
+ self._ascending_alert_list.append(3)
251
+ elif intensity >= 7:
252
+ level = "significant"
253
+ self._ascending_alert_list.append(2)
254
+ elif intensity >= 5:
255
+ level = "medium"
256
+ self._ascending_alert_list.append(1)
257
+ else:
258
+ level = "low"
259
+ self._ascending_alert_list.append(0)
260
+ else:
261
+ if total_detections > 30:
262
+ level = "critical"
263
+ intensity = 10.0
264
+ self._ascending_alert_list.append(3)
265
+ elif total_detections > 25:
266
+ level = "significant"
267
+ intensity = 9.0
268
+ self._ascending_alert_list.append(2)
269
+ elif total_detections > 15:
270
+ level = "medium"
271
+ intensity = 7.0
272
+ self._ascending_alert_list.append(1)
273
+ else:
274
+ level = "low"
275
+ intensity = min(10.0, total_detections / 3.0)
276
+ self._ascending_alert_list.append(0)
277
+
278
+ human_text_lines = [f"INCIDENTS DETECTED @ {current_timestamp}:"]
279
+ human_text_lines.append(f"\tSeverity Level: {(self.CASE_TYPE, level)}")
280
+ human_text = "\n".join(human_text_lines)
281
+
282
+ alert_settings = []
283
+ if config.alert_config and hasattr(config.alert_config, 'alert_type'):
284
+ alert_settings.append({
285
+ "alert_type": getattr(config.alert_config, 'alert_type', ['Default']),
286
+ "incident_category": self.CASE_TYPE,
287
+ "threshold_level": config.alert_config.count_thresholds if hasattr(config.alert_config, 'count_thresholds') else {},
288
+ "ascending": True,
289
+ "settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
290
+ getattr(config.alert_config, 'alert_value', ['JSON']))}
291
+ })
292
+
293
+ event = self.create_incident(
294
+ incident_id=self.CASE_TYPE + '_' + str(frame_number),
295
+ incident_type=self.CASE_TYPE,
296
+ severity_level=level,
297
+ human_text=human_text,
298
+ camera_info=camera_info,
299
+ alerts=alerts,
300
+ alert_settings=alert_settings,
301
+ start_time=start_timestamp,
302
+ end_time=self.current_incident_end_timestamp,
303
+ level_settings={"low": 1, "medium": 3, "significant": 4, "critical": 7}
304
+ )
305
+ incidents.append(event)
306
+ else:
307
+ self._ascending_alert_list.append(0)
308
+ incidents.append({})
309
+ return incidents
310
+
311
+ def _generate_tracking_stats(self, counting_summary: Dict, alerts: List, config: BananaMonitoringConfig,
312
+ frame_number: Optional[int] = None, stream_info: Optional[Dict[str, Any]] = None) -> List[Dict]:
313
+ camera_info = self.get_camera_info_from_stream(stream_info)
314
+ tracking_stats = []
315
+ total_detections = counting_summary.get("total_count", 0)
316
+ total_counts_dict = counting_summary.get("total_counts", {})
317
+ per_category_count = counting_summary.get("per_category_count", {})
318
+ current_timestamp = self._get_current_timestamp_str(stream_info, precision=False)
319
+ start_timestamp = self._get_start_timestamp_str(stream_info, precision=False)
320
+ high_precision_start_timestamp = self._get_current_timestamp_str(stream_info, precision=True)
321
+ high_precision_reset_timestamp = self._get_start_timestamp_str(stream_info, precision=True)
322
+
323
+ total_counts = [{"category": cat, "count": count} for cat, count in total_counts_dict.items() if count > 0]
324
+ current_counts = [{"category": cat, "count": count} for cat, count in per_category_count.items() if count > 0 or total_detections > 0]
325
+
326
+ detections = []
327
+ for detection in counting_summary.get("detections", []):
328
+ bbox = detection.get("bounding_box", {})
329
+ category = detection.get("category", "banana")
330
+ if detection.get("masks"):
331
+ segmentation = detection.get("masks", [])
332
+ detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
333
+ elif detection.get("segmentation"):
334
+ segmentation = detection.get("segmentation")
335
+ detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
336
+ elif detection.get("mask"):
337
+ segmentation = detection.get("mask")
338
+ detection_obj = self.create_detection_object(category, bbox, segmentation=segmentation)
339
+ else:
340
+ detection_obj = self.create_detection_object(category, bbox)
341
+ detections.append(detection_obj)
342
+
343
+ alert_settings = []
344
+ if config.alert_config and hasattr(config.alert_config, 'alert_type'):
345
+ alert_settings.append({
346
+ "alert_type": getattr(config.alert_config, 'alert_type', ['Default']),
347
+ "incident_category": self.CASE_TYPE,
348
+ "threshold_level": config.alert_config.count_thresholds if hasattr(config.alert_config, 'count_thresholds') else {},
349
+ "ascending": True,
350
+ "settings": {t: v for t, v in zip(getattr(config.alert_config, 'alert_type', ['Default']),
351
+ getattr(config.alert_config, 'alert_value', ['JSON']))}
352
+ })
353
+
354
+ human_text_lines = [f"Tracking Statistics:"]
355
+ human_text_lines.append(f"CURRENT FRAME @ {current_timestamp}")
356
+ for cat, count in per_category_count.items():
357
+ human_text_lines.append(f"\t{cat}: {count}")
358
+ human_text_lines.append(f"TOTAL SINCE {start_timestamp}")
359
+ for cat, count in total_counts_dict.items():
360
+ if count > 0:
361
+ human_text_lines.append(f"\t{cat}: {count}")
362
+ if alerts:
363
+ for alert in alerts:
364
+ human_text_lines.append(f"Alerts: {alert.get('settings', {})} sent @ {current_timestamp}")
365
+ else:
366
+ human_text_lines.append("Alerts: None")
367
+ human_text = "\n".join(human_text_lines)
368
+
369
+ reset_settings = [{"interval_type": "daily", "reset_time": {"value": 9, "time_unit": "hour"}}]
370
+ tracking_stat = self.create_tracking_stats(
371
+ total_counts=total_counts,
372
+ current_counts=current_counts,
373
+ detections=detections,
374
+ human_text=human_text,
375
+ camera_info=camera_info,
376
+ alerts=alerts,
377
+ alert_settings=alert_settings,
378
+ reset_settings=reset_settings,
379
+ start_time=high_precision_start_timestamp,
380
+ reset_time=high_precision_reset_timestamp
381
+ )
382
+ tracking_stats.append(tracking_stat)
383
+ return tracking_stats
384
+
385
+ def _generate_business_analytics(self, counting_summary: Dict, alerts: Any, config: BananaMonitoringConfig,
386
+ stream_info: Optional[Dict[str, Any]] = None, is_empty=False) -> List[Dict]:
387
+ if is_empty:
388
+ return []
389
+
390
+ def _generate_summary(self, summary: dict, incidents: List, tracking_stats: List, business_analytics: List, alerts: List) -> List[Dict]:
391
+ lines = {}
392
+ lines["Application Name"] = self.CASE_TYPE
393
+ lines["Application Version"] = self.CASE_VERSION
394
+ if len(incidents) > 0:
395
+ lines["Incidents"] = f"\n\t{incidents[0].get('human_text', 'No incidents detected')}\n"
396
+ if len(tracking_stats) > 0:
397
+ lines["Tracking Statistics"] = f"\t{tracking_stats[0].get('human_text', 'No tracking statistics detected')}\n"
398
+ if len(business_analytics) > 0:
399
+ lines["Business Analytics"] = f"\t{business_analytics[0].get('human_text', 'No business analytics detected')}\n"
400
+ if len(incidents) == 0 and len(tracking_stats) == 0 and len(business_analytics) == 0:
401
+ lines["Summary"] = "No Summary Data"
402
+ return [lines]
403
+
404
+ def _get_track_ids_info(self, detections: list) -> Dict[str, Any]:
405
+ frame_track_ids = set()
406
+ for det in detections:
407
+ tid = det.get('track_id')
408
+ if tid is not None:
409
+ frame_track_ids.add(tid)
410
+ total_track_ids = set()
411
+ for s in getattr(self, '_per_category_total_track_ids', {}).values():
412
+ total_track_ids.update(s)
413
+ return {
414
+ "total_count": len(total_track_ids),
415
+ "current_frame_count": len(frame_track_ids),
416
+ "total_unique_track_ids": len(total_track_ids),
417
+ "current_frame_track_ids": list(frame_track_ids),
418
+ "last_update_time": time.time(),
419
+ "total_frames_processed": getattr(self, '_total_frame_counter', 0)
420
+ }
421
+
422
+ def _update_tracking_state(self, detections: list):
423
+ if not hasattr(self, "_per_category_total_track_ids"):
424
+ self._per_category_total_track_ids = {cat: set() for cat in self.target_categories}
425
+ self._current_frame_track_ids = {cat: set() for cat in self.target_categories}
426
+
427
+ for det in detections:
428
+ cat = det.get("category")
429
+ raw_track_id = det.get("track_id")
430
+ if cat not in self.target_categories or raw_track_id is None:
431
+ continue
432
+ bbox = det.get("bounding_box", det.get("bbox"))
433
+ canonical_id = self._merge_or_register_track(raw_track_id, bbox)
434
+ det["track_id"] = canonical_id
435
+ self._per_category_total_track_ids.setdefault(cat, set()).add(canonical_id)
436
+ self._current_frame_track_ids[cat].add(canonical_id)
437
+
438
+ def get_total_counts(self):
439
+ return {cat: len(ids) for cat, ids in getattr(self, '_per_category_total_track_ids', {}).items()}
440
+
441
+ def _format_timestamp_for_stream(self, timestamp: float) -> str:
442
+ dt = datetime.fromtimestamp(timestamp, tz=timezone.utc)
443
+ return dt.strftime('%Y:%m:%d %H:%M:%S')
444
+
445
+ def _format_timestamp_for_video(self, timestamp: float) -> str:
446
+ hours = int(timestamp // 3600)
447
+ minutes = int((timestamp % 3600) // 60)
448
+ seconds = round(float(timestamp % 60), 2)
449
+ return f"{hours:02d}:{minutes:02d}:{seconds:.1f}"
450
+
451
+ def _get_current_timestamp_str(self, stream_info: Optional[Dict[str, Any]], precision=False, frame_id: Optional[str] = None) -> str:
452
+ if not stream_info:
453
+ return "00:00:00.00"
454
+ if precision:
455
+ if stream_info.get("input_settings", {}).get("start_frame", "na") != "na":
456
+ if frame_id:
457
+ start_time = int(frame_id) / stream_info.get("input_settings", {}).get("original_fps", 30)
458
+ else:
459
+ start_time = stream_info.get("input_settings", {}).get("start_frame", 30) / stream_info.get("input_settings", {}).get("original_fps", 30)
460
+ stream_time_str = self._format_timestamp_for_video(start_time)
461
+ return stream_time_str
462
+ else:
463
+ return datetime.now(timezone.utc).strftime("%Y-%m-%d-%H:%M:%S.%f UTC")
464
+ if stream_info.get("input_settings", {}).get("start_frame", "na") != "na":
465
+ if frame_id:
466
+ start_time = int(frame_id) / stream_info.get("input_settings", {}).get("original_fps", 30)
467
+ else:
468
+ start_time = stream_info.get("input_settings", {}).get("start_frame", 30) / stream_info.get("input_settings", {}).get("original_fps", 30)
469
+ stream_time_str = self._format_timestamp_for_video(start_time)
470
+ return stream_time_str
471
+ else:
472
+ stream_time_str = stream_info.get("input_settings", {}).get("stream_info", {}).get("stream_time", "")
473
+ if stream_time_str:
474
+ try:
475
+ timestamp_str = stream_time_str.replace(" UTC", "")
476
+ dt = datetime.strptime(timestamp_str, "%Y-%m-%d-%H:%M:%S.%f")
477
+ timestamp = dt.replace(tzinfo=timezone.utc).timestamp()
478
+ return self._format_timestamp_for_stream(timestamp)
479
+ except:
480
+ return self._format_timestamp_for_stream(time.time())
481
+ else:
482
+ return self._format_timestamp_for_stream(time.time())
483
+
484
+ def _get_start_timestamp_str(self, stream_info: Optional[Dict[str, Any]], precision=False) -> str:
485
+ if not stream_info:
486
+ return "00:00:00"
487
+ if precision:
488
+ if stream_info.get("input_settings", {}).get("start_frame", "na") != "na":
489
+ return "00:00:00"
490
+ else:
491
+ return datetime.now(timezone.utc).strftime("%Y-%m-%d-%H:%M:%S.%f UTC")
492
+ if stream_info.get("input_settings", {}).get("start_frame", "na") != "na":
493
+ return "00:00:00"
494
+ else:
495
+ if self._tracking_start_time is None:
496
+ stream_time_str = stream_info.get("input_settings", {}).get("stream_info", {}).get("stream_time", "")
497
+ if stream_time_str:
498
+ try:
499
+ timestamp_str = stream_time_str.replace(" UTC", "")
500
+ dt = datetime.strptime(timestamp_str, "%Y-%m-%d-%H:%M:%S.%f")
501
+ self._tracking_start_time = dt.replace(tzinfo=timezone.utc).timestamp()
502
+ except:
503
+ self._tracking_start_time = time.time()
504
+ else:
505
+ self._tracking_start_time = time.time()
506
+ dt = datetime.fromtimestamp(self._tracking_start_time, tz=timezone.utc)
507
+ dt = dt.replace(minute=0, second=0, microsecond=0)
508
+ return dt.strftime('%Y:%m:%d %H:%M:%S')
509
+
510
+ def _count_categories(self, detections: list, config: BananaMonitoringConfig) -> dict:
511
+ counts = {}
512
+ for det in detections:
513
+ cat = det.get('category', 'unknown')
514
+ counts[cat] = counts.get(cat, 0) + 1
515
+ return {
516
+ "total_count": sum(counts.values()),
517
+ "per_category_count": counts,
518
+ "detections": [
519
+ {
520
+ "bounding_box": det.get("bounding_box"),
521
+ "category": det.get("category"),
522
+ "confidence": det.get("confidence"),
523
+ "track_id": det.get("track_id"),
524
+ "frame_id": det.get("frame_id")
525
+ }
526
+ for det in detections
527
+ ]
528
+ }
529
+
530
+ def _extract_predictions(self, detections: list) -> List[Dict[str, Any]]:
531
+ return [
532
+ {
533
+ "category": det.get("category", "unknown"),
534
+ "confidence": det.get("confidence", 0.0),
535
+ "bounding_box": det.get("bounding_box", {})
536
+ }
537
+ for det in detections
538
+ ]
539
+
540
+ def _compute_iou(self, box1: Any, box2: Any) -> float:
541
+ def _bbox_to_list(bbox):
542
+ if bbox is None:
543
+ return []
544
+ if isinstance(bbox, list):
545
+ return bbox[:4] if len(bbox) >= 4 else []
546
+ if isinstance(bbox, dict):
547
+ if "xmin" in bbox:
548
+ return [bbox["xmin"], bbox["ymin"], bbox["xmax"], bbox["ymax"]]
549
+ if "x1" in bbox:
550
+ return [bbox["x1"], bbox["y1"], bbox["x2"], bbox["y2"]]
551
+ values = [v for v in bbox.values() if isinstance(v, (int, float))]
552
+ return values[:4] if len(values) >= 4 else []
553
+ return []
554
+
555
+ l1 = _bbox_to_list(box1)
556
+ l2 = _bbox_to_list(box2)
557
+ if len(l1) < 4 or len(l2) < 4:
558
+ return 0.0
559
+ x1_min, y1_min, x1_max, y1_max = l1
560
+ x2_min, y2_min, x2_max, y2_max = l2
561
+
562
+ x1_min, x1_max = min(x1_min, x1_max), max(x1_min, x1_max)
563
+ y1_min, y1_max = min(y1_min, y1_max), max(y1_min, y1_max)
564
+ x2_min, x2_max = min(x2_min, x2_max), max(x2_min, x2_max)
565
+ y2_min, y2_max = min(y2_min, y2_max), max(y2_min, y2_max)
566
+
567
+ inter_x_min = max(x1_min, x2_min)
568
+ inter_y_min = max(y1_min, y2_min)
569
+ inter_x_max = min(x1_max, x2_max)
570
+ inter_y_max = min(y1_max, y2_max)
571
+
572
+ inter_w = max(0.0, inter_x_max - inter_x_min)
573
+ inter_h = max(0.0, inter_y_max - inter_y_min)
574
+ inter_area = inter_w * inter_h
575
+
576
+ area1 = (x1_max - x1_min) * (y1_max - y1_min)
577
+ area2 = (x2_max - x2_min) * (y2_max - y2_min)
578
+ union_area = area1 + area2 - inter_area
579
+
580
+ return (inter_area / union_area) if union_area > 0 else 0.0
581
+
582
+ def _merge_or_register_track(self, raw_id: Any, bbox: Any) -> Any:
583
+ if raw_id is None or bbox is None:
584
+ return raw_id
585
+ now = time.time()
586
+ if raw_id in self._track_aliases:
587
+ canonical_id = self._track_aliases[raw_id]
588
+ track_info = self._canonical_tracks.get(canonical_id)
589
+ if track_info is not None:
590
+ track_info["last_bbox"] = bbox
591
+ track_info["last_update"] = now
592
+ track_info["raw_ids"].add(raw_id)
593
+ return canonical_id
594
+
595
+ for canonical_id, info in self._canonical_tracks.items():
596
+ if now - info["last_update"] > self._track_merge_time_window:
597
+ continue
598
+ iou = self._compute_iou(bbox, info["last_bbox"])
599
+ if iou >= self._track_merge_iou_threshold:
600
+ self._track_aliases[raw_id] = canonical_id
601
+ info["last_bbox"] = bbox
602
+ info["last_update"] = now
603
+ info["raw_ids"].add(raw_id)
604
+ return canonical_id
605
+
606
+ canonical_id = raw_id
607
+ self._track_aliases[raw_id] = canonical_id
608
+ self._canonical_tracks[canonical_id] = {
609
+ "last_bbox": bbox,
610
+ "last_update": now,
611
+ "raw_ids": {raw_id},
612
+ }
613
+ return canonical_id
614
+
615
+ def _format_timestamp(self, timestamp: float) -> str:
616
+ return datetime.fromtimestamp(timestamp, timezone.utc).strftime('%Y-%m-%d %H:%M:%S UTC')
617
+
618
+ def _get_tracking_start_time(self) -> str:
619
+ if self._tracking_start_time is None:
620
+ return "N/A"
621
+ return self._format_timestamp(self._tracking_start_time)
622
+
623
+ def _set_tracking_start_time(self) -> None:
624
+ self._tracking_start_time = time.time()