dnt 0.2.1__py3-none-any.whl → 0.3.1.8__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (315) hide show
  1. dnt/__init__.py +4 -1
  2. dnt/analysis/__init__.py +3 -1
  3. dnt/analysis/count.py +107 -0
  4. dnt/analysis/interaction2.py +518 -0
  5. dnt/analysis/position.py +12 -0
  6. dnt/analysis/stop.py +92 -33
  7. dnt/analysis/stop2.py +289 -0
  8. dnt/analysis/stop3.py +758 -0
  9. dnt/detect/__init__.py +1 -1
  10. dnt/detect/signal/detector.py +326 -0
  11. dnt/detect/timestamp.py +105 -0
  12. dnt/detect/yolov8/detector.py +182 -35
  13. dnt/detect/yolov8/segmentor.py +171 -0
  14. dnt/engine/__init__.py +8 -0
  15. dnt/engine/bbox_interp.py +83 -0
  16. dnt/engine/bbox_iou.py +20 -0
  17. dnt/engine/cluster.py +31 -0
  18. dnt/engine/iob.py +66 -0
  19. dnt/filter/__init__.py +4 -0
  20. dnt/filter/filter.py +450 -21
  21. dnt/label/__init__.py +1 -1
  22. dnt/label/labeler.py +215 -14
  23. dnt/label/labeler2.py +631 -0
  24. dnt/shared/__init__.py +2 -1
  25. dnt/shared/data/coco.names +0 -0
  26. dnt/shared/data/openimages.names +0 -0
  27. dnt/shared/data/voc.names +0 -0
  28. dnt/shared/download.py +12 -0
  29. dnt/shared/synhcro.py +150 -0
  30. dnt/shared/util.py +17 -4
  31. dnt/third_party/fast-reid/__init__.py +1 -0
  32. dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
  33. dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
  34. dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
  35. dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
  36. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
  37. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
  38. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
  39. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
  40. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
  41. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
  42. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
  43. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
  44. dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
  45. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
  46. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
  47. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
  48. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
  49. dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
  50. dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
  51. dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
  52. dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
  53. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
  54. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
  55. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
  56. dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
  57. dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
  58. dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
  59. dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
  60. dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
  61. dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
  62. dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
  63. dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
  64. dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
  65. dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
  66. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
  67. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
  68. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
  69. dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
  70. dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
  71. dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
  72. dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
  73. dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
  74. dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
  75. dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
  76. dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
  77. dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
  78. dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
  79. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
  80. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
  81. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
  82. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
  83. dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
  84. dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
  85. dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
  86. dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
  87. dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
  88. dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
  89. dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
  90. dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
  91. dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
  92. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
  93. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
  94. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
  95. dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
  96. dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
  97. dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
  98. dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
  99. dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
  100. dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
  101. dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
  102. dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
  103. dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
  104. dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
  105. dnt/third_party/fast-reid/configs/__init__.py +0 -0
  106. dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
  107. dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
  108. dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
  109. dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
  110. dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
  111. dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
  112. dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
  113. dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
  114. dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
  115. dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
  116. dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
  117. dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
  118. dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
  119. dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
  120. dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
  121. dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
  122. dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
  123. dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
  124. dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
  125. dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
  126. dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
  127. dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
  128. dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
  129. dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
  130. dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
  131. dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
  132. dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
  133. dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
  134. dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
  135. dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
  136. dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
  137. dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
  138. dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
  139. dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
  140. dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
  141. dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
  142. dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
  143. dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
  144. dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
  145. dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
  146. dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
  147. dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
  148. dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
  149. dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
  150. dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
  151. dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
  152. dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
  153. dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
  154. dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
  155. dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
  156. dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
  157. dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
  158. dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
  159. dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
  160. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
  161. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
  162. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
  163. dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
  164. dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
  165. dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
  166. dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
  167. dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
  168. dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
  169. dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
  170. dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
  171. dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
  172. dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
  173. dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
  174. dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
  175. dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
  176. dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
  177. dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
  178. dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
  179. dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
  180. dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
  181. dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
  182. dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
  183. dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
  184. dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
  185. dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
  186. dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
  187. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
  188. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
  189. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
  190. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
  191. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
  192. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
  193. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
  194. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
  195. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
  196. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
  197. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
  198. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
  199. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
  200. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
  201. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
  202. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
  203. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
  204. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
  205. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
  206. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
  207. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
  208. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
  209. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
  210. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
  211. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
  212. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
  213. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
  214. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
  215. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
  216. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
  217. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
  218. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
  219. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
  220. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
  221. dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
  222. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
  223. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
  224. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
  225. dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
  226. dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
  227. dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
  228. dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
  229. dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
  230. dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
  231. dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
  232. dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
  233. dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
  234. dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
  235. dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
  236. dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
  237. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
  238. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
  239. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
  240. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
  241. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
  242. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
  243. dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
  244. dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
  245. dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
  246. dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
  247. dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
  248. dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
  249. dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
  250. dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
  251. dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
  252. dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
  253. dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
  254. dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
  255. dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
  256. dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
  257. dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
  258. dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
  259. dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
  260. dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
  261. dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
  262. dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
  263. dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
  264. dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
  265. dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
  266. dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
  267. dnt/track/__init__.py +3 -1
  268. dnt/track/botsort/__init__.py +4 -0
  269. dnt/track/botsort/bot_tracker/__init__.py +3 -0
  270. dnt/track/botsort/bot_tracker/basetrack.py +60 -0
  271. dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
  272. dnt/track/botsort/bot_tracker/gmc.py +316 -0
  273. dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
  274. dnt/track/botsort/bot_tracker/matching.py +194 -0
  275. dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
  276. dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
  277. dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
  278. dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
  279. dnt/track/botsort/inference.py +96 -0
  280. dnt/track/config.py +120 -0
  281. dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
  282. dnt/track/dsort/configs/deep_sort.yaml +0 -0
  283. dnt/track/dsort/configs/fastreid.yaml +1 -1
  284. dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
  285. dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
  286. dnt/track/dsort/deep_sort/deep_sort.py +31 -21
  287. dnt/track/dsort/deep_sort/sort/detection.py +2 -1
  288. dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
  289. dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
  290. dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
  291. dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
  292. dnt/track/dsort/deep_sort/sort/track.py +2 -1
  293. dnt/track/dsort/deep_sort/sort/tracker.py +1 -1
  294. dnt/track/dsort/dsort.py +44 -27
  295. dnt/track/re_class.py +117 -0
  296. dnt/track/sort/sort.py +9 -7
  297. dnt/track/tracker.py +225 -20
  298. dnt-0.3.1.8.dist-info/METADATA +117 -0
  299. dnt-0.3.1.8.dist-info/RECORD +315 -0
  300. {dnt-0.2.1.dist-info → dnt-0.3.1.8.dist-info}/WHEEL +1 -1
  301. dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
  302. dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
  303. dnt/track/dsort/deep_sort/deep/test.py +0 -77
  304. dnt/track/dsort/deep_sort/deep/train.py +0 -189
  305. dnt/track/dsort/utils/asserts.py +0 -13
  306. dnt/track/dsort/utils/draw.py +0 -36
  307. dnt/track/dsort/utils/json_logger.py +0 -383
  308. dnt/track/dsort/utils/log.py +0 -17
  309. dnt/track/dsort/utils/parser.py +0 -35
  310. dnt/track/dsort/utils/tools.py +0 -39
  311. dnt-0.2.1.dist-info/METADATA +0 -35
  312. dnt-0.2.1.dist-info/RECORD +0 -60
  313. /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
  314. {dnt-0.2.1.dist-info → dnt-0.3.1.8.dist-info/licenses}/LICENSE +0 -0
  315. {dnt-0.2.1.dist-info → dnt-0.3.1.8.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,316 @@
1
+ import cv2
2
+ import matplotlib.pyplot as plt
3
+ import numpy as np
4
+ import copy
5
+ import time
6
+
7
+
8
+ class GMC:
9
+ def __init__(self, method='sparseOptFlow', downscale=2, verbose=None):
10
+ super(GMC, self).__init__()
11
+
12
+ self.method = method
13
+ self.downscale = max(1, int(downscale))
14
+
15
+ if self.method == 'orb':
16
+ self.detector = cv2.FastFeatureDetector_create(20)
17
+ self.extractor = cv2.ORB_create()
18
+ self.matcher = cv2.BFMatcher(cv2.NORM_HAMMING)
19
+
20
+ elif self.method == 'sift':
21
+ self.detector = cv2.SIFT_create(nOctaveLayers=3, contrastThreshold=0.02, edgeThreshold=20)
22
+ self.extractor = cv2.SIFT_create(nOctaveLayers=3, contrastThreshold=0.02, edgeThreshold=20)
23
+ self.matcher = cv2.BFMatcher(cv2.NORM_L2)
24
+
25
+ elif self.method == 'ecc':
26
+ number_of_iterations = 5000
27
+ termination_eps = 1e-6
28
+ self.warp_mode = cv2.MOTION_EUCLIDEAN
29
+ self.criteria = (cv2.TERM_CRITERIA_EPS | cv2.TERM_CRITERIA_COUNT, number_of_iterations, termination_eps)
30
+
31
+ elif self.method == 'sparseOptFlow':
32
+ self.feature_params = dict(maxCorners=1000, qualityLevel=0.01, minDistance=1, blockSize=3,
33
+ useHarrisDetector=False, k=0.04)
34
+ # self.gmc_file = open('GMC_results.txt', 'w')
35
+
36
+ elif self.method == 'file' or self.method == 'files':
37
+ seqName = verbose[0]
38
+ ablation = verbose[1]
39
+ if ablation:
40
+ filePath = r'bot_tracker/GMC_files/MOT17_ablation'
41
+ else:
42
+ filePath = r'bot_tracker/GMC_files/MOTChallenge'
43
+
44
+ if '-FRCNN' in seqName:
45
+ seqName = seqName[:-6]
46
+ elif '-DPM' in seqName:
47
+ seqName = seqName[:-4]
48
+ elif '-SDP' in seqName:
49
+ seqName = seqName[:-4]
50
+
51
+ self.gmcFile = open(filePath + "/GMC-" + seqName + ".txt", 'r')
52
+
53
+ if self.gmcFile is None:
54
+ raise ValueError("Error: Unable to open GMC file in directory:" + filePath)
55
+ elif self.method == 'none' or self.method == 'None':
56
+ self.method = 'none'
57
+ else:
58
+ raise ValueError("Error: Unknown CMC method:" + method)
59
+
60
+ self.prevFrame = None
61
+ self.prevKeyPoints = None
62
+ self.prevDescriptors = None
63
+
64
+ self.initializedFirstFrame = False
65
+
66
+ def apply(self, raw_frame, detections=None):
67
+ if self.method == 'orb' or self.method == 'sift':
68
+ return self.applyFeaures(raw_frame, detections)
69
+ elif self.method == 'ecc':
70
+ return self.applyEcc(raw_frame, detections)
71
+ elif self.method == 'sparseOptFlow':
72
+ return self.applySparseOptFlow(raw_frame, detections)
73
+ elif self.method == 'file':
74
+ return self.applyFile(raw_frame, detections)
75
+ elif self.method == 'none':
76
+ return np.eye(2, 3)
77
+ else:
78
+ return np.eye(2, 3)
79
+
80
+ def applyEcc(self, raw_frame, detections=None):
81
+
82
+ # Initialize
83
+ height, width, _ = raw_frame.shape
84
+ frame = cv2.cvtColor(raw_frame, cv2.COLOR_BGR2GRAY)
85
+ H = np.eye(2, 3, dtype=np.float32)
86
+
87
+ # Downscale image (TODO: consider using pyramids)
88
+ if self.downscale > 1.0:
89
+ frame = cv2.GaussianBlur(frame, (3, 3), 1.5)
90
+ frame = cv2.resize(frame, (width // self.downscale, height // self.downscale))
91
+ width = width // self.downscale
92
+ height = height // self.downscale
93
+
94
+ # Handle first frame
95
+ if not self.initializedFirstFrame:
96
+ # Initialize data
97
+ self.prevFrame = frame.copy()
98
+
99
+ # Initialization done
100
+ self.initializedFirstFrame = True
101
+
102
+ return H
103
+
104
+ # Run the ECC algorithm. The results are stored in warp_matrix.
105
+ # (cc, H) = cv2.findTransformECC(self.prevFrame, frame, H, self.warp_mode, self.criteria)
106
+ try:
107
+ (cc, H) = cv2.findTransformECC(self.prevFrame, frame, H, self.warp_mode, self.criteria, None, 1)
108
+ except:
109
+ print('Warning: find transform failed. Set warp as identity')
110
+
111
+ return H
112
+
113
+ def applyFeaures(self, raw_frame, detections=None):
114
+
115
+ # Initialize
116
+ height, width, _ = raw_frame.shape
117
+ frame = cv2.cvtColor(raw_frame, cv2.COLOR_BGR2GRAY)
118
+ H = np.eye(2, 3)
119
+
120
+ # Downscale image (TODO: consider using pyramids)
121
+ if self.downscale > 1.0:
122
+ # frame = cv2.GaussianBlur(frame, (3, 3), 1.5)
123
+ frame = cv2.resize(frame, (width // self.downscale, height // self.downscale))
124
+ width = width // self.downscale
125
+ height = height // self.downscale
126
+
127
+ # find the keypoints
128
+ mask = np.zeros_like(frame)
129
+ # mask[int(0.05 * height): int(0.95 * height), int(0.05 * width): int(0.95 * width)] = 255
130
+ mask[int(0.02 * height): int(0.98 * height), int(0.02 * width): int(0.98 * width)] = 255
131
+ if detections is not None:
132
+ for det in detections:
133
+ tlbr = (det[:4] / self.downscale).astype(np.int_)
134
+ mask[tlbr[1]:tlbr[3], tlbr[0]:tlbr[2]] = 0
135
+
136
+ keypoints = self.detector.detect(frame, mask)
137
+
138
+ # compute the descriptors
139
+ keypoints, descriptors = self.extractor.compute(frame, keypoints)
140
+
141
+ # Handle first frame
142
+ if not self.initializedFirstFrame:
143
+ # Initialize data
144
+ self.prevFrame = frame.copy()
145
+ self.prevKeyPoints = copy.copy(keypoints)
146
+ self.prevDescriptors = copy.copy(descriptors)
147
+
148
+ # Initialization done
149
+ self.initializedFirstFrame = True
150
+
151
+ return H
152
+
153
+ # Match descriptors.
154
+ knnMatches = self.matcher.knnMatch(self.prevDescriptors, descriptors, 2)
155
+
156
+ # Filtered matches based on smallest spatial distance
157
+ matches = []
158
+ spatialDistances = []
159
+
160
+ maxSpatialDistance = 0.25 * np.array([width, height])
161
+
162
+ # Handle empty matches case
163
+ if len(knnMatches) == 0:
164
+ # Store to next iteration
165
+ self.prevFrame = frame.copy()
166
+ self.prevKeyPoints = copy.copy(keypoints)
167
+ self.prevDescriptors = copy.copy(descriptors)
168
+
169
+ return H
170
+
171
+ for m, n in knnMatches:
172
+ if m.distance < 0.9 * n.distance:
173
+ prevKeyPointLocation = self.prevKeyPoints[m.queryIdx].pt
174
+ currKeyPointLocation = keypoints[m.trainIdx].pt
175
+
176
+ spatialDistance = (prevKeyPointLocation[0] - currKeyPointLocation[0],
177
+ prevKeyPointLocation[1] - currKeyPointLocation[1])
178
+
179
+ if (np.abs(spatialDistance[0]) < maxSpatialDistance[0]) and \
180
+ (np.abs(spatialDistance[1]) < maxSpatialDistance[1]):
181
+ spatialDistances.append(spatialDistance)
182
+ matches.append(m)
183
+
184
+ meanSpatialDistances = np.mean(spatialDistances, 0)
185
+ stdSpatialDistances = np.std(spatialDistances, 0)
186
+
187
+ inliesrs = (spatialDistances - meanSpatialDistances) < 2.5 * stdSpatialDistances
188
+
189
+ goodMatches = []
190
+ prevPoints = []
191
+ currPoints = []
192
+ for i in range(len(matches)):
193
+ if inliesrs[i, 0] and inliesrs[i, 1]:
194
+ goodMatches.append(matches[i])
195
+ prevPoints.append(self.prevKeyPoints[matches[i].queryIdx].pt)
196
+ currPoints.append(keypoints[matches[i].trainIdx].pt)
197
+
198
+ prevPoints = np.array(prevPoints)
199
+ currPoints = np.array(currPoints)
200
+
201
+ # Draw the keypoint matches on the output image
202
+ if 0:
203
+ matches_img = np.hstack((self.prevFrame, frame))
204
+ matches_img = cv2.cvtColor(matches_img, cv2.COLOR_GRAY2BGR)
205
+ W = np.size(self.prevFrame, 1)
206
+ for m in goodMatches:
207
+ prev_pt = np.array(self.prevKeyPoints[m.queryIdx].pt, dtype=np.int_)
208
+ curr_pt = np.array(keypoints[m.trainIdx].pt, dtype=np.int_)
209
+ curr_pt[0] += W
210
+ color = np.random.randint(0, 255, (3,))
211
+ color = (int(color[0]), int(color[1]), int(color[2]))
212
+
213
+ matches_img = cv2.line(matches_img, prev_pt, curr_pt, tuple(color), 1, cv2.LINE_AA)
214
+ matches_img = cv2.circle(matches_img, prev_pt, 2, tuple(color), -1)
215
+ matches_img = cv2.circle(matches_img, curr_pt, 2, tuple(color), -1)
216
+
217
+ plt.figure()
218
+ plt.imshow(matches_img)
219
+ plt.show()
220
+
221
+ # Find rigid matrix
222
+ if (np.size(prevPoints, 0) > 4) and (np.size(prevPoints, 0) == np.size(prevPoints, 0)):
223
+ H, inliesrs = cv2.estimateAffinePartial2D(prevPoints, currPoints, cv2.RANSAC)
224
+
225
+ # Handle downscale
226
+ if self.downscale > 1.0:
227
+ H[0, 2] *= self.downscale
228
+ H[1, 2] *= self.downscale
229
+ else:
230
+ print('Warning: not enough matching points')
231
+
232
+ # Store to next iteration
233
+ self.prevFrame = frame.copy()
234
+ self.prevKeyPoints = copy.copy(keypoints)
235
+ self.prevDescriptors = copy.copy(descriptors)
236
+
237
+ return H
238
+
239
+ def applySparseOptFlow(self, raw_frame, detections=None):
240
+
241
+ t0 = time.time()
242
+
243
+ # Initialize
244
+ height, width, _ = raw_frame.shape
245
+ frame = cv2.cvtColor(raw_frame, cv2.COLOR_BGR2GRAY)
246
+ H = np.eye(2, 3)
247
+
248
+ # Downscale image
249
+ if self.downscale > 1.0:
250
+ # frame = cv2.GaussianBlur(frame, (3, 3), 1.5)
251
+ frame = cv2.resize(frame, (width // self.downscale, height // self.downscale))
252
+
253
+ # find the keypoints
254
+ keypoints = cv2.goodFeaturesToTrack(frame, mask=None, **self.feature_params)
255
+
256
+ # Handle first frame
257
+ if not self.initializedFirstFrame:
258
+ # Initialize data
259
+ self.prevFrame = frame.copy()
260
+ self.prevKeyPoints = copy.copy(keypoints)
261
+
262
+ # Initialization done
263
+ self.initializedFirstFrame = True
264
+
265
+ return H
266
+
267
+ # find correspondences
268
+ matchedKeypoints, status, err = cv2.calcOpticalFlowPyrLK(self.prevFrame, frame, self.prevKeyPoints, None)
269
+
270
+ # leave good correspondences only
271
+ prevPoints = []
272
+ currPoints = []
273
+
274
+ for i in range(len(status)):
275
+ if status[i]:
276
+ prevPoints.append(self.prevKeyPoints[i])
277
+ currPoints.append(matchedKeypoints[i])
278
+
279
+ prevPoints = np.array(prevPoints)
280
+ currPoints = np.array(currPoints)
281
+
282
+ # Find rigid matrix
283
+ if (np.size(prevPoints, 0) > 4) and (np.size(prevPoints, 0) == np.size(prevPoints, 0)):
284
+ H, inliesrs = cv2.estimateAffinePartial2D(prevPoints, currPoints, cv2.RANSAC)
285
+
286
+ # Handle downscale
287
+ if self.downscale > 1.0:
288
+ H[0, 2] *= self.downscale
289
+ H[1, 2] *= self.downscale
290
+ else:
291
+ print('Warning: not enough matching points')
292
+
293
+ # Store to next iteration
294
+ self.prevFrame = frame.copy()
295
+ self.prevKeyPoints = copy.copy(keypoints)
296
+
297
+ t1 = time.time()
298
+
299
+ # gmc_line = str(1000 * (t1 - t0)) + "\t" + str(H[0, 0]) + "\t" + str(H[0, 1]) + "\t" + str(
300
+ # H[0, 2]) + "\t" + str(H[1, 0]) + "\t" + str(H[1, 1]) + "\t" + str(H[1, 2]) + "\n"
301
+ # self.gmc_file.write(gmc_line)
302
+
303
+ return H
304
+
305
+ def applyFile(self, raw_frame, detections=None):
306
+ line = self.gmcFile.readline()
307
+ tokens = line.split("\t")
308
+ H = np.eye(2, 3, dtype=np.float_)
309
+ H[0, 0] = float(tokens[1])
310
+ H[0, 1] = float(tokens[2])
311
+ H[0, 2] = float(tokens[3])
312
+ H[1, 0] = float(tokens[4])
313
+ H[1, 1] = float(tokens[5])
314
+ H[1, 2] = float(tokens[6])
315
+
316
+ return H
@@ -0,0 +1,269 @@
1
+ # vim: expandtab:ts=4:sw=4
2
+ import numpy as np
3
+ import scipy.linalg
4
+
5
+
6
+ """
7
+ Table for the 0.95 quantile of the chi-square distribution with N degrees of
8
+ freedom (contains values for N=1, ..., 9). Taken from MATLAB/Octave's chi2inv
9
+ function and used as Mahalanobis gating threshold.
10
+ """
11
+ chi2inv95 = {
12
+ 1: 3.8415,
13
+ 2: 5.9915,
14
+ 3: 7.8147,
15
+ 4: 9.4877,
16
+ 5: 11.070,
17
+ 6: 12.592,
18
+ 7: 14.067,
19
+ 8: 15.507,
20
+ 9: 16.919}
21
+
22
+
23
+ class KalmanFilter(object):
24
+ """
25
+ A simple Kalman filter for tracking bounding boxes in image space.
26
+
27
+ The 8-dimensional state space
28
+
29
+ x, y, w, h, vx, vy, vw, vh
30
+
31
+ contains the bounding box center position (x, y), width w, height h,
32
+ and their respective velocities.
33
+
34
+ Object motion follows a constant velocity model. The bounding box location
35
+ (x, y, w, h) is taken as direct observation of the state space (linear
36
+ observation model).
37
+
38
+ """
39
+
40
+ def __init__(self):
41
+ ndim, dt = 4, 1.
42
+
43
+ # Create Kalman filter model matrices.
44
+ self._motion_mat = np.eye(2 * ndim, 2 * ndim)
45
+ for i in range(ndim):
46
+ self._motion_mat[i, ndim + i] = dt
47
+ self._update_mat = np.eye(ndim, 2 * ndim)
48
+
49
+ # Motion and observation uncertainty are chosen relative to the current
50
+ # state estimate. These weights control the amount of uncertainty in
51
+ # the model. This is a bit hacky.
52
+ self._std_weight_position = 1. / 20
53
+ self._std_weight_velocity = 1. / 160
54
+
55
+ def initiate(self, measurement):
56
+ """Create track from unassociated measurement.
57
+
58
+ Parameters
59
+ ----------
60
+ measurement : ndarray
61
+ Bounding box coordinates (x, y, w, h) with center position (x, y),
62
+ width w, and height h.
63
+
64
+ Returns
65
+ -------
66
+ (ndarray, ndarray)
67
+ Returns the mean vector (8 dimensional) and covariance matrix (8x8
68
+ dimensional) of the new track. Unobserved velocities are initialized
69
+ to 0 mean.
70
+
71
+ """
72
+ mean_pos = measurement
73
+ mean_vel = np.zeros_like(mean_pos)
74
+ mean = np.r_[mean_pos, mean_vel]
75
+
76
+ std = [
77
+ 2 * self._std_weight_position * measurement[2],
78
+ 2 * self._std_weight_position * measurement[3],
79
+ 2 * self._std_weight_position * measurement[2],
80
+ 2 * self._std_weight_position * measurement[3],
81
+ 10 * self._std_weight_velocity * measurement[2],
82
+ 10 * self._std_weight_velocity * measurement[3],
83
+ 10 * self._std_weight_velocity * measurement[2],
84
+ 10 * self._std_weight_velocity * measurement[3]]
85
+ covariance = np.diag(np.square(std))
86
+ return mean, covariance
87
+
88
+ def predict(self, mean, covariance):
89
+ """Run Kalman filter prediction step.
90
+
91
+ Parameters
92
+ ----------
93
+ mean : ndarray
94
+ The 8 dimensional mean vector of the object state at the previous
95
+ time step.
96
+ covariance : ndarray
97
+ The 8x8 dimensional covariance matrix of the object state at the
98
+ previous time step.
99
+
100
+ Returns
101
+ -------
102
+ (ndarray, ndarray)
103
+ Returns the mean vector and covariance matrix of the predicted
104
+ state. Unobserved velocities are initialized to 0 mean.
105
+
106
+ """
107
+ std_pos = [
108
+ self._std_weight_position * mean[2],
109
+ self._std_weight_position * mean[3],
110
+ self._std_weight_position * mean[2],
111
+ self._std_weight_position * mean[3]]
112
+ std_vel = [
113
+ self._std_weight_velocity * mean[2],
114
+ self._std_weight_velocity * mean[3],
115
+ self._std_weight_velocity * mean[2],
116
+ self._std_weight_velocity * mean[3]]
117
+ motion_cov = np.diag(np.square(np.r_[std_pos, std_vel]))
118
+
119
+ mean = np.dot(mean, self._motion_mat.T)
120
+ covariance = np.linalg.multi_dot((
121
+ self._motion_mat, covariance, self._motion_mat.T)) + motion_cov
122
+
123
+ return mean, covariance
124
+
125
+ def project(self, mean, covariance):
126
+ """Project state distribution to measurement space.
127
+
128
+ Parameters
129
+ ----------
130
+ mean : ndarray
131
+ The state's mean vector (8 dimensional array).
132
+ covariance : ndarray
133
+ The state's covariance matrix (8x8 dimensional).
134
+
135
+ Returns
136
+ -------
137
+ (ndarray, ndarray)
138
+ Returns the projected mean and covariance matrix of the given state
139
+ estimate.
140
+
141
+ """
142
+ std = [
143
+ self._std_weight_position * mean[2],
144
+ self._std_weight_position * mean[3],
145
+ self._std_weight_position * mean[2],
146
+ self._std_weight_position * mean[3]]
147
+ innovation_cov = np.diag(np.square(std))
148
+
149
+ mean = np.dot(self._update_mat, mean)
150
+ covariance = np.linalg.multi_dot((
151
+ self._update_mat, covariance, self._update_mat.T))
152
+ return mean, covariance + innovation_cov
153
+
154
+ def multi_predict(self, mean, covariance):
155
+ """Run Kalman filter prediction step (Vectorized version).
156
+ Parameters
157
+ ----------
158
+ mean : ndarray
159
+ The Nx8 dimensional mean matrix of the object states at the previous
160
+ time step.
161
+ covariance : ndarray
162
+ The Nx8x8 dimensional covariance matrics of the object states at the
163
+ previous time step.
164
+ Returns
165
+ -------
166
+ (ndarray, ndarray)
167
+ Returns the mean vector and covariance matrix of the predicted
168
+ state. Unobserved velocities are initialized to 0 mean.
169
+ """
170
+ std_pos = [
171
+ self._std_weight_position * mean[:, 2],
172
+ self._std_weight_position * mean[:, 3],
173
+ self._std_weight_position * mean[:, 2],
174
+ self._std_weight_position * mean[:, 3]]
175
+ std_vel = [
176
+ self._std_weight_velocity * mean[:, 2],
177
+ self._std_weight_velocity * mean[:, 3],
178
+ self._std_weight_velocity * mean[:, 2],
179
+ self._std_weight_velocity * mean[:, 3]]
180
+ sqr = np.square(np.r_[std_pos, std_vel]).T
181
+
182
+ motion_cov = []
183
+ for i in range(len(mean)):
184
+ motion_cov.append(np.diag(sqr[i]))
185
+ motion_cov = np.asarray(motion_cov)
186
+
187
+ mean = np.dot(mean, self._motion_mat.T)
188
+ left = np.dot(self._motion_mat, covariance).transpose((1, 0, 2))
189
+ covariance = np.dot(left, self._motion_mat.T) + motion_cov
190
+
191
+ return mean, covariance
192
+
193
+ def update(self, mean, covariance, measurement):
194
+ """Run Kalman filter correction step.
195
+
196
+ Parameters
197
+ ----------
198
+ mean : ndarray
199
+ The predicted state's mean vector (8 dimensional).
200
+ covariance : ndarray
201
+ The state's covariance matrix (8x8 dimensional).
202
+ measurement : ndarray
203
+ The 4 dimensional measurement vector (x, y, w, h), where (x, y)
204
+ is the center position, w the width, and h the height of the
205
+ bounding box.
206
+
207
+ Returns
208
+ -------
209
+ (ndarray, ndarray)
210
+ Returns the measurement-corrected state distribution.
211
+
212
+ """
213
+ projected_mean, projected_cov = self.project(mean, covariance)
214
+
215
+ chol_factor, lower = scipy.linalg.cho_factor(
216
+ projected_cov, lower=True, check_finite=False)
217
+ kalman_gain = scipy.linalg.cho_solve(
218
+ (chol_factor, lower), np.dot(covariance, self._update_mat.T).T,
219
+ check_finite=False).T
220
+ innovation = measurement - projected_mean
221
+
222
+ new_mean = mean + np.dot(innovation, kalman_gain.T)
223
+ new_covariance = covariance - np.linalg.multi_dot((
224
+ kalman_gain, projected_cov, kalman_gain.T))
225
+ return new_mean, new_covariance
226
+
227
+ def gating_distance(self, mean, covariance, measurements,
228
+ only_position=False, metric='maha'):
229
+ """Compute gating distance between state distribution and measurements.
230
+ A suitable distance threshold can be obtained from `chi2inv95`. If
231
+ `only_position` is False, the chi-square distribution has 4 degrees of
232
+ freedom, otherwise 2.
233
+ Parameters
234
+ ----------
235
+ mean : ndarray
236
+ Mean vector over the state distribution (8 dimensional).
237
+ covariance : ndarray
238
+ Covariance of the state distribution (8x8 dimensional).
239
+ measurements : ndarray
240
+ An Nx4 dimensional matrix of N measurements, each in
241
+ format (x, y, a, h) where (x, y) is the bounding box center
242
+ position, a the aspect ratio, and h the height.
243
+ only_position : Optional[bool]
244
+ If True, distance computation is done with respect to the bounding
245
+ box center position only.
246
+ Returns
247
+ -------
248
+ ndarray
249
+ Returns an array of length N, where the i-th element contains the
250
+ squared Mahalanobis distance between (mean, covariance) and
251
+ `measurements[i]`.
252
+ """
253
+ mean, covariance = self.project(mean, covariance)
254
+ if only_position:
255
+ mean, covariance = mean[:2], covariance[:2, :2]
256
+ measurements = measurements[:, :2]
257
+
258
+ d = measurements - mean
259
+ if metric == 'gaussian':
260
+ return np.sum(d * d, axis=1)
261
+ elif metric == 'maha':
262
+ cholesky_factor = np.linalg.cholesky(covariance)
263
+ z = scipy.linalg.solve_triangular(
264
+ cholesky_factor, d.T, lower=True, check_finite=False,
265
+ overwrite_b=True)
266
+ squared_maha = np.sum(z * z, axis=0)
267
+ return squared_maha
268
+ else:
269
+ raise ValueError('invalid distance metric')