ultralytics 8.1.41__tar.gz → 8.1.43__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.

Potentially problematic release.


This version of ultralytics might be problematic. Click here for more details.

Files changed (217) hide show
  1. {ultralytics-8.1.41/ultralytics.egg-info → ultralytics-8.1.43}/PKG-INFO +2 -1
  2. {ultralytics-8.1.41 → ultralytics-8.1.43}/pyproject.toml +1 -0
  3. {ultralytics-8.1.41 → ultralytics-8.1.43}/tests/test_python.py +11 -18
  4. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/__init__.py +1 -1
  5. ultralytics-8.1.43/ultralytics/cfg/models/v9/yolov9c-seg.yaml +38 -0
  6. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v9/yolov9c.yaml +3 -1
  7. ultralytics-8.1.43/ultralytics/cfg/models/v9/yolov9e-seg.yaml +62 -0
  8. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v9/yolov9e.yaml +3 -1
  9. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/augment.py +12 -9
  10. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/dataset.py +147 -142
  11. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/explorer/explorer.py +4 -6
  12. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/explorer/gui/dash.py +3 -3
  13. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/explorer/utils.py +3 -2
  14. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/engine/exporter.py +3 -2
  15. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/engine/trainer.py +11 -10
  16. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/fastsam/prompt.py +4 -1
  17. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/predict.py +4 -1
  18. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/classify/train.py +2 -1
  19. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/solutions/heatmap.py +14 -27
  20. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/solutions/object_counter.py +12 -23
  21. ultralytics-8.1.43/ultralytics/solutions/queue_management.py +187 -0
  22. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/__init__.py +22 -14
  23. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/benchmarks.py +1 -2
  24. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/clearml.py +4 -3
  25. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/wb.py +5 -5
  26. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/checks.py +6 -9
  27. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/metrics.py +3 -3
  28. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/ops.py +1 -1
  29. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/plotting.py +96 -37
  30. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/torch_utils.py +15 -7
  31. {ultralytics-8.1.41 → ultralytics-8.1.43/ultralytics.egg-info}/PKG-INFO +2 -1
  32. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics.egg-info/SOURCES.txt +3 -0
  33. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics.egg-info/requires.txt +3 -0
  34. {ultralytics-8.1.41 → ultralytics-8.1.43}/LICENSE +0 -0
  35. {ultralytics-8.1.41 → ultralytics-8.1.43}/README.md +0 -0
  36. {ultralytics-8.1.41 → ultralytics-8.1.43}/setup.cfg +0 -0
  37. {ultralytics-8.1.41 → ultralytics-8.1.43}/tests/test_cli.py +0 -0
  38. {ultralytics-8.1.41 → ultralytics-8.1.43}/tests/test_cuda.py +0 -0
  39. {ultralytics-8.1.41 → ultralytics-8.1.43}/tests/test_engine.py +0 -0
  40. {ultralytics-8.1.41 → ultralytics-8.1.43}/tests/test_explorer.py +0 -0
  41. {ultralytics-8.1.41 → ultralytics-8.1.43}/tests/test_integrations.py +0 -0
  42. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/assets/bus.jpg +0 -0
  43. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/assets/zidane.jpg +0 -0
  44. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/__init__.py +0 -0
  45. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/Argoverse.yaml +0 -0
  46. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/DOTAv1.5.yaml +0 -0
  47. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/DOTAv1.yaml +0 -0
  48. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/GlobalWheat2020.yaml +0 -0
  49. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/ImageNet.yaml +0 -0
  50. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/Objects365.yaml +0 -0
  51. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/SKU-110K.yaml +0 -0
  52. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/VOC.yaml +0 -0
  53. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/VisDrone.yaml +0 -0
  54. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/african-wildlife.yaml +0 -0
  55. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/brain-tumor.yaml +0 -0
  56. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/carparts-seg.yaml +0 -0
  57. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/coco-pose.yaml +0 -0
  58. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/coco.yaml +0 -0
  59. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/coco128-seg.yaml +0 -0
  60. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/coco128.yaml +0 -0
  61. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/coco8-pose.yaml +0 -0
  62. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/coco8-seg.yaml +0 -0
  63. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/coco8.yaml +0 -0
  64. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/crack-seg.yaml +0 -0
  65. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/dota8.yaml +0 -0
  66. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/lvis.yaml +0 -0
  67. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/open-images-v7.yaml +0 -0
  68. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/package-seg.yaml +0 -0
  69. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/tiger-pose.yaml +0 -0
  70. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/datasets/xView.yaml +0 -0
  71. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/default.yaml +0 -0
  72. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/rt-detr/rtdetr-l.yaml +0 -0
  73. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/rt-detr/rtdetr-resnet101.yaml +0 -0
  74. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/rt-detr/rtdetr-resnet50.yaml +0 -0
  75. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/rt-detr/rtdetr-x.yaml +0 -0
  76. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v3/yolov3-spp.yaml +0 -0
  77. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v3/yolov3-tiny.yaml +0 -0
  78. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v3/yolov3.yaml +0 -0
  79. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v5/yolov5-p6.yaml +0 -0
  80. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v5/yolov5.yaml +0 -0
  81. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v6/yolov6.yaml +0 -0
  82. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-cls-resnet101.yaml +0 -0
  83. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-cls-resnet50.yaml +0 -0
  84. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-cls.yaml +0 -0
  85. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-ghost-p2.yaml +0 -0
  86. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-ghost-p6.yaml +0 -0
  87. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-ghost.yaml +0 -0
  88. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-obb.yaml +0 -0
  89. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-p2.yaml +0 -0
  90. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-p6.yaml +0 -0
  91. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-pose-p6.yaml +0 -0
  92. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-pose.yaml +0 -0
  93. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-rtdetr.yaml +0 -0
  94. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-seg-p6.yaml +0 -0
  95. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-seg.yaml +0 -0
  96. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-world.yaml +0 -0
  97. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8-worldv2.yaml +0 -0
  98. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/models/v8/yolov8.yaml +0 -0
  99. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/trackers/botsort.yaml +0 -0
  100. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/cfg/trackers/bytetrack.yaml +0 -0
  101. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/__init__.py +0 -0
  102. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/annotator.py +0 -0
  103. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/base.py +0 -0
  104. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/build.py +0 -0
  105. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/converter.py +0 -0
  106. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/explorer/__init__.py +0 -0
  107. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/explorer/gui/__init__.py +0 -0
  108. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/loaders.py +0 -0
  109. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/split_dota.py +0 -0
  110. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/data/utils.py +0 -0
  111. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/engine/__init__.py +0 -0
  112. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/engine/model.py +0 -0
  113. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/engine/predictor.py +0 -0
  114. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/engine/results.py +0 -0
  115. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/engine/tuner.py +0 -0
  116. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/engine/validator.py +0 -0
  117. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/hub/__init__.py +0 -0
  118. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/hub/auth.py +0 -0
  119. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/hub/session.py +0 -0
  120. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/hub/utils.py +0 -0
  121. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/__init__.py +0 -0
  122. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/fastsam/__init__.py +0 -0
  123. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/fastsam/model.py +0 -0
  124. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/fastsam/predict.py +0 -0
  125. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/fastsam/utils.py +0 -0
  126. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/fastsam/val.py +0 -0
  127. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/nas/__init__.py +0 -0
  128. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/nas/model.py +0 -0
  129. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/nas/predict.py +0 -0
  130. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/nas/val.py +0 -0
  131. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/rtdetr/__init__.py +0 -0
  132. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/rtdetr/model.py +0 -0
  133. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/rtdetr/predict.py +0 -0
  134. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/rtdetr/train.py +0 -0
  135. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/rtdetr/val.py +0 -0
  136. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/__init__.py +0 -0
  137. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/amg.py +0 -0
  138. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/build.py +0 -0
  139. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/model.py +0 -0
  140. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/modules/__init__.py +0 -0
  141. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/modules/decoders.py +0 -0
  142. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/modules/encoders.py +0 -0
  143. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/modules/sam.py +0 -0
  144. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/modules/tiny_encoder.py +0 -0
  145. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/sam/modules/transformer.py +0 -0
  146. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/utils/__init__.py +0 -0
  147. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/utils/loss.py +0 -0
  148. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/utils/ops.py +0 -0
  149. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/__init__.py +0 -0
  150. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/classify/__init__.py +0 -0
  151. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/classify/predict.py +0 -0
  152. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/classify/val.py +0 -0
  153. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/detect/__init__.py +0 -0
  154. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/detect/predict.py +0 -0
  155. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/detect/train.py +0 -0
  156. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/detect/val.py +0 -0
  157. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/model.py +0 -0
  158. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/obb/__init__.py +0 -0
  159. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/obb/predict.py +0 -0
  160. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/obb/train.py +0 -0
  161. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/obb/val.py +0 -0
  162. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/pose/__init__.py +0 -0
  163. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/pose/predict.py +0 -0
  164. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/pose/train.py +0 -0
  165. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/pose/val.py +0 -0
  166. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/segment/__init__.py +0 -0
  167. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/segment/predict.py +0 -0
  168. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/segment/train.py +0 -0
  169. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/segment/val.py +0 -0
  170. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/world/__init__.py +0 -0
  171. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/world/train.py +0 -0
  172. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/models/yolo/world/train_world.py +0 -0
  173. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/__init__.py +0 -0
  174. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/autobackend.py +0 -0
  175. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/modules/__init__.py +0 -0
  176. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/modules/block.py +0 -0
  177. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/modules/conv.py +0 -0
  178. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/modules/head.py +0 -0
  179. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/modules/transformer.py +0 -0
  180. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/modules/utils.py +0 -0
  181. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/nn/tasks.py +0 -0
  182. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/solutions/__init__.py +0 -0
  183. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/solutions/ai_gym.py +0 -0
  184. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/solutions/distance_calculation.py +0 -0
  185. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/solutions/speed_estimation.py +0 -0
  186. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/__init__.py +0 -0
  187. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/basetrack.py +0 -0
  188. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/bot_sort.py +0 -0
  189. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/byte_tracker.py +0 -0
  190. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/track.py +0 -0
  191. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/utils/__init__.py +0 -0
  192. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/utils/gmc.py +0 -0
  193. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/utils/kalman_filter.py +0 -0
  194. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/trackers/utils/matching.py +0 -0
  195. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/autobatch.py +0 -0
  196. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/__init__.py +0 -0
  197. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/base.py +0 -0
  198. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/comet.py +0 -0
  199. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/dvc.py +0 -0
  200. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/hub.py +0 -0
  201. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/mlflow.py +0 -0
  202. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/neptune.py +0 -0
  203. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/raytune.py +0 -0
  204. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/callbacks/tensorboard.py +0 -0
  205. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/dist.py +0 -0
  206. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/downloads.py +0 -0
  207. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/errors.py +0 -0
  208. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/files.py +0 -0
  209. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/instance.py +0 -0
  210. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/loss.py +0 -0
  211. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/patches.py +0 -0
  212. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/tal.py +0 -0
  213. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/triton.py +0 -0
  214. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics/utils/tuner.py +0 -0
  215. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics.egg-info/dependency_links.txt +0 -0
  216. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics.egg-info/entry_points.txt +0 -0
  217. {ultralytics-8.1.41 → ultralytics-8.1.43}/ultralytics.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: ultralytics
3
- Version: 8.1.41
3
+ Version: 8.1.43
4
4
  Summary: Ultralytics YOLOv8 for SOTA object detection, multi-object tracking, instance segmentation, pose estimation and image classification.
5
5
  Author: Glenn Jocher, Ayush Chaurasia, Jing Qiu
6
6
  Maintainer: Glenn Jocher, Ayush Chaurasia, Jing Qiu
@@ -62,6 +62,7 @@ Requires-Dist: coremltools>=7.0; (platform_system != "Windows" and python_versio
62
62
  Requires-Dist: openvino>=2024.0.0; extra == "export"
63
63
  Requires-Dist: tensorflow<=2.13.1; python_version <= "3.11" and extra == "export"
64
64
  Requires-Dist: tensorflowjs>=3.9.0; python_version <= "3.11" and extra == "export"
65
+ Requires-Dist: numpy==1.23.5; platform_machine == "aarch64" and extra == "export"
65
66
  Provides-Extra: explorer
66
67
  Requires-Dist: lancedb; extra == "explorer"
67
68
  Requires-Dist: duckdb<=0.9.2; extra == "explorer"
@@ -101,6 +101,7 @@ export = [
101
101
  "openvino>=2024.0.0", # OpenVINO export
102
102
  "tensorflow<=2.13.1; python_version <= '3.11'", # TF bug https://github.com/ultralytics/ultralytics/issues/5161
103
103
  "tensorflowjs>=3.9.0; python_version <= '3.11'", # TF.js export, automatically installs tensorflow
104
+ "numpy==1.23.5; platform_machine == 'aarch64'", # Fix error: `np.bool` was a deprecated alias for the builtin `bool` when using TensorRT models on NVIDIA Jetson
104
105
  ]
105
106
  explorer = [
106
107
  "lancedb", # vector search
@@ -10,7 +10,6 @@ import pytest
10
10
  import torch
11
11
  import yaml
12
12
  from PIL import Image
13
- from torchvision.transforms import ToTensor
14
13
 
15
14
  from ultralytics import RTDETR, YOLO
16
15
  from ultralytics.cfg import TASK2DATA
@@ -108,20 +107,17 @@ def test_predict_img():
108
107
  assert len(model(batch, imgsz=32)) == len(batch) # multiple sources in a batch
109
108
 
110
109
  # Test tensor inference
111
- im = cv2.imread(str(SOURCE)) # OpenCV
112
- t = cv2.resize(im, (32, 32))
113
- t = ToTensor()(t)
114
- t = torch.stack([t, t, t, t])
115
- results = model(t, imgsz=32)
116
- assert len(results) == t.shape[0]
117
- results = seg_model(t, imgsz=32)
118
- assert len(results) == t.shape[0]
119
- results = cls_model(t, imgsz=32)
120
- assert len(results) == t.shape[0]
121
- results = pose_model(t, imgsz=32)
122
- assert len(results) == t.shape[0]
123
- results = obb_model(t, imgsz=32)
124
- assert len(results) == t.shape[0]
110
+ im = torch.rand((4, 3, 32, 32)) # batch-size 4, FP32 0.0-1.0 RGB order
111
+ results = model(im, imgsz=32)
112
+ assert len(results) == im.shape[0]
113
+ results = seg_model(im, imgsz=32)
114
+ assert len(results) == im.shape[0]
115
+ results = cls_model(im, imgsz=32)
116
+ assert len(results) == im.shape[0]
117
+ results = pose_model(im, imgsz=32)
118
+ assert len(results) == im.shape[0]
119
+ results = obb_model(im, imgsz=32)
120
+ assert len(results) == im.shape[0]
125
121
 
126
122
 
127
123
  def test_predict_grey_and_4ch():
@@ -592,8 +588,6 @@ def image():
592
588
  )
593
589
  def test_classify_transforms_train(image, auto_augment, erasing, force_color_jitter):
594
590
  """Tests classification transforms during training with various augmentation settings."""
595
- import torchvision.transforms as T
596
-
597
591
  from ultralytics.data.augment import classify_augmentations
598
592
 
599
593
  transform = classify_augmentations(
@@ -610,7 +604,6 @@ def test_classify_transforms_train(image, auto_augment, erasing, force_color_jit
610
604
  hsv_v=0.4,
611
605
  force_color_jitter=force_color_jitter,
612
606
  erasing=erasing,
613
- interpolation=T.InterpolationMode.BILINEAR,
614
607
  )
615
608
 
616
609
  transformed_image = transform(Image.fromarray(cv2.cvtColor(image, cv2.COLOR_BGR2RGB)))
@@ -1,6 +1,6 @@
1
1
  # Ultralytics YOLO 🚀, AGPL-3.0 license
2
2
 
3
- __version__ = "8.1.41"
3
+ __version__ = "8.1.43"
4
4
 
5
5
  from ultralytics.data.explorer.explorer import Explorer
6
6
  from ultralytics.models import RTDETR, SAM, YOLO, YOLOWorld
@@ -0,0 +1,38 @@
1
+ # Ultralytics YOLO 🚀, AGPL-3.0 license
2
+ # YOLOv9c-seg
3
+ # 654 layers, 27897120 parameters, 159.4 GFLOPs
4
+
5
+ # parameters
6
+ nc: 80 # number of classes
7
+
8
+ # gelan backbone
9
+ backbone:
10
+ - [-1, 1, Conv, [64, 3, 2]] # 0-P1/2
11
+ - [-1, 1, Conv, [128, 3, 2]] # 1-P2/4
12
+ - [-1, 1, RepNCSPELAN4, [256, 128, 64, 1]] # 2
13
+ - [-1, 1, ADown, [256]] # 3-P3/8
14
+ - [-1, 1, RepNCSPELAN4, [512, 256, 128, 1]] # 4
15
+ - [-1, 1, ADown, [512]] # 5-P4/16
16
+ - [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 6
17
+ - [-1, 1, ADown, [512]] # 7-P5/32
18
+ - [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 8
19
+ - [-1, 1, SPPELAN, [512, 256]] # 9
20
+
21
+ head:
22
+ - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
23
+ - [[-1, 6], 1, Concat, [1]] # cat backbone P4
24
+ - [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 12
25
+
26
+ - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
27
+ - [[-1, 4], 1, Concat, [1]] # cat backbone P3
28
+ - [-1, 1, RepNCSPELAN4, [256, 256, 128, 1]] # 15 (P3/8-small)
29
+
30
+ - [-1, 1, ADown, [256]]
31
+ - [[-1, 12], 1, Concat, [1]] # cat head P4
32
+ - [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 18 (P4/16-medium)
33
+
34
+ - [-1, 1, ADown, [512]]
35
+ - [[-1, 9], 1, Concat, [1]] # cat head P5
36
+ - [-1, 1, RepNCSPELAN4, [512, 512, 256, 1]] # 21 (P5/32-large)
37
+
38
+ - [[15, 18, 21], 1, Segment, [nc, 32, 256]] # Segment(P3, P4, P5)
@@ -1,4 +1,6 @@
1
- # YOLOv9
1
+ # Ultralytics YOLO 🚀, AGPL-3.0 license
2
+ # YOLOv9c
3
+ # 618 layers, 25590912 parameters, 104.0 GFLOPs
2
4
 
3
5
  # parameters
4
6
  nc: 80 # number of classes
@@ -0,0 +1,62 @@
1
+ # Ultralytics YOLO 🚀, AGPL-3.0 license
2
+ # YOLOv9c-seg
3
+ # 1261 layers, 60512800 parameters, 248.4 GFLOPs
4
+
5
+ # parameters
6
+ nc: 80 # number of classes
7
+
8
+ # gelan backbone
9
+ backbone:
10
+ - [-1, 1, Silence, []]
11
+ - [-1, 1, Conv, [64, 3, 2]] # 1-P1/2
12
+ - [-1, 1, Conv, [128, 3, 2]] # 2-P2/4
13
+ - [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]] # 3
14
+ - [-1, 1, ADown, [256]] # 4-P3/8
15
+ - [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]] # 5
16
+ - [-1, 1, ADown, [512]] # 6-P4/16
17
+ - [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 7
18
+ - [-1, 1, ADown, [1024]] # 8-P5/32
19
+ - [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 9
20
+
21
+ - [1, 1, CBLinear, [[64]]] # 10
22
+ - [3, 1, CBLinear, [[64, 128]]] # 11
23
+ - [5, 1, CBLinear, [[64, 128, 256]]] # 12
24
+ - [7, 1, CBLinear, [[64, 128, 256, 512]]] # 13
25
+ - [9, 1, CBLinear, [[64, 128, 256, 512, 1024]]] # 14
26
+
27
+ - [0, 1, Conv, [64, 3, 2]] # 15-P1/2
28
+ - [[10, 11, 12, 13, 14, -1], 1, CBFuse, [[0, 0, 0, 0, 0]]] # 16
29
+ - [-1, 1, Conv, [128, 3, 2]] # 17-P2/4
30
+ - [[11, 12, 13, 14, -1], 1, CBFuse, [[1, 1, 1, 1]]] # 18
31
+ - [-1, 1, RepNCSPELAN4, [256, 128, 64, 2]] # 19
32
+ - [-1, 1, ADown, [256]] # 20-P3/8
33
+ - [[12, 13, 14, -1], 1, CBFuse, [[2, 2, 2]]] # 21
34
+ - [-1, 1, RepNCSPELAN4, [512, 256, 128, 2]] # 22
35
+ - [-1, 1, ADown, [512]] # 23-P4/16
36
+ - [[13, 14, -1], 1, CBFuse, [[3, 3]]] # 24
37
+ - [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 25
38
+ - [-1, 1, ADown, [1024]] # 26-P5/32
39
+ - [[14, -1], 1, CBFuse, [[4]]] # 27
40
+ - [-1, 1, RepNCSPELAN4, [1024, 512, 256, 2]] # 28
41
+ - [-1, 1, SPPELAN, [512, 256]] # 29
42
+
43
+ # gelan head
44
+ head:
45
+ - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
46
+ - [[-1, 25], 1, Concat, [1]] # cat backbone P4
47
+ - [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]] # 32
48
+
49
+ - [-1, 1, nn.Upsample, [None, 2, 'nearest']]
50
+ - [[-1, 22], 1, Concat, [1]] # cat backbone P3
51
+ - [-1, 1, RepNCSPELAN4, [256, 256, 128, 2]] # 35 (P3/8-small)
52
+
53
+ - [-1, 1, ADown, [256]]
54
+ - [[-1, 32], 1, Concat, [1]] # cat head P4
55
+ - [-1, 1, RepNCSPELAN4, [512, 512, 256, 2]] # 38 (P4/16-medium)
56
+
57
+ - [-1, 1, ADown, [512]]
58
+ - [[-1, 29], 1, Concat, [1]] # cat head P5
59
+ - [-1, 1, RepNCSPELAN4, [512, 1024, 512, 2]] # 41 (P5/32-large)
60
+
61
+ # segment
62
+ - [[35, 38, 41], 1, Segment, [nc, 32, 256]] # Segment (P3, P4, P5)
@@ -1,4 +1,6 @@
1
- # YOLOv9
1
+ # Ultralytics YOLO 🚀, AGPL-3.0 license
2
+ # YOLOv9e
3
+ # 1225 layers, 58206592 parameters, 193.0 GFLOPs
2
4
 
3
5
  # parameters
4
6
  nc: 80 # number of classes
@@ -8,7 +8,7 @@ from typing import Tuple, Union
8
8
  import cv2
9
9
  import numpy as np
10
10
  import torch
11
- import torchvision.transforms as T
11
+ from PIL import Image
12
12
 
13
13
  from ultralytics.utils import LOGGER, colorstr
14
14
  from ultralytics.utils.checks import check_version
@@ -167,8 +167,8 @@ class BaseMixTransform:
167
167
  text2id = {text: i for i, text in enumerate(mix_texts)}
168
168
 
169
169
  for label in [labels] + labels["mix_labels"]:
170
- for i, l in enumerate(label["cls"].squeeze(-1).tolist()):
171
- text = label["texts"][int(l)]
170
+ for i, cls in enumerate(label["cls"].squeeze(-1).tolist()):
171
+ text = label["texts"][int(cls)]
172
172
  label["cls"][i] = text2id[tuple(text)]
173
173
  label["texts"] = mix_texts
174
174
  return labels
@@ -1133,7 +1133,7 @@ def classify_transforms(
1133
1133
  size=224,
1134
1134
  mean=DEFAULT_MEAN,
1135
1135
  std=DEFAULT_STD,
1136
- interpolation: T.InterpolationMode = T.InterpolationMode.BILINEAR,
1136
+ interpolation=Image.BILINEAR,
1137
1137
  crop_fraction: float = DEFAULT_CROP_FTACTION,
1138
1138
  ):
1139
1139
  """
@@ -1149,6 +1149,7 @@ def classify_transforms(
1149
1149
  Returns:
1150
1150
  (T.Compose): torchvision transforms
1151
1151
  """
1152
+ import torchvision.transforms as T # scope for faster 'import ultralytics'
1152
1153
 
1153
1154
  if isinstance(size, (tuple, list)):
1154
1155
  assert len(size) == 2
@@ -1157,12 +1158,12 @@ def classify_transforms(
1157
1158
  scale_size = math.floor(size / crop_fraction)
1158
1159
  scale_size = (scale_size, scale_size)
1159
1160
 
1160
- # aspect ratio is preserved, crops center within image, no borders are added, image is lost
1161
+ # Aspect ratio is preserved, crops center within image, no borders are added, image is lost
1161
1162
  if scale_size[0] == scale_size[1]:
1162
- # simple case, use torchvision built-in Resize w/ shortest edge mode (scalar size arg)
1163
+ # Simple case, use torchvision built-in Resize with the shortest edge mode (scalar size arg)
1163
1164
  tfl = [T.Resize(scale_size[0], interpolation=interpolation)]
1164
1165
  else:
1165
- # resize shortest edge to matching target dim for non-square target
1166
+ # Resize the shortest edge to matching target dim for non-square target
1166
1167
  tfl = [T.Resize(scale_size)]
1167
1168
  tfl += [T.CenterCrop(size)]
1168
1169
 
@@ -1192,7 +1193,7 @@ def classify_augmentations(
1192
1193
  hsv_v=0.4, # image HSV-Value augmentation (fraction)
1193
1194
  force_color_jitter=False,
1194
1195
  erasing=0.0,
1195
- interpolation: T.InterpolationMode = T.InterpolationMode.BILINEAR,
1196
+ interpolation=Image.BILINEAR,
1196
1197
  ):
1197
1198
  """
1198
1199
  Classification transforms with augmentation for training. Inspired by timm/data/transforms_factory.py.
@@ -1216,7 +1217,9 @@ def classify_augmentations(
1216
1217
  Returns:
1217
1218
  (T.Compose): torchvision transforms
1218
1219
  """
1219
- # Transforms to apply if albumentations not installed
1220
+ # Transforms to apply if Albumentations not installed
1221
+ import torchvision.transforms as T # scope for faster 'import ultralytics'
1222
+
1220
1223
  if not isinstance(size, int):
1221
1224
  raise TypeError(f"classify_transforms() size {size} must be integer, not (list, tuple)")
1222
1225
  scale = tuple(scale or (0.08, 1.0)) # default imagenet scale range
@@ -1,18 +1,17 @@
1
1
  # Ultralytics YOLO 🚀, AGPL-3.0 license
2
2
  import contextlib
3
- from itertools import repeat
3
+ import json
4
4
  from collections import defaultdict
5
+ from itertools import repeat
5
6
  from multiprocessing.pool import ThreadPool
6
7
  from pathlib import Path
7
8
 
8
9
  import cv2
9
- import json
10
10
  import numpy as np
11
11
  import torch
12
- import torchvision
13
12
  from PIL import Image
14
-
15
13
  from torch.utils.data import ConcatDataset
14
+
16
15
  from ultralytics.utils import LOCAL_RANK, NUM_THREADS, TQDM, colorstr
17
16
  from ultralytics.utils.ops import resample_segments
18
17
  from .augment import (
@@ -103,16 +102,16 @@ class YOLODataset(BaseDataset):
103
102
  nc += nc_f
104
103
  if im_file:
105
104
  x["labels"].append(
106
- dict(
107
- im_file=im_file,
108
- shape=shape,
109
- cls=lb[:, 0:1], # n, 1
110
- bboxes=lb[:, 1:], # n, 4
111
- segments=segments,
112
- keypoints=keypoint,
113
- normalized=True,
114
- bbox_format="xywh",
115
- )
105
+ {
106
+ "im_file": im_file,
107
+ "shape": shape,
108
+ "cls": lb[:, 0:1], # n, 1
109
+ "bboxes": lb[:, 1:], # n, 4
110
+ "segments": segments,
111
+ "keypoints": keypoint,
112
+ "normalized": True,
113
+ "bbox_format": "xywh",
114
+ }
116
115
  )
117
116
  if msg:
118
117
  msgs.append(msg)
@@ -245,125 +244,6 @@ class YOLODataset(BaseDataset):
245
244
  return new_batch
246
245
 
247
246
 
248
- # Classification dataloaders -------------------------------------------------------------------------------------------
249
- class ClassificationDataset(torchvision.datasets.ImageFolder):
250
- """
251
- Extends torchvision ImageFolder to support YOLO classification tasks, offering functionalities like image
252
- augmentation, caching, and verification. It's designed to efficiently handle large datasets for training deep
253
- learning models, with optional image transformations and caching mechanisms to speed up training.
254
-
255
- This class allows for augmentations using both torchvision and Albumentations libraries, and supports caching images
256
- in RAM or on disk to reduce IO overhead during training. Additionally, it implements a robust verification process
257
- to ensure data integrity and consistency.
258
-
259
- Attributes:
260
- cache_ram (bool): Indicates if caching in RAM is enabled.
261
- cache_disk (bool): Indicates if caching on disk is enabled.
262
- samples (list): A list of tuples, each containing the path to an image, its class index, path to its .npy cache
263
- file (if caching on disk), and optionally the loaded image array (if caching in RAM).
264
- torch_transforms (callable): PyTorch transforms to be applied to the images.
265
- """
266
-
267
- def __init__(self, root, args, augment=False, prefix=""):
268
- """
269
- Initialize YOLO object with root, image size, augmentations, and cache settings.
270
-
271
- Args:
272
- root (str): Path to the dataset directory where images are stored in a class-specific folder structure.
273
- args (Namespace): Configuration containing dataset-related settings such as image size, augmentation
274
- parameters, and cache settings. It includes attributes like `imgsz` (image size), `fraction` (fraction
275
- of data to use), `scale`, `fliplr`, `flipud`, `cache` (disk or RAM caching for faster training),
276
- `auto_augment`, `hsv_h`, `hsv_s`, `hsv_v`, and `crop_fraction`.
277
- augment (bool, optional): Whether to apply augmentations to the dataset. Default is False.
278
- prefix (str, optional): Prefix for logging and cache filenames, aiding in dataset identification and
279
- debugging. Default is an empty string.
280
- """
281
- super().__init__(root=root)
282
- if augment and args.fraction < 1.0: # reduce training fraction
283
- self.samples = self.samples[: round(len(self.samples) * args.fraction)]
284
- self.prefix = colorstr(f"{prefix}: ") if prefix else ""
285
- self.cache_ram = args.cache is True or str(args.cache).lower() == "ram" # cache images into RAM
286
- self.cache_disk = str(args.cache).lower() == "disk" # cache images on hard drive as uncompressed *.npy files
287
- self.samples = self.verify_images() # filter out bad images
288
- self.samples = [list(x) + [Path(x[0]).with_suffix(".npy"), None] for x in self.samples] # file, index, npy, im
289
- scale = (1.0 - args.scale, 1.0) # (0.08, 1.0)
290
- self.torch_transforms = (
291
- classify_augmentations(
292
- size=args.imgsz,
293
- scale=scale,
294
- hflip=args.fliplr,
295
- vflip=args.flipud,
296
- erasing=args.erasing,
297
- auto_augment=args.auto_augment,
298
- hsv_h=args.hsv_h,
299
- hsv_s=args.hsv_s,
300
- hsv_v=args.hsv_v,
301
- )
302
- if augment
303
- else classify_transforms(size=args.imgsz, crop_fraction=args.crop_fraction)
304
- )
305
-
306
- def __getitem__(self, i):
307
- """Returns subset of data and targets corresponding to given indices."""
308
- f, j, fn, im = self.samples[i] # filename, index, filename.with_suffix('.npy'), image
309
- if self.cache_ram:
310
- if im is None: # Warning: two separate if statements required here, do not combine this with previous line
311
- im = self.samples[i][3] = cv2.imread(f)
312
- elif self.cache_disk:
313
- if not fn.exists(): # load npy
314
- np.save(fn.as_posix(), cv2.imread(f), allow_pickle=False)
315
- im = np.load(fn)
316
- else: # read image
317
- im = cv2.imread(f) # BGR
318
- # Convert NumPy array to PIL image
319
- im = Image.fromarray(cv2.cvtColor(im, cv2.COLOR_BGR2RGB))
320
- sample = self.torch_transforms(im)
321
- return {"img": sample, "cls": j}
322
-
323
- def __len__(self) -> int:
324
- """Return the total number of samples in the dataset."""
325
- return len(self.samples)
326
-
327
- def verify_images(self):
328
- """Verify all images in dataset."""
329
- desc = f"{self.prefix}Scanning {self.root}..."
330
- path = Path(self.root).with_suffix(".cache") # *.cache file path
331
-
332
- with contextlib.suppress(FileNotFoundError, AssertionError, AttributeError):
333
- cache = load_dataset_cache_file(path) # attempt to load a *.cache file
334
- assert cache["version"] == DATASET_CACHE_VERSION # matches current version
335
- assert cache["hash"] == get_hash([x[0] for x in self.samples]) # identical hash
336
- nf, nc, n, samples = cache.pop("results") # found, missing, empty, corrupt, total
337
- if LOCAL_RANK in {-1, 0}:
338
- d = f"{desc} {nf} images, {nc} corrupt"
339
- TQDM(None, desc=d, total=n, initial=n)
340
- if cache["msgs"]:
341
- LOGGER.info("\n".join(cache["msgs"])) # display warnings
342
- return samples
343
-
344
- # Run scan if *.cache retrieval failed
345
- nf, nc, msgs, samples, x = 0, 0, [], [], {}
346
- with ThreadPool(NUM_THREADS) as pool:
347
- results = pool.imap(func=verify_image, iterable=zip(self.samples, repeat(self.prefix)))
348
- pbar = TQDM(results, desc=desc, total=len(self.samples))
349
- for sample, nf_f, nc_f, msg in pbar:
350
- if nf_f:
351
- samples.append(sample)
352
- if msg:
353
- msgs.append(msg)
354
- nf += nf_f
355
- nc += nc_f
356
- pbar.desc = f"{desc} {nf} images, {nc} corrupt"
357
- pbar.close()
358
- if msgs:
359
- LOGGER.info("\n".join(msgs))
360
- x["hash"] = get_hash([x[0] for x in self.samples])
361
- x["results"] = nf, nc, len(samples), samples
362
- x["msgs"] = msgs # warnings
363
- save_dataset_cache_file(self.prefix, path, x, DATASET_CACHE_VERSION)
364
- return samples
365
-
366
-
367
247
  class YOLOMultiModalDataset(YOLODataset):
368
248
  """
369
249
  Dataset class for loading object detection and/or segmentation labels in YOLO format.
@@ -447,15 +327,15 @@ class GroundingDataset(YOLODataset):
447
327
  bboxes.append(box)
448
328
  lb = np.array(bboxes, dtype=np.float32) if len(bboxes) else np.zeros((0, 5), dtype=np.float32)
449
329
  labels.append(
450
- dict(
451
- im_file=im_file,
452
- shape=(h, w),
453
- cls=lb[:, 0:1], # n, 1
454
- bboxes=lb[:, 1:], # n, 4
455
- normalized=True,
456
- bbox_format="xywh",
457
- texts=texts,
458
- )
330
+ {
331
+ "im_file": im_file,
332
+ "shape": (h, w),
333
+ "cls": lb[:, 0:1], # n, 1
334
+ "bboxes": lb[:, 1:], # n, 4
335
+ "normalized": True,
336
+ "bbox_format": "xywh",
337
+ "texts": texts,
338
+ }
459
339
  )
460
340
  return labels
461
341
 
@@ -497,3 +377,128 @@ class SemanticDataset(BaseDataset):
497
377
  def __init__(self):
498
378
  """Initialize a SemanticDataset object."""
499
379
  super().__init__()
380
+
381
+
382
+ class ClassificationDataset:
383
+ """
384
+ Extends torchvision ImageFolder to support YOLO classification tasks, offering functionalities like image
385
+ augmentation, caching, and verification. It's designed to efficiently handle large datasets for training deep
386
+ learning models, with optional image transformations and caching mechanisms to speed up training.
387
+
388
+ This class allows for augmentations using both torchvision and Albumentations libraries, and supports caching images
389
+ in RAM or on disk to reduce IO overhead during training. Additionally, it implements a robust verification process
390
+ to ensure data integrity and consistency.
391
+
392
+ Attributes:
393
+ cache_ram (bool): Indicates if caching in RAM is enabled.
394
+ cache_disk (bool): Indicates if caching on disk is enabled.
395
+ samples (list): A list of tuples, each containing the path to an image, its class index, path to its .npy cache
396
+ file (if caching on disk), and optionally the loaded image array (if caching in RAM).
397
+ torch_transforms (callable): PyTorch transforms to be applied to the images.
398
+ """
399
+
400
+ def __init__(self, root, args, augment=False, prefix=""):
401
+ """
402
+ Initialize YOLO object with root, image size, augmentations, and cache settings.
403
+
404
+ Args:
405
+ root (str): Path to the dataset directory where images are stored in a class-specific folder structure.
406
+ args (Namespace): Configuration containing dataset-related settings such as image size, augmentation
407
+ parameters, and cache settings. It includes attributes like `imgsz` (image size), `fraction` (fraction
408
+ of data to use), `scale`, `fliplr`, `flipud`, `cache` (disk or RAM caching for faster training),
409
+ `auto_augment`, `hsv_h`, `hsv_s`, `hsv_v`, and `crop_fraction`.
410
+ augment (bool, optional): Whether to apply augmentations to the dataset. Default is False.
411
+ prefix (str, optional): Prefix for logging and cache filenames, aiding in dataset identification and
412
+ debugging. Default is an empty string.
413
+ """
414
+ import torchvision # scope for faster 'import ultralytics'
415
+
416
+ # Base class assigned as attribute rather than used as base class to allow for scoping slow torchvision import
417
+ self.base = torchvision.datasets.ImageFolder(root=root)
418
+ self.samples = self.base.samples
419
+ self.root = self.base.root
420
+
421
+ # Initialize attributes
422
+ if augment and args.fraction < 1.0: # reduce training fraction
423
+ self.samples = self.samples[: round(len(self.samples) * args.fraction)]
424
+ self.prefix = colorstr(f"{prefix}: ") if prefix else ""
425
+ self.cache_ram = args.cache is True or str(args.cache).lower() == "ram" # cache images into RAM
426
+ self.cache_disk = str(args.cache).lower() == "disk" # cache images on hard drive as uncompressed *.npy files
427
+ self.samples = self.verify_images() # filter out bad images
428
+ self.samples = [list(x) + [Path(x[0]).with_suffix(".npy"), None] for x in self.samples] # file, index, npy, im
429
+ scale = (1.0 - args.scale, 1.0) # (0.08, 1.0)
430
+ self.torch_transforms = (
431
+ classify_augmentations(
432
+ size=args.imgsz,
433
+ scale=scale,
434
+ hflip=args.fliplr,
435
+ vflip=args.flipud,
436
+ erasing=args.erasing,
437
+ auto_augment=args.auto_augment,
438
+ hsv_h=args.hsv_h,
439
+ hsv_s=args.hsv_s,
440
+ hsv_v=args.hsv_v,
441
+ )
442
+ if augment
443
+ else classify_transforms(size=args.imgsz, crop_fraction=args.crop_fraction)
444
+ )
445
+
446
+ def __getitem__(self, i):
447
+ """Returns subset of data and targets corresponding to given indices."""
448
+ f, j, fn, im = self.samples[i] # filename, index, filename.with_suffix('.npy'), image
449
+ if self.cache_ram:
450
+ if im is None: # Warning: two separate if statements required here, do not combine this with previous line
451
+ im = self.samples[i][3] = cv2.imread(f)
452
+ elif self.cache_disk:
453
+ if not fn.exists(): # load npy
454
+ np.save(fn.as_posix(), cv2.imread(f), allow_pickle=False)
455
+ im = np.load(fn)
456
+ else: # read image
457
+ im = cv2.imread(f) # BGR
458
+ # Convert NumPy array to PIL image
459
+ im = Image.fromarray(cv2.cvtColor(im, cv2.COLOR_BGR2RGB))
460
+ sample = self.torch_transforms(im)
461
+ return {"img": sample, "cls": j}
462
+
463
+ def __len__(self) -> int:
464
+ """Return the total number of samples in the dataset."""
465
+ return len(self.samples)
466
+
467
+ def verify_images(self):
468
+ """Verify all images in dataset."""
469
+ desc = f"{self.prefix}Scanning {self.root}..."
470
+ path = Path(self.root).with_suffix(".cache") # *.cache file path
471
+
472
+ with contextlib.suppress(FileNotFoundError, AssertionError, AttributeError):
473
+ cache = load_dataset_cache_file(path) # attempt to load a *.cache file
474
+ assert cache["version"] == DATASET_CACHE_VERSION # matches current version
475
+ assert cache["hash"] == get_hash([x[0] for x in self.samples]) # identical hash
476
+ nf, nc, n, samples = cache.pop("results") # found, missing, empty, corrupt, total
477
+ if LOCAL_RANK in {-1, 0}:
478
+ d = f"{desc} {nf} images, {nc} corrupt"
479
+ TQDM(None, desc=d, total=n, initial=n)
480
+ if cache["msgs"]:
481
+ LOGGER.info("\n".join(cache["msgs"])) # display warnings
482
+ return samples
483
+
484
+ # Run scan if *.cache retrieval failed
485
+ nf, nc, msgs, samples, x = 0, 0, [], [], {}
486
+ with ThreadPool(NUM_THREADS) as pool:
487
+ results = pool.imap(func=verify_image, iterable=zip(self.samples, repeat(self.prefix)))
488
+ pbar = TQDM(results, desc=desc, total=len(self.samples))
489
+ for sample, nf_f, nc_f, msg in pbar:
490
+ if nf_f:
491
+ samples.append(sample)
492
+ if msg:
493
+ msgs.append(msg)
494
+ nf += nf_f
495
+ nc += nc_f
496
+ pbar.desc = f"{desc} {nf} images, {nc} corrupt"
497
+ pbar.close()
498
+ if msgs:
499
+ LOGGER.info("\n".join(msgs))
500
+ x["hash"] = get_hash([x[0] for x in self.samples])
501
+ x["results"] = nf, nc, len(samples), samples
502
+ x["msgs"] = msgs # warnings
503
+ save_dataset_cache_file(self.prefix, path, x, DATASET_CACHE_VERSION)
504
+ return samples
@@ -9,7 +9,6 @@ import numpy as np
9
9
  import torch
10
10
  from PIL import Image
11
11
  from matplotlib import pyplot as plt
12
- from pandas import DataFrame
13
12
  from tqdm import tqdm
14
13
 
15
14
  from ultralytics.data.augment import Format
@@ -172,7 +171,7 @@ class Explorer:
172
171
 
173
172
  def sql_query(
174
173
  self, query: str, return_type: str = "pandas"
175
- ) -> Union[DataFrame, Any, None]: # pandas.dataframe or pyarrow.Table
174
+ ) -> Union[Any, None]: # pandas.DataFrame or pyarrow.Table
176
175
  """
177
176
  Run a SQL-Like query on the table. Utilizes LanceDB predicate pushdown.
178
177
 
@@ -247,7 +246,7 @@ class Explorer:
247
246
  idx: Union[int, List[int]] = None,
248
247
  limit: int = 25,
249
248
  return_type: str = "pandas",
250
- ) -> Union[DataFrame, Any]: # pandas.dataframe or pyarrow.Table
249
+ ) -> Any: # pandas.DataFrame or pyarrow.Table
251
250
  """
252
251
  Query the table for similar images. Accepts a single image or a list of images.
253
252
 
@@ -312,7 +311,7 @@ class Explorer:
312
311
  img = plot_query_result(similar, plot_labels=labels)
313
312
  return Image.fromarray(img)
314
313
 
315
- def similarity_index(self, max_dist: float = 0.2, top_k: float = None, force: bool = False) -> DataFrame:
314
+ def similarity_index(self, max_dist: float = 0.2, top_k: float = None, force: bool = False) -> Any: # pd.DataFrame
316
315
  """
317
316
  Calculate the similarity index of all the images in the table. Here, the index will contain the data points that
318
317
  are max_dist or closer to the image in the embedding space at a given index.
@@ -447,12 +446,11 @@ class Explorer:
447
446
  """
448
447
  result = prompt_sql_query(query)
449
448
  try:
450
- df = self.sql_query(result)
449
+ return self.sql_query(result)
451
450
  except Exception as e:
452
451
  LOGGER.error("AI generated query is not valid. Please try again with a different prompt")
453
452
  LOGGER.error(e)
454
453
  return None
455
- return df
456
454
 
457
455
  def visualize(self, result):
458
456
  """