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
@@ -3,7 +3,8 @@ import numpy as np
3
3
  import copy
4
4
  import motmetrics as mm
5
5
  mm.lap.default_solver = 'lap'
6
- from utils.io import read_results, unzip_objs
6
+
7
+ from yolox.tracking_utils.io import read_results, unzip_objs
7
8
 
8
9
 
9
10
  class Evaluator(object):
@@ -39,7 +40,6 @@ class Evaluator(object):
39
40
  ignore_objs = self.gt_ignore_frame_dict.get(frame_id, [])
40
41
  ignore_tlwhs = unzip_objs(ignore_objs)[0]
41
42
 
42
-
43
43
  # remove ignored results
44
44
  keep = np.ones(len(trk_tlwhs), dtype=bool)
45
45
  iou_distance = mm.distances.iou_matrix(ignore_tlwhs, trk_tlwhs, max_iou=0.5)
@@ -53,6 +53,15 @@ class Evaluator(object):
53
53
  keep[match_js] = False
54
54
  trk_tlwhs = trk_tlwhs[keep]
55
55
  trk_ids = trk_ids[keep]
56
+ #match_is, match_js = mm.lap.linear_sum_assignment(iou_distance)
57
+ #match_is, match_js = map(lambda a: np.asarray(a, dtype=int), [match_is, match_js])
58
+ #match_ious = iou_distance[match_is, match_js]
59
+
60
+ #match_js = np.asarray(match_js, dtype=int)
61
+ #match_js = match_js[np.logical_not(np.isnan(match_ious))]
62
+ #keep[match_js] = False
63
+ #trk_tlwhs = trk_tlwhs[keep]
64
+ #trk_ids = trk_ids[keep]
56
65
 
57
66
  # get distance matrix
58
67
  iou_distance = mm.distances.iou_matrix(gt_tlwhs, trk_tlwhs, max_iou=0.5)
@@ -70,7 +79,8 @@ class Evaluator(object):
70
79
  self.reset_accumulator()
71
80
 
72
81
  result_frame_dict = read_results(filename, self.data_type, is_gt=False)
73
- frames = sorted(list(set(self.gt_frame_dict.keys()) | set(result_frame_dict.keys())))
82
+ #frames = sorted(list(set(self.gt_frame_dict.keys()) | set(result_frame_dict.keys())))
83
+ frames = sorted(list(set(result_frame_dict.keys())))
74
84
  for frame_id in frames:
75
85
  trk_objs = result_frame_dict.get(frame_id, [])
76
86
  trk_tlwhs, trk_ids = unzip_objs(trk_objs)[:2]
@@ -100,4 +110,4 @@ class Evaluator(object):
100
110
  import pandas as pd
101
111
  writer = pd.ExcelWriter(filename)
102
112
  summary.to_excel(writer)
103
- writer.save()
113
+ writer.save()
@@ -2,58 +2,34 @@ import os
2
2
  from typing import Dict
3
3
  import numpy as np
4
4
 
5
- # from utils.log import get_logger
6
5
 
6
+ def write_results(filename, results_dict: Dict, data_type: str):
7
+ if not filename:
8
+ return
9
+ path = os.path.dirname(filename)
10
+ if not os.path.exists(path):
11
+ os.makedirs(path)
7
12
 
8
- def write_results(filename, results, data_type):
9
- if data_type == 'mot':
10
- save_format = '{frame},{id},{x1},{y1},{w},{h},-1,-1,-1,-1\n'
13
+ if data_type in ('mot', 'mcmot', 'lab'):
14
+ save_format = '{frame},{id},{x1},{y1},{w},{h},1,-1,-1,-1\n'
11
15
  elif data_type == 'kitti':
12
- save_format = '{frame} {id} pedestrian 0 0 -10 {x1} {y1} {x2} {y2} -10 -10 -10 -1000 -1000 -1000 -10\n'
16
+ save_format = '{frame} {id} pedestrian -1 -1 -10 {x1} {y1} {x2} {y2} -1 -1 -1 -1000 -1000 -1000 -10 {score}\n'
13
17
  else:
14
18
  raise ValueError(data_type)
15
19
 
16
20
  with open(filename, 'w') as f:
17
- for frame_id, tlwhs, track_ids in results:
21
+ for frame_id, frame_data in results_dict.items():
18
22
  if data_type == 'kitti':
19
23
  frame_id -= 1
20
- for tlwh, track_id in zip(tlwhs, track_ids):
24
+ for tlwh, track_id in frame_data:
21
25
  if track_id < 0:
22
26
  continue
23
27
  x1, y1, w, h = tlwh
24
28
  x2, y2 = x1 + w, y1 + h
25
- line = save_format.format(frame=frame_id, id=track_id, x1=x1, y1=y1, x2=x2, y2=y2, w=w, h=h)
29
+ line = save_format.format(frame=frame_id, id=track_id, x1=x1, y1=y1, x2=x2, y2=y2, w=w, h=h, score=1.0)
26
30
  f.write(line)
27
31
 
28
32
 
29
- # def write_results(filename, results_dict: Dict, data_type: str):
30
- # if not filename:
31
- # return
32
- # path = os.path.dirname(filename)
33
- # if not os.path.exists(path):
34
- # os.makedirs(path)
35
-
36
- # if data_type in ('mot', 'mcmot', 'lab'):
37
- # save_format = '{frame},{id},{x1},{y1},{w},{h},1,-1,-1,-1\n'
38
- # elif data_type == 'kitti':
39
- # save_format = '{frame} {id} pedestrian -1 -1 -10 {x1} {y1} {x2} {y2} -1 -1 -1 -1000 -1000 -1000 -10 {score}\n'
40
- # else:
41
- # raise ValueError(data_type)
42
-
43
- # with open(filename, 'w') as f:
44
- # for frame_id, frame_data in results_dict.items():
45
- # if data_type == 'kitti':
46
- # frame_id -= 1
47
- # for tlwh, track_id in frame_data:
48
- # if track_id < 0:
49
- # continue
50
- # x1, y1, w, h = tlwh
51
- # x2, y2 = x1 + w, y1 + h
52
- # line = save_format.format(frame=frame_id, id=track_id, x1=x1, y1=y1, x2=x2, y2=y2, w=w, h=h, score=1.0)
53
- # f.write(line)
54
- # logger.info('Save results to {}'.format(filename))
55
-
56
-
57
33
  def read_results(filename, data_type: str, is_gt=False, is_ignore=False):
58
34
  if data_type in ('mot', 'lab'):
59
35
  read_fun = read_mot_results
@@ -96,6 +72,8 @@ def read_mot_results(filename, is_gt, is_ignore):
96
72
  continue
97
73
  results_dict.setdefault(fid, list())
98
74
 
75
+ box_size = float(linelist[4]) * float(linelist[5])
76
+
99
77
  if is_gt:
100
78
  if 'MOT16-' in filename or 'MOT17-' in filename:
101
79
  label = int(float(linelist[7]))
@@ -115,6 +93,11 @@ def read_mot_results(filename, is_gt, is_ignore):
115
93
  else:
116
94
  score = float(linelist[6])
117
95
 
96
+ #if box_size > 7000:
97
+ #if box_size <= 7000 or box_size >= 15000:
98
+ #if box_size < 15000:
99
+ #continue
100
+
118
101
  tlwh = tuple(map(float, linelist[2:6]))
119
102
  target_id = int(linelist[1])
120
103
 
@@ -0,0 +1,37 @@
1
+ import time
2
+
3
+
4
+ class Timer(object):
5
+ """A simple timer."""
6
+ def __init__(self):
7
+ self.total_time = 0.
8
+ self.calls = 0
9
+ self.start_time = 0.
10
+ self.diff = 0.
11
+ self.average_time = 0.
12
+
13
+ self.duration = 0.
14
+
15
+ def tic(self):
16
+ # using time.time instead of time.clock because time time.clock
17
+ # does not normalize for multithreading
18
+ self.start_time = time.time()
19
+
20
+ def toc(self, average=True):
21
+ self.diff = time.time() - self.start_time
22
+ self.total_time += self.diff
23
+ self.calls += 1
24
+ self.average_time = self.total_time / self.calls
25
+ if average:
26
+ self.duration = self.average_time
27
+ else:
28
+ self.duration = self.diff
29
+ return self.duration
30
+
31
+ def clear(self):
32
+ self.total_time = 0.
33
+ self.calls = 0
34
+ self.start_time = 0.
35
+ self.diff = 0.
36
+ self.average_time = 0.
37
+ self.duration = 0.
@@ -0,0 +1,96 @@
1
+ import os, sys
2
+ import cv2
3
+ import torch
4
+ import numpy as np
5
+ import pandas as pd
6
+ from tqdm import tqdm
7
+ import argparse
8
+
9
+ sys.path.append(os.path.join(os.path.dirname(__file__), '../..'))
10
+
11
+ from bot_tracker.mc_bot_sort import BoTSORT
12
+ from config import Config
13
+
14
+ def track(video_file:str, det_file:str, out_file:str = None, cfg:dict = Config.get_cfg_botsort(),
15
+ video_index:int = None, total_videos:int = None)->pd.DataFrame:
16
+
17
+ cap = cv2.VideoCapture(video_file)
18
+ if not cap.isOpened():
19
+ raise IOError("Couldn't open webcam or video")
20
+
21
+ if video_file is not None:
22
+ fps = cap.get(cv2.CAP_PROP_FPS)
23
+ else:
24
+ fps = cfg['fps']
25
+
26
+ botsort = BoTSORT(cfg, frame_rate=fps)
27
+
28
+ detections = pd.read_csv(det_file, header=None).to_numpy()
29
+ start_frame = int(min(detections[:,0]))
30
+ end_frame = int(max(detections[:,0]))
31
+ tot_frames = max((end_frame - start_frame + 1), 0)
32
+
33
+ pbar = tqdm(total=tot_frames, desc='Tracking {}'.format(os.path.basename(video_file)), unit = 'frames')
34
+ if video_index and total_videos:
35
+ pbar.desc = 'Tracking {} of {}'.format(video_index, total_videos)
36
+
37
+ results = []
38
+ cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
39
+ while cap.isOpened():
40
+
41
+ pos_frame = int(cap.get(cv2.CAP_PROP_POS_FRAMES))
42
+ ret, frame = cap.read()
43
+
44
+ if (not ret) or (pos_frame>end_frame):
45
+ break
46
+
47
+ im = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
48
+ frame_dets = detections[np.where(detections[:,0] == pos_frame)]
49
+ nrows, ncols = frame_dets.shape
50
+
51
+ if nrows > 0:
52
+ dets = []
53
+ for det in frame_dets:
54
+ dets.append([det[2], det[3], det[2]+det[4], det[3]+det[5], det[6], det[7]]) # x1, y1, x2, y2, score, class
55
+ dets = np.array(dets)
56
+ '''
57
+ for det in frame_dets:
58
+ bbox_xywh.append([det[2]+det[4]/2, det[3]+det[5]/2, det[4], det[5]])
59
+ bbox_xywh = np.array(bbox_xywh)
60
+ conf_score = np.array(frame_dets[:,6])
61
+ '''
62
+ outputs = botsort.update(dets, im)
63
+
64
+ if len(outputs) > 0:
65
+ for t in outputs:
66
+ tlwh = t.tlwh
67
+ tlbr = t.tlbr
68
+ tid = t.track_id
69
+ tcls = t.cls
70
+ score = t.score
71
+ vertical = tlwh[2] / tlwh[3] > cfg['aspect_ratio_thresh']
72
+ if tlwh[2] * tlwh[3] > cfg['min_box_area'] and not vertical:
73
+ results.append([pos_frame, tid, int(tlwh[0]), int(tlwh[1]), int(tlwh[2]), int(tlwh[3]), round(score,1), int(tcls), -1, -1])
74
+
75
+ pbar.update()
76
+ cap.release()
77
+ pbar.close()
78
+
79
+ df = pd.DataFrame(results)
80
+ if out_file:
81
+ if cfg['output_header']:
82
+ header = ['frame', 'track_id', 'x', 'y', 'w', 'h', 'score', 'class', 'r3','r4']
83
+ else:
84
+ header = None
85
+ df.to_csv(out_file, index=False, header=header)
86
+
87
+ return df
88
+
89
+ if __name__ == "__main__":
90
+
91
+ video_file = "/mnt/d/videos/ped2stage/videos/gh1293.mp4"
92
+ iou_file = "/mnt/d/videos/ped2stage/dets/gh1293_iou_ped.txt"
93
+ out_file = "/mnt/d/videos/ped2stage/tracks/gh1293_ped_track_2.txt"
94
+
95
+ track(video_file, iou_file, out_file)
96
+
dnt/track/config.py ADDED
@@ -0,0 +1,120 @@
1
+ import yaml
2
+ import os, io
3
+
4
+ class Config:
5
+ def __init__(self, cfg:dict):
6
+ pass
7
+
8
+ @staticmethod
9
+ def get_cfg_sort()->dict:
10
+ '''
11
+ method: str - Tracking method, 'sort'
12
+ max_age: int - Maximum age of a track, default is 1
13
+ min_inits: int - Number of frames to wait before activate a track, default is 3
14
+ iou_threshold: float - IOU threshold, default is 0.3
15
+ '''
16
+ return {'method':'sort',
17
+ 'max_age':1,
18
+ 'min_inits':3,
19
+ 'iou_threshold':0.3}
20
+
21
+ @staticmethod
22
+ def get_cfg_dsort(model:str="default")->dict:
23
+ '''
24
+ Parameters:
25
+ model: str - DeepSORT model, 'default', 'bot_R50', 'bot_R50-ibn', 'bot_S50', 'bot_R101-ibn', 'veh_bot_R50-ibn'
26
+ Contents:
27
+ method: str - Tracking method, 'dsort'
28
+ reid_cfg: str - ReID config file path
29
+ reid_ckpt: str - ReID weights file path
30
+ max_dist: float - Maximum cosine distance, default is 0.2
31
+ min_confidence: float - Minimum detection confidence, default is 0.3
32
+ nms_max_overlap: float - Maximum overlap in NMS, default is 0.5
33
+ max_iou_distance: float - Maximum IOU distance, default is 0.7
34
+ max_age: int - Maximum age of a track, default is 70
35
+ n_init: int - Number of frames to wait before activate a track, default is 3
36
+ nn_budget: int - Maximum number of nearest neighbors, default is 100
37
+ '''
38
+ cfg = { 'method': 'dsort',
39
+ 'reid_cfg': None,
40
+ 'reid_ckpt': 'ckpt.t7',
41
+ 'max_dist': 0.2,
42
+ 'min_confidence': 0.3,
43
+ 'nms_max_overlap': 0.5,
44
+ 'max_iou_distance': 0.7,
45
+ 'max_age': 70,
46
+ 'n_init': 3,
47
+ 'nn_budget': 100}
48
+
49
+ if model == 'bot_R50':
50
+ cfg['reid_cfg'] = 'Market1501/bagtricks_R50.yml'
51
+ cfg['reid_ckpt'] = 'market_bot_R50.pth'
52
+ elif model == 'bot_R50-ibn':
53
+ cfg['reid_cfg'] = 'Market1501/bagtricks_R50-ibn.yml'
54
+ cfg['reid_ckpt'] = 'market_bot_R50-ibn.pth'
55
+ elif model == 'bot_S50':
56
+ cfg['reid_cfg'] = 'Market1501/bagtricks_S50.yml'
57
+ cfg['reid_ckpt'] = 'market_bot_S50.pth'
58
+ elif model == 'bot_R101-ibn':
59
+ cfg['reid_cfg'] = 'Market1501/bagtricks_R101-ibn.yml'
60
+ cfg['reid_ckpt'] = 'market_bot_R101-ibn.pth'
61
+ elif model == 'veh_bot_R50-ibn':
62
+ cfg['reid_cfg'] = 'VehicleID/bagtricks_R50-ibn.yml'
63
+ cfg['reid_ckpt'] = 'vehicleid_bot_R50-ibn.pth'
64
+
65
+ return cfg
66
+
67
+ @staticmethod
68
+ def get_cfg_botsort()->dict:
69
+ '''
70
+ method: str - Tracking method, 'botsort'
71
+ device: str - Calucation device, default is 'cuda'
72
+ half: bool - Half precision, default is False
73
+ track_high_thresh: float - Tracking confidence threshold, default is 0.5
74
+ track_low_thresh: float - Lowest detection threshold, default is 0.1
75
+ new_track_thresh: float - New track thresh, default is 0.6
76
+ track_buffer: int - The frames for keep lost tracks, default is 30
77
+ fps: int - Video fps, default is 30
78
+ match_thresh: float - Matching threshold for tracking, default is 0.8
79
+ aspect_ratio_thresh: float - Threshold for filtering out boxes of which aspect ratio are above the given value, default is 1.6
80
+ min_box_area: int - Filter out tiny boxes, default is 10
81
+ fuse_score: bool - Fuse score and iou for association, default is False
82
+ mot20: str - MOT20 dataset, default is None
83
+ cmc_method: str - CMC method, 'sparseOptFlow', 'orb', 'ecc', default is 'sparseOptFlow'
84
+ ablation: bool - Ablation, default is False
85
+ name: str - Benchmark name, default is 'None'
86
+ with_reid: bool - With ReID module, default is True
87
+ fast_reid_config: str - ReID config file path, default is 'Market1501/sbs_S50.yml'
88
+ fast_reid_weights: str - ReID config file path, default is 'market_bot_S50.pth'
89
+ proximity_thresh: float - Threshold for rejecting low overlap reid matches, default is 0.5
90
+ appearance_thresh: float - Threshold for rejecting low appearance similarity reid matches, default is 0.25
91
+ '''
92
+ return { 'method': 'botsort',
93
+ 'device': 'cuda', # calucation device: cpu, cuda
94
+ 'half': False, # half precision: True, False
95
+ 'output_header': False, # add header in the output file
96
+
97
+ # Track
98
+ 'track_high_thresh': 0.5, # tracking confidence threshold
99
+ 'track_low_thresh': 0.1, # lowest detection threshold
100
+ 'new_track_thresh': 0.6, # new track thresh
101
+ 'track_buffer': 30, # the frames for keep lost tracks
102
+ 'fps': 30, # video fps
103
+ 'match_thresh': 0.8, # matching threshold for tracking
104
+ 'aspect_ratio_thresh': 1.6, # threshold for filtering out boxes of which aspect ratio are above the given value.
105
+ 'min_box_area': 10, # filter out tiny boxes
106
+ 'fuse_score': False, # fuse score and iou for association
107
+ 'mot20': None, # mot20 dataset
108
+
109
+ # CMC
110
+ 'cmc_method': 'sparseOptFlow', # cmc method: files (Vidstab GMC) | sparseOptFlow |orb | ecc
111
+ 'ablation': False, # ablation
112
+ 'name': 'None', # benchmark name
113
+
114
+ # ReID
115
+ 'with_reid': True, # with ReID module.
116
+ 'fast_reid_config': 'Market1501/sbs_S50.yml', # reid config file path
117
+ 'fast_reid_weights': 'market_bot_S50.pth', # reid config file path
118
+ 'proximity_thresh': 0.5, # threshold for rejecting low overlap reid matches
119
+ 'appearance_thresh': 0.25 # threshold for rejecting low appearance similarity reid matches
120
+ }
@@ -0,0 +1,7 @@
1
+ _BASE_: ../Base-bagtricks.yml
2
+
3
+ DATASETS:
4
+ NAMES: ("Market1501",)
5
+ TESTS: ("Market1501",)
6
+
7
+ OUTPUT_DIR: logs/market1501/bagtricks_R50
File without changes
@@ -1,3 +1,3 @@
1
1
  FASTREID:
2
- CFG: "thirdparty/fast-reid/configs/Market1501/bagtricks_R50.yml"
2
+ CFG: "bagtricks_R50.yml"
3
3
  CHECKPOINT: "deep_sort/deep/checkpoint/market_bot_R50.pth"
File without changes
@@ -3,13 +3,29 @@ import torchvision.transforms as transforms
3
3
  import numpy as np
4
4
  import cv2
5
5
  import logging
6
+ import os, sys, requests
7
+ from tqdm import tqdm
6
8
 
7
- from .model import Net
9
+ sys.path.append(os.path.join(os.path.dirname(__file__)))
10
+ sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../../third_party/fast-reid/")))
11
+
12
+ from model import Net
13
+ from fastreid.config import get_cfg # type: ignore
14
+ from fastreid.engine import DefaultTrainer # type: ignore
15
+ from fastreid.utils.checkpoint import Checkpointer # type: ignore
8
16
 
9
17
  class Extractor(object):
10
- def __init__(self, model_path, use_cuda=True):
18
+ def __init__(self, model_path, device:str='auto', half:bool=False):
11
19
  self.net = Net(reid=True)
12
- self.device = "cuda" if torch.cuda.is_available() and use_cuda else "cpu"
20
+ if device == 'auto':
21
+ self.device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
22
+ elif device == 'cuda' and torch.cuda.is_available():
23
+ self.device = 'cuda'
24
+ elif device == 'mps' and torch.backends.mps.is_available():
25
+ self.device = 'mps'
26
+ else:
27
+ self.device = 'cpu'
28
+ self.half = half
13
29
  state_dict = torch.load(model_path, map_location=lambda storage, loc: storage)['net_dict']
14
30
  self.net.load_state_dict(state_dict)
15
31
  logger = logging.getLogger("root.tracker")
@@ -44,12 +60,75 @@ class Extractor(object):
44
60
  features = self.net(im_batch)
45
61
  return features.cpu().numpy()
46
62
 
63
+
47
64
  class FastReIDExtractor(object):
48
- pass
65
+ def __init__(self, model_config, model_path, device:str='cuda', half:bool=False):
66
+ cfg = get_cfg()
67
+ cfg.set_new_allowed(True)
68
+ cfg.merge_from_file(model_config)
69
+ cfg.MODEL.BACKBONE.PRETRAIN = False
70
+ self.net = DefaultTrainer.build_model(cfg)
71
+ if device == 'auto':
72
+ self.device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
73
+ elif device == 'cuda' and torch.cuda.is_available():
74
+ self.device = 'cuda'
75
+ elif device == 'mps' and torch.backends.mps.is_available():
76
+ self.device = 'mps'
77
+ else:
78
+ self.device = 'cpu'
79
+ self.half = half
80
+
81
+ if not os.path.exists(model_path):
82
+ try:
83
+ url = 'https://github.com/JDAI-CV/fast-reid/releases/download/v0.1.1/'+os.path.basename(model_path)
84
+ response = requests.get(url, stream=True, allow_redirects=True)
85
+ with open(model_path, mode="wb") as file:
86
+ pbar = tqdm(unit="B", total=int(response.headers['Content-Length']),
87
+ desc="Downloading "+os.path.basename(model_path)+" ...")
88
+ for chunk in response.iter_content(chunk_size=10 * 1024):
89
+ file.write(chunk)
90
+ pbar.update(len(chunk))
91
+ except ValueError:
92
+ raise FileNotFoundError(f"File {model_path} not found and cannot be downloaded from {url}!")
93
+
94
+ Checkpointer(self.net).load(model_path)
95
+ logger = logging.getLogger("root.tracker")
96
+ logger.info("Loading weights from {}... Done!".format(model_path))
97
+ self.net.to(self.device)
98
+ self.net.eval()
99
+ height, width = cfg.INPUT.SIZE_TEST
100
+ self.size = (width, height)
101
+ self.norm = transforms.Compose([
102
+ transforms.ToTensor(),
103
+ transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225]),
104
+ ])
105
+
106
+ def _preprocess(self, im_crops):
107
+ def _resize(im, size):
108
+ return cv2.resize(im.astype(np.float32)/255., size)
109
+
110
+ im_batch = torch.cat([self.norm(_resize(im, self.size)).unsqueeze(0) for im in im_crops], dim=0).float()
111
+ return im_batch
112
+
113
+
114
+ def __call__(self, im_crops):
115
+ im_batch = self._preprocess(im_crops)
116
+ with torch.no_grad():
117
+ im_batch = im_batch.to(self.device)
118
+ features = self.net(im_batch)
119
+ return features.cpu().numpy()
49
120
 
50
121
  if __name__ == '__main__':
51
- img = cv2.imread("demo.jpg")[:,:,(2,1,0)]
52
- extr = Extractor("checkpoint/ckpt.t7")
53
- feature = extr(img)
54
- print(feature.shape)
122
+ dirname = os.path.dirname(__file__)
123
+ img_file = os.path.join(dirname, "demo.jpg")
124
+ imgs = []
125
+ imgs.append(cv2.imread(img_file)[:,:,(2,1,0)])
126
+ cfg_file = os.path.join(dirname, "fastreid.yaml")
127
+ model_1 = os.path.join(dirname, "checkpoint/ckpt.t7")
128
+ model_2 = os.path.join(dirname, "checkpoint/market_bot_R50.pth")
129
+ extr1 = Extractor(model_1, use_cuda=True)
130
+ extr2 = FastReIDExtractor(cfg_file, model_2)
131
+ feature1 = extr1(imgs)
132
+ feature2 = extr2(imgs)
133
+ print(feature1.shape, feature2.shape)
55
134
 
@@ -1,3 +1,4 @@
1
+ import sys, os
1
2
  import numpy as np
2
3
  import torch
3
4
 
@@ -7,30 +8,40 @@ from .sort.preprocessing import non_max_suppression
7
8
  from .sort.detection import Detection
8
9
  from .sort.tracker import Tracker
9
10
 
10
-
11
11
  __all__ = ['DeepSort']
12
12
 
13
-
14
13
  class DeepSort(object):
15
- def __init__(self, model_path, model_config=None, max_dist=0.2, min_confidence=0.3, nms_max_overlap=1.0, max_iou_distance=0.7, max_age=70, n_init=3, nn_budget=100, use_cuda=True):
16
- self.min_confidence = min_confidence
17
- self.nms_max_overlap = nms_max_overlap
18
-
19
- if model_config is None:
20
- self.extractor = Extractor(model_path, use_cuda=use_cuda)
14
+ def __init__(self, cfg:dict, device:str='auto', half:bool=False):
15
+
16
+ self.model_path = cfg['reid_ckpt'] # path to the reid checkpoint (model weights)
17
+ self.model_config= cfg['reid_cfg'] # path to the reid config file (yaml)
18
+ self.max_cosine_distance = cfg['max_dist']
19
+ self.min_confidence = cfg['min_confidence'] # ignore detections if confidence lower than this value
20
+ self.nms_max_overlap = cfg['nms_max_overlap']
21
+ self.max_iou_distance = cfg['max_iou_distance']
22
+ self.max_age = cfg['max_age'] # if a track is not matched in max_age frames, it will be deleted
23
+ self.n_init = cfg['n_init'] # number of detections before creating a track
24
+ self.nn_budget = cfg['nn_budget']
25
+
26
+ if self.model_config is None:
27
+ self.extractor = Extractor(os.path.join(os.path.dirname(__file__), 'deep/checkpoint/', self.model_path)
28
+ , device=device, half=half) # default extractor
21
29
  else:
22
- self.extractor = FastReIDExtractor(model_config, model_path, use_cuda=use_cuda)
30
+ cfg_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../third_party/fast-reid/configs/', self.model_config))
31
+ ckpt_path = os.path.abspath(os.path.join(os.path.dirname(__file__), '../../../third_party/fast-reid/checkpoint/', self.model_path))
32
+ self.extractor = FastReIDExtractor(cfg_path, ckpt_path, device=device, half=half) # fast-reid extractor
23
33
 
24
- max_cosine_distance = max_dist
25
- metric = NearestNeighborDistanceMetric("cosine", max_cosine_distance, nn_budget)
26
- self.tracker = Tracker(metric, max_iou_distance=max_iou_distance, max_age=max_age, n_init=n_init)
34
+ metric = NearestNeighborDistanceMetric("cosine", self.max_cosine_distance, self.nn_budget)
35
+ self.tracker = Tracker(metric, max_iou_distance=self.max_iou_distance, max_age=self.max_age, n_init=self.n_init)
27
36
 
28
- def update(self, bbox_xywh, confidences, ori_img):
37
+ def update(self, bbox_xywh, confidences, classes, ori_img):
29
38
  self.height, self.width = ori_img.shape[:2]
39
+
30
40
  # generate detections
31
- features = self._get_features(bbox_xywh, ori_img)
32
- bbox_tlwh = self._xywh_to_tlwh(bbox_xywh)
33
- detections = [Detection(bbox_tlwh[i], conf, features[i]) for i,conf in enumerate(confidences) if conf>self.min_confidence]
41
+ features = self._get_features(bbox_xywh, ori_img) # extract features for bboxes
42
+ bbox_tlwh = self._xywh_to_tlwh(bbox_xywh) # convert bbox from xc_yc_w_h to left top width height/width
43
+ detections = [Detection(bbox_tlwh[i], conf, classes[i], features[i])
44
+ for i, conf in enumerate(confidences) if conf>self.min_confidence] # ignore low confidence bboxes
34
45
 
35
46
  # run on non-maximum supression
36
47
  boxes = np.array([d.tlwh for d in detections])
@@ -39,8 +50,8 @@ class DeepSort(object):
39
50
  detections = [detections[i] for i in indices]
40
51
 
41
52
  # update tracker
42
- self.tracker.predict()
43
- self.tracker.update(detections)
53
+ self.tracker.predict() # predict the location of the bboxes
54
+ self.tracker.update(detections) # update tracks by location and appearance
44
55
 
45
56
  # output bbox identities
46
57
  outputs = []
@@ -50,12 +61,12 @@ class DeepSort(object):
50
61
  box = track.to_tlwh()
51
62
  x1,y1,x2,y2 = self._tlwh_to_xyxy(box)
52
63
  track_id = track.track_id
53
- outputs.append(np.array([x1,y1,x2,y2,track_id], dtype=int))
64
+ track_cls = track.cls
65
+ outputs.append(np.array([x1,y1,x2,y2,track_id,track_cls], dtype=int))
54
66
  if len(outputs) > 0:
55
67
  outputs = np.stack(outputs,axis=0)
56
68
  return outputs
57
69
 
58
-
59
70
  """
60
71
  TODO:
61
72
  Convert bbox from xc_yc_w_h to xtl_ytl_w_h
@@ -71,7 +82,6 @@ class DeepSort(object):
71
82
  bbox_tlwh[:,1] = bbox_xywh[:,1] - bbox_xywh[:,3]/2.
72
83
  return bbox_tlwh
73
84
 
74
-
75
85
  def _xywh_to_xyxy(self, bbox_xywh):
76
86
  x,y,w,h = bbox_xywh
77
87
  x1 = max(int(x-w/2),0)
@@ -26,10 +26,11 @@ class Detection(object):
26
26
 
27
27
  """
28
28
 
29
- def __init__(self, tlwh, confidence, feature):
29
+ def __init__(self, tlwh, confidence, cls, feature):
30
30
  self.tlwh = np.asarray(tlwh, dtype=float)
31
31
  self.confidence = float(confidence)
32
32
  self.feature = np.asarray(feature, dtype=float)
33
+ self.cls = cls
33
34
 
34
35
  def to_tlbr(self):
35
36
  """Convert bounding box to format `(min x, min y, max x, max y)`, i.e.,
@@ -3,7 +3,6 @@ from __future__ import absolute_import
3
3
  import numpy as np
4
4
  from . import linear_assignment
5
5
 
6
-
7
6
  def iou(bbox, candidates):
8
7
  """Computer intersection over union.
9
8
 
@@ -38,7 +37,6 @@ def iou(bbox, candidates):
38
37
  area_candidates = candidates[:, 2:].prod(axis=1)
39
38
  return area_intersection / (area_bbox + area_candidates - area_intersection)
40
39
 
41
-
42
40
  def iou_cost(tracks, detections, track_indices=None,
43
41
  detection_indices=None):
44
42
  """An intersection over union distance metric.