dnt 0.2.4__py3-none-any.whl → 0.3.1.3__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.

Potentially problematic release.


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

Files changed (305) hide show
  1. dnt/__init__.py +3 -2
  2. dnt/analysis/__init__.py +3 -2
  3. dnt/analysis/interaction.py +503 -0
  4. dnt/analysis/stop.py +22 -17
  5. dnt/analysis/stop2.py +289 -0
  6. dnt/analysis/stop3.py +754 -0
  7. dnt/detect/signal/detector.py +317 -0
  8. dnt/detect/yolov8/detector.py +116 -16
  9. dnt/engine/__init__.py +8 -0
  10. dnt/engine/bbox_interp.py +83 -0
  11. dnt/engine/bbox_iou.py +20 -0
  12. dnt/engine/cluster.py +31 -0
  13. dnt/engine/iob.py +66 -0
  14. dnt/filter/filter.py +321 -1
  15. dnt/label/labeler.py +4 -4
  16. dnt/label/labeler2.py +502 -0
  17. dnt/shared/__init__.py +2 -1
  18. dnt/shared/data/coco.names +0 -0
  19. dnt/shared/data/openimages.names +0 -0
  20. dnt/shared/data/voc.names +0 -0
  21. dnt/shared/download.py +12 -0
  22. dnt/shared/synhcro.py +150 -0
  23. dnt/shared/util.py +17 -4
  24. dnt/third_party/fast-reid/__init__.py +1 -0
  25. dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
  26. dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
  27. dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
  28. dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
  29. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
  30. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
  31. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
  32. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
  33. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
  34. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
  35. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
  36. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
  37. dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
  38. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
  39. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
  40. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
  41. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
  42. dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
  43. dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
  44. dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
  45. dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
  46. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
  47. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
  48. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
  49. dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
  50. dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
  51. dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
  52. dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
  53. dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
  54. dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
  55. dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
  56. dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
  57. dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
  58. dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
  59. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
  60. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
  61. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
  62. dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
  63. dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
  64. dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
  65. dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
  66. dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
  67. dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
  68. dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
  69. dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
  70. dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
  71. dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
  72. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
  73. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
  74. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
  75. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
  76. dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
  77. dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
  78. dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
  79. dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
  80. dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
  81. dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
  82. dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
  83. dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
  84. dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
  85. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
  86. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
  87. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
  88. dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
  89. dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
  90. dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
  91. dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
  92. dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
  93. dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
  94. dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
  95. dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
  96. dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
  97. dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
  98. dnt/third_party/fast-reid/configs/__init__.py +0 -0
  99. dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
  100. dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
  101. dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
  102. dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
  103. dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
  104. dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
  105. dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
  106. dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
  107. dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
  108. dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
  109. dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
  110. dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
  111. dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
  112. dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
  113. dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
  114. dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
  115. dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
  116. dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
  117. dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
  118. dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
  119. dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
  120. dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
  121. dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
  122. dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
  123. dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
  124. dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
  125. dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
  126. dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
  127. dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
  128. dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
  129. dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
  130. dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
  131. dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
  132. dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
  133. dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
  134. dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
  135. dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
  136. dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
  137. dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
  138. dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
  139. dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
  140. dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
  141. dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
  142. dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
  143. dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
  144. dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
  145. dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
  146. dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
  147. dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
  148. dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
  149. dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
  150. dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
  151. dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
  152. dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
  153. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
  154. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
  155. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
  156. dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
  157. dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
  158. dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
  159. dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
  160. dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
  161. dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
  162. dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
  163. dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
  164. dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
  165. dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
  166. dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
  167. dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
  168. dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
  169. dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
  170. dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
  171. dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
  172. dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
  173. dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
  174. dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
  175. dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
  176. dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
  177. dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
  178. dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
  179. dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
  180. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
  181. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
  182. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
  183. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
  184. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
  185. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
  186. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
  187. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
  188. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
  189. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
  190. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
  191. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
  192. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
  193. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
  194. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
  195. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
  196. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
  197. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
  198. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
  199. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
  200. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
  201. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
  202. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
  203. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
  204. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
  205. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
  206. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
  207. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
  208. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
  209. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
  210. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
  211. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
  212. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
  213. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
  214. dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
  215. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
  216. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
  217. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
  218. dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
  219. dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
  220. dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
  221. dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
  222. dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
  223. dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
  224. dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
  225. dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
  226. dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
  227. dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
  228. dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
  229. dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
  230. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
  231. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
  232. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
  233. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
  234. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
  235. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
  236. dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
  237. dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
  238. dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
  239. dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
  240. dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
  241. dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
  242. dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
  243. dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
  244. dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
  245. dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
  246. dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
  247. dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
  248. dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
  249. dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
  250. dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
  251. dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
  252. dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
  253. dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
  254. dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
  255. dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
  256. dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
  257. dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
  258. dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
  259. dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
  260. dnt/track/__init__.py +2 -0
  261. dnt/track/botsort/__init__.py +4 -0
  262. dnt/track/botsort/bot_tracker/__init__.py +3 -0
  263. dnt/track/botsort/bot_tracker/basetrack.py +60 -0
  264. dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
  265. dnt/track/botsort/bot_tracker/gmc.py +316 -0
  266. dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
  267. dnt/track/botsort/bot_tracker/matching.py +194 -0
  268. dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
  269. dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
  270. dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
  271. dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
  272. dnt/track/botsort/inference.py +96 -0
  273. dnt/track/config.py +120 -0
  274. dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
  275. dnt/track/dsort/configs/deep_sort.yaml +0 -0
  276. dnt/track/dsort/configs/fastreid.yaml +1 -1
  277. dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
  278. dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
  279. dnt/track/dsort/deep_sort/deep_sort.py +28 -18
  280. dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
  281. dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
  282. dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
  283. dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
  284. dnt/track/dsort/dsort.py +21 -28
  285. dnt/track/re_class.py +94 -0
  286. dnt/track/sort/sort.py +5 -1
  287. dnt/track/tracker.py +207 -30
  288. {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/METADATA +30 -10
  289. dnt-0.3.1.3.dist-info/RECORD +314 -0
  290. {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/WHEEL +1 -1
  291. dnt/analysis/yield.py +0 -9
  292. dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
  293. dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
  294. dnt/track/dsort/deep_sort/deep/test.py +0 -77
  295. dnt/track/dsort/deep_sort/deep/train.py +0 -189
  296. dnt/track/dsort/utils/asserts.py +0 -13
  297. dnt/track/dsort/utils/draw.py +0 -36
  298. dnt/track/dsort/utils/json_logger.py +0 -383
  299. dnt/track/dsort/utils/log.py +0 -17
  300. dnt/track/dsort/utils/parser.py +0 -35
  301. dnt/track/dsort/utils/tools.py +0 -39
  302. dnt-0.2.4.dist-info/RECORD +0 -64
  303. /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
  304. {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/LICENSE +0 -0
  305. {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,329 @@
1
+ from .config import CfgNode as CN
2
+
3
+ # -----------------------------------------------------------------------------
4
+ # Convention about Training / Test specific parameters
5
+ # -----------------------------------------------------------------------------
6
+ # Whenever an argument can be either used for training or for testing, the
7
+ # corresponding name will be post-fixed by a _TRAIN for a training parameter,
8
+ # or _TEST for a test-specific parameter.
9
+ # For example, the number of images during training will be
10
+ # IMAGES_PER_BATCH_TRAIN, while the number of images for testing will be
11
+ # IMAGES_PER_BATCH_TEST
12
+
13
+ # -----------------------------------------------------------------------------
14
+ # Config definition
15
+ # -----------------------------------------------------------------------------
16
+
17
+ _C = CN()
18
+
19
+ # -----------------------------------------------------------------------------
20
+ # MODEL
21
+ # -----------------------------------------------------------------------------
22
+ _C.MODEL = CN()
23
+ _C.MODEL.DEVICE = "cuda"
24
+ _C.MODEL.META_ARCHITECTURE = "Baseline"
25
+
26
+ _C.MODEL.FREEZE_LAYERS = []
27
+
28
+ # MoCo memory size
29
+ _C.MODEL.QUEUE_SIZE = 8192
30
+
31
+ # ---------------------------------------------------------------------------- #
32
+ # Backbone options
33
+ # ---------------------------------------------------------------------------- #
34
+ _C.MODEL.BACKBONE = CN()
35
+
36
+ _C.MODEL.BACKBONE.NAME = "build_resnet_backbone"
37
+ _C.MODEL.BACKBONE.DEPTH = "50x"
38
+ _C.MODEL.BACKBONE.LAST_STRIDE = 1
39
+ # Backbone feature dimension
40
+ _C.MODEL.BACKBONE.FEAT_DIM = 2048
41
+ # Normalization method for the convolution layers.
42
+ _C.MODEL.BACKBONE.NORM = "BN"
43
+ # If use IBN block in backbone
44
+ _C.MODEL.BACKBONE.WITH_IBN = False
45
+ # If use SE block in backbone
46
+ _C.MODEL.BACKBONE.WITH_SE = False
47
+ # If use Non-local block in backbone
48
+ _C.MODEL.BACKBONE.WITH_NL = False
49
+ # Vision Transformer options
50
+ _C.MODEL.BACKBONE.SIE_COE = 3.0
51
+ _C.MODEL.BACKBONE.STRIDE_SIZE = (16, 16)
52
+ _C.MODEL.BACKBONE.DROP_PATH_RATIO = 0.1
53
+ _C.MODEL.BACKBONE.DROP_RATIO = 0.0
54
+ _C.MODEL.BACKBONE.ATT_DROP_RATE = 0.0
55
+ # If use ImageNet pretrain model
56
+ _C.MODEL.BACKBONE.PRETRAIN = False
57
+ # Pretrain model path
58
+ _C.MODEL.BACKBONE.PRETRAIN_PATH = ''
59
+
60
+ # ---------------------------------------------------------------------------- #
61
+ # REID HEADS options
62
+ # ---------------------------------------------------------------------------- #
63
+ _C.MODEL.HEADS = CN()
64
+ _C.MODEL.HEADS.NAME = "EmbeddingHead"
65
+ # Normalization method for the convolution layers.
66
+ _C.MODEL.HEADS.NORM = "BN"
67
+ # Number of identity
68
+ _C.MODEL.HEADS.NUM_CLASSES = 0
69
+ # Embedding dimension in head
70
+ _C.MODEL.HEADS.EMBEDDING_DIM = 0
71
+ # If use BNneck in embedding
72
+ _C.MODEL.HEADS.WITH_BNNECK = False
73
+ # Triplet feature using feature before(after) bnneck
74
+ _C.MODEL.HEADS.NECK_FEAT = "before" # options: before, after
75
+ # Pooling layer type
76
+ _C.MODEL.HEADS.POOL_LAYER = "GlobalAvgPool"
77
+
78
+ # Classification layer type
79
+ _C.MODEL.HEADS.CLS_LAYER = "Linear" # ArcSoftmax" or "CircleSoftmax"
80
+
81
+ # Margin and Scale for margin-based classification layer
82
+ _C.MODEL.HEADS.MARGIN = 0.
83
+ _C.MODEL.HEADS.SCALE = 1
84
+
85
+ # ---------------------------------------------------------------------------- #
86
+ # REID LOSSES options
87
+ # ---------------------------------------------------------------------------- #
88
+ _C.MODEL.LOSSES = CN()
89
+ _C.MODEL.LOSSES.NAME = ("CrossEntropyLoss",)
90
+
91
+ # Cross Entropy Loss options
92
+ _C.MODEL.LOSSES.CE = CN()
93
+ # if epsilon == 0, it means no label smooth regularization,
94
+ # if epsilon == -1, it means adaptive label smooth regularization
95
+ _C.MODEL.LOSSES.CE.EPSILON = 0.0
96
+ _C.MODEL.LOSSES.CE.ALPHA = 0.2
97
+ _C.MODEL.LOSSES.CE.SCALE = 1.0
98
+
99
+ # Focal Loss options
100
+ _C.MODEL.LOSSES.FL = CN()
101
+ _C.MODEL.LOSSES.FL.ALPHA = 0.25
102
+ _C.MODEL.LOSSES.FL.GAMMA = 2
103
+ _C.MODEL.LOSSES.FL.SCALE = 1.0
104
+
105
+ # Triplet Loss options
106
+ _C.MODEL.LOSSES.TRI = CN()
107
+ _C.MODEL.LOSSES.TRI.MARGIN = 0.3
108
+ _C.MODEL.LOSSES.TRI.NORM_FEAT = False
109
+ _C.MODEL.LOSSES.TRI.HARD_MINING = False
110
+ _C.MODEL.LOSSES.TRI.SCALE = 1.0
111
+
112
+ # Circle Loss options
113
+ _C.MODEL.LOSSES.CIRCLE = CN()
114
+ _C.MODEL.LOSSES.CIRCLE.MARGIN = 0.25
115
+ _C.MODEL.LOSSES.CIRCLE.GAMMA = 128
116
+ _C.MODEL.LOSSES.CIRCLE.SCALE = 1.0
117
+
118
+ # Cosface Loss options
119
+ _C.MODEL.LOSSES.COSFACE = CN()
120
+ _C.MODEL.LOSSES.COSFACE.MARGIN = 0.25
121
+ _C.MODEL.LOSSES.COSFACE.GAMMA = 128
122
+ _C.MODEL.LOSSES.COSFACE.SCALE = 1.0
123
+
124
+ # Path to a checkpoint file to be loaded to the model. You can find available models in the model zoo.
125
+ _C.MODEL.WEIGHTS = ""
126
+
127
+ # Values to be used for image normalization
128
+ _C.MODEL.PIXEL_MEAN = [0.485*255, 0.456*255, 0.406*255]
129
+ # Values to be used for image normalization
130
+ _C.MODEL.PIXEL_STD = [0.229*255, 0.224*255, 0.225*255]
131
+
132
+ # -----------------------------------------------------------------------------
133
+ # KNOWLEDGE DISTILLATION
134
+ # -----------------------------------------------------------------------------
135
+
136
+ _C.KD = CN()
137
+ _C.KD.MODEL_CONFIG = []
138
+ _C.KD.MODEL_WEIGHTS = []
139
+ _C.KD.EMA = CN({"ENABLED": False})
140
+ _C.KD.EMA.MOMENTUM = 0.999
141
+
142
+ # -----------------------------------------------------------------------------
143
+ # INPUT
144
+ # -----------------------------------------------------------------------------
145
+ _C.INPUT = CN()
146
+ # Size of the image during training
147
+ _C.INPUT.SIZE_TRAIN = [256, 128]
148
+ # Size of the image during test
149
+ _C.INPUT.SIZE_TEST = [256, 128]
150
+
151
+ # `True` if cropping is used for data augmentation during training
152
+ _C.INPUT.CROP = CN({"ENABLED": False})
153
+ # Size of the image cropped
154
+ _C.INPUT.CROP.SIZE = [224, 224]
155
+ # Size of the origin size cropped
156
+ _C.INPUT.CROP.SCALE = [0.16, 1]
157
+ # Aspect ratio of the origin aspect ratio cropped
158
+ _C.INPUT.CROP.RATIO = [3./4., 4./3.]
159
+
160
+ # Random probability for image horizontal flip
161
+ _C.INPUT.FLIP = CN({"ENABLED": False})
162
+ _C.INPUT.FLIP.PROB = 0.5
163
+
164
+ # Value of padding size
165
+ _C.INPUT.PADDING = CN({"ENABLED": False})
166
+ _C.INPUT.PADDING.MODE = 'constant'
167
+ _C.INPUT.PADDING.SIZE = 10
168
+
169
+ # Random color jitter
170
+ _C.INPUT.CJ = CN({"ENABLED": False})
171
+ _C.INPUT.CJ.PROB = 0.5
172
+ _C.INPUT.CJ.BRIGHTNESS = 0.15
173
+ _C.INPUT.CJ.CONTRAST = 0.15
174
+ _C.INPUT.CJ.SATURATION = 0.1
175
+ _C.INPUT.CJ.HUE = 0.1
176
+
177
+ # Random Affine
178
+ _C.INPUT.AFFINE = CN({"ENABLED": False})
179
+
180
+ # Auto augmentation
181
+ _C.INPUT.AUTOAUG = CN({"ENABLED": False})
182
+ _C.INPUT.AUTOAUG.PROB = 0.0
183
+
184
+ # Augmix augmentation
185
+ _C.INPUT.AUGMIX = CN({"ENABLED": False})
186
+ _C.INPUT.AUGMIX.PROB = 0.0
187
+
188
+ # Random Erasing
189
+ _C.INPUT.REA = CN({"ENABLED": False})
190
+ _C.INPUT.REA.PROB = 0.5
191
+ _C.INPUT.REA.VALUE = [0.485*255, 0.456*255, 0.406*255]
192
+ # Random Patch
193
+ _C.INPUT.RPT = CN({"ENABLED": False})
194
+ _C.INPUT.RPT.PROB = 0.5
195
+
196
+ # -----------------------------------------------------------------------------
197
+ # Dataset
198
+ # -----------------------------------------------------------------------------
199
+ _C.DATASETS = CN()
200
+ # List of the dataset names for training
201
+ _C.DATASETS.NAMES = ("Market1501",)
202
+ # List of the dataset names for testing
203
+ _C.DATASETS.TESTS = ("Market1501",)
204
+ # Combine trainset and testset joint training
205
+ _C.DATASETS.COMBINEALL = False
206
+
207
+ # -----------------------------------------------------------------------------
208
+ # DataLoader
209
+ # -----------------------------------------------------------------------------
210
+ _C.DATALOADER = CN()
211
+ # Options: TrainingSampler, NaiveIdentitySampler, BalancedIdentitySampler
212
+ _C.DATALOADER.SAMPLER_TRAIN = "TrainingSampler"
213
+ # Number of instance for each person
214
+ _C.DATALOADER.NUM_INSTANCE = 4
215
+ _C.DATALOADER.NUM_WORKERS = 8
216
+
217
+ # For set re-weight
218
+ _C.DATALOADER.SET_WEIGHT = []
219
+
220
+ # ---------------------------------------------------------------------------- #
221
+ # Solver
222
+ # ---------------------------------------------------------------------------- #
223
+ _C.SOLVER = CN()
224
+
225
+ # AUTOMATIC MIXED PRECISION
226
+ _C.SOLVER.AMP = CN({"ENABLED": False})
227
+
228
+ # Optimizer
229
+ _C.SOLVER.OPT = "Adam"
230
+
231
+ _C.SOLVER.MAX_EPOCH = 120
232
+
233
+ _C.SOLVER.BASE_LR = 3e-4
234
+
235
+ # This LR is applied to the last classification layer if
236
+ # you want to 10x higher than BASE_LR.
237
+ _C.SOLVER.HEADS_LR_FACTOR = 1.
238
+
239
+ _C.SOLVER.MOMENTUM = 0.9
240
+ _C.SOLVER.NESTEROV = False
241
+
242
+ _C.SOLVER.WEIGHT_DECAY = 0.0005
243
+ # The weight decay that's applied to parameters of normalization layers
244
+ # (typically the affine transformation)
245
+ _C.SOLVER.WEIGHT_DECAY_NORM = 0.0005
246
+
247
+ # The previous detection code used a 2x higher LR and 0 WD for bias.
248
+ # This is not useful (at least for recent models). You should avoid
249
+ # changing these and they exists only to reproduce previous model
250
+ # training if desired.
251
+ _C.SOLVER.BIAS_LR_FACTOR = 1.0
252
+ _C.SOLVER.WEIGHT_DECAY_BIAS = _C.SOLVER.WEIGHT_DECAY
253
+
254
+ # Multi-step learning rate options
255
+ _C.SOLVER.SCHED = "MultiStepLR"
256
+
257
+ _C.SOLVER.DELAY_EPOCHS = 0
258
+
259
+ _C.SOLVER.GAMMA = 0.1
260
+ _C.SOLVER.STEPS = [30, 55]
261
+
262
+ # Cosine annealing learning rate options
263
+ _C.SOLVER.ETA_MIN_LR = 1e-7
264
+
265
+ # Warmup options
266
+ _C.SOLVER.WARMUP_FACTOR = 0.1
267
+ _C.SOLVER.WARMUP_ITERS = 1000
268
+ _C.SOLVER.WARMUP_METHOD = "linear"
269
+
270
+ # Backbone freeze iters
271
+ _C.SOLVER.FREEZE_ITERS = 0
272
+
273
+ _C.SOLVER.CHECKPOINT_PERIOD = 20
274
+
275
+ # Number of images per batch across all machines.
276
+ # This is global, so if we have 8 GPUs and IMS_PER_BATCH = 256, each GPU will
277
+ # see 32 images per batch
278
+ _C.SOLVER.IMS_PER_BATCH = 64
279
+
280
+ # Gradient clipping
281
+ _C.SOLVER.CLIP_GRADIENTS = CN({"ENABLED": False})
282
+ # Type of gradient clipping, currently 2 values are supported:
283
+ # - "value": the absolute values of elements of each gradients are clipped
284
+ # - "norm": the norm of the gradient for each parameter is clipped thus
285
+ # affecting all elements in the parameter
286
+ _C.SOLVER.CLIP_GRADIENTS.CLIP_TYPE = "norm"
287
+ # Maximum absolute value used for clipping gradients
288
+ _C.SOLVER.CLIP_GRADIENTS.CLIP_VALUE = 5.0
289
+ # Floating point number p for L-p norm to be used with the "norm"
290
+ # gradient clipping type; for L-inf, please specify .inf
291
+ _C.SOLVER.CLIP_GRADIENTS.NORM_TYPE = 2.0
292
+
293
+ _C.TEST = CN()
294
+
295
+ _C.TEST.EVAL_PERIOD = 20
296
+
297
+ # Number of images per batch across all machines.
298
+ _C.TEST.IMS_PER_BATCH = 64
299
+ _C.TEST.METRIC = "cosine"
300
+ _C.TEST.ROC = CN({"ENABLED": False})
301
+ _C.TEST.FLIP = CN({"ENABLED": False})
302
+
303
+ # Average query expansion
304
+ _C.TEST.AQE = CN({"ENABLED": False})
305
+ _C.TEST.AQE.ALPHA = 3.0
306
+ _C.TEST.AQE.QE_TIME = 1
307
+ _C.TEST.AQE.QE_K = 5
308
+
309
+ # Re-rank
310
+ _C.TEST.RERANK = CN({"ENABLED": False})
311
+ _C.TEST.RERANK.K1 = 20
312
+ _C.TEST.RERANK.K2 = 6
313
+ _C.TEST.RERANK.LAMBDA = 0.3
314
+
315
+ # Precise batchnorm
316
+ _C.TEST.PRECISE_BN = CN({"ENABLED": False})
317
+ _C.TEST.PRECISE_BN.DATASET = 'Market1501'
318
+ _C.TEST.PRECISE_BN.NUM_ITER = 300
319
+
320
+ # ---------------------------------------------------------------------------- #
321
+ # Misc options
322
+ # ---------------------------------------------------------------------------- #
323
+ _C.OUTPUT_DIR = "logs/"
324
+
325
+ # Benchmark different cudnn algorithms.
326
+ # If input images have very different sizes, this option will have large overhead
327
+ # for about 10k iterations. It usually hurts total time, but can benefit for certain models.
328
+ # If input images have the same or similar sizes, benchmark is often helpful.
329
+ _C.CUDNN_BENCHMARK = False
@@ -0,0 +1,17 @@
1
+ # encoding: utf-8
2
+ """
3
+ @author: sherlock
4
+ @contact: sherlockliao01@gmail.com
5
+ """
6
+
7
+ from . import transforms # isort:skip
8
+ from .build import (
9
+ build_reid_train_loader,
10
+ build_reid_test_loader
11
+ )
12
+ from .common import CommDataset
13
+
14
+ # ensure the builtin datasets are registered
15
+ from . import datasets, samplers # isort:skip
16
+
17
+ __all__ = [k for k in globals().keys() if not k.startswith("_")]
@@ -0,0 +1,194 @@
1
+ # encoding: utf-8
2
+ """
3
+ @author: l1aoxingyu
4
+ @contact: sherlockliao01@gmail.com
5
+ """
6
+
7
+ import logging
8
+ import os
9
+
10
+ import torch
11
+ TORCH_MAJOR = int(torch.__version__.split('.')[0])
12
+ TORCH_MINOR = int(torch.__version__.split('.')[1])
13
+
14
+ if TORCH_MAJOR == 1 and TORCH_MINOR < 8:
15
+ from torch._six import string_classes # type: ignore
16
+ else:
17
+ string_classes = str
18
+
19
+ from collections.abc import Mapping
20
+
21
+ from fastreid.config import configurable
22
+ from fastreid.utils import comm
23
+ from . import samplers
24
+ from .common import CommDataset
25
+ from .data_utils import DataLoaderX
26
+ from .datasets import DATASET_REGISTRY
27
+ from .transforms import build_transforms
28
+
29
+ __all__ = [
30
+ "build_reid_train_loader",
31
+ "build_reid_test_loader"
32
+ ]
33
+
34
+ _root = os.getenv("FASTREID_DATASETS", "datasets")
35
+
36
+
37
+ def _train_loader_from_config(cfg, *, train_set=None, transforms=None, sampler=None, **kwargs):
38
+ if transforms is None:
39
+ transforms = build_transforms(cfg, is_train=True)
40
+
41
+ if train_set is None:
42
+ train_items = list()
43
+ for d in cfg.DATASETS.NAMES:
44
+ data = DATASET_REGISTRY.get(d)(root=_root, **kwargs)
45
+ if comm.is_main_process():
46
+ data.show_train()
47
+ train_items.extend(data.train)
48
+
49
+ train_set = CommDataset(train_items, transforms, relabel=True)
50
+
51
+ if sampler is None:
52
+ sampler_name = cfg.DATALOADER.SAMPLER_TRAIN
53
+ num_instance = cfg.DATALOADER.NUM_INSTANCE
54
+ mini_batch_size = cfg.SOLVER.IMS_PER_BATCH // comm.get_world_size()
55
+
56
+ logger = logging.getLogger(__name__)
57
+ logger.info("Using training sampler {}".format(sampler_name))
58
+ if sampler_name == "TrainingSampler":
59
+ sampler = samplers.TrainingSampler(len(train_set))
60
+ elif sampler_name == "NaiveIdentitySampler":
61
+ sampler = samplers.NaiveIdentitySampler(train_set.img_items, mini_batch_size, num_instance)
62
+ elif sampler_name == "BalancedIdentitySampler":
63
+ sampler = samplers.BalancedIdentitySampler(train_set.img_items, mini_batch_size, num_instance)
64
+ elif sampler_name == "SetReWeightSampler":
65
+ set_weight = cfg.DATALOADER.SET_WEIGHT
66
+ sampler = samplers.SetReWeightSampler(train_set.img_items, mini_batch_size, num_instance, set_weight)
67
+ elif sampler_name == "ImbalancedDatasetSampler":
68
+ sampler = samplers.ImbalancedDatasetSampler(train_set.img_items)
69
+ else:
70
+ raise ValueError("Unknown training sampler: {}".format(sampler_name))
71
+
72
+ return {
73
+ "train_set": train_set,
74
+ "sampler": sampler,
75
+ "total_batch_size": cfg.SOLVER.IMS_PER_BATCH,
76
+ "num_workers": cfg.DATALOADER.NUM_WORKERS,
77
+ }
78
+
79
+
80
+ @configurable(from_config=_train_loader_from_config)
81
+ def build_reid_train_loader(
82
+ train_set, *, sampler=None, total_batch_size, num_workers=0,
83
+ ):
84
+ """
85
+ Build a dataloader for object re-identification with some default features.
86
+ This interface is experimental.
87
+
88
+ Returns:
89
+ torch.utils.data.DataLoader: a dataloader.
90
+ """
91
+
92
+ mini_batch_size = total_batch_size // comm.get_world_size()
93
+
94
+ batch_sampler = torch.utils.data.sampler.BatchSampler(sampler, mini_batch_size, True)
95
+
96
+ train_loader = DataLoaderX(
97
+ comm.get_local_rank(),
98
+ dataset=train_set,
99
+ num_workers=num_workers,
100
+ batch_sampler=batch_sampler,
101
+ collate_fn=fast_batch_collator,
102
+ pin_memory=True,
103
+ )
104
+
105
+ return train_loader
106
+
107
+
108
+ def _test_loader_from_config(cfg, *, dataset_name=None, test_set=None, num_query=0, transforms=None, **kwargs):
109
+ if transforms is None:
110
+ transforms = build_transforms(cfg, is_train=False)
111
+
112
+ if test_set is None:
113
+ assert dataset_name is not None, "dataset_name must be explicitly passed in when test_set is not provided"
114
+ data = DATASET_REGISTRY.get(dataset_name)(root=_root, **kwargs)
115
+ if comm.is_main_process():
116
+ data.show_test()
117
+ test_items = data.query + data.gallery
118
+ test_set = CommDataset(test_items, transforms, relabel=False)
119
+
120
+ # Update query number
121
+ num_query = len(data.query)
122
+
123
+ return {
124
+ "test_set": test_set,
125
+ "test_batch_size": cfg.TEST.IMS_PER_BATCH,
126
+ "num_query": num_query,
127
+ }
128
+
129
+
130
+ @configurable(from_config=_test_loader_from_config)
131
+ def build_reid_test_loader(test_set, test_batch_size, num_query, num_workers=4):
132
+ """
133
+ Similar to `build_reid_train_loader`. This sampler coordinates all workers to produce
134
+ the exact set of all samples
135
+ This interface is experimental.
136
+
137
+ Args:
138
+ test_set:
139
+ test_batch_size:
140
+ num_query:
141
+ num_workers:
142
+
143
+ Returns:
144
+ DataLoader: a torch DataLoader, that loads the given reid dataset, with
145
+ the test-time transformation.
146
+
147
+ Examples:
148
+ ::
149
+ data_loader = build_reid_test_loader(test_set, test_batch_size, num_query)
150
+ # or, instantiate with a CfgNode:
151
+ data_loader = build_reid_test_loader(cfg, "my_test")
152
+ """
153
+
154
+ mini_batch_size = test_batch_size // comm.get_world_size()
155
+ data_sampler = samplers.InferenceSampler(len(test_set))
156
+ batch_sampler = torch.utils.data.BatchSampler(data_sampler, mini_batch_size, False)
157
+ test_loader = DataLoaderX(
158
+ comm.get_local_rank(),
159
+ dataset=test_set,
160
+ batch_sampler=batch_sampler,
161
+ num_workers=num_workers, # save some memory
162
+ collate_fn=fast_batch_collator,
163
+ pin_memory=True,
164
+ )
165
+ return test_loader, num_query
166
+
167
+
168
+ def trivial_batch_collator(batch):
169
+ """
170
+ A batch collator that does nothing.
171
+ """
172
+ return batch
173
+
174
+
175
+ def fast_batch_collator(batched_inputs):
176
+ """
177
+ A simple batch collator for most common reid tasks
178
+ """
179
+ elem = batched_inputs[0]
180
+ if isinstance(elem, torch.Tensor):
181
+ out = torch.zeros((len(batched_inputs), *elem.size()), dtype=elem.dtype)
182
+ for i, tensor in enumerate(batched_inputs):
183
+ out[i] += tensor
184
+ return out
185
+
186
+ elif isinstance(elem, Mapping):
187
+ return {key: fast_batch_collator([d[key] for d in batched_inputs]) for key in elem}
188
+
189
+ elif isinstance(elem, float):
190
+ return torch.tensor(batched_inputs, dtype=torch.float64)
191
+ elif isinstance(elem, int):
192
+ return torch.tensor(batched_inputs)
193
+ elif isinstance(elem, string_classes):
194
+ return batched_inputs
@@ -0,0 +1,58 @@
1
+ # encoding: utf-8
2
+ """
3
+ @author: liaoxingyu
4
+ @contact: sherlockliao01@gmail.com
5
+ """
6
+
7
+ from torch.utils.data import Dataset
8
+
9
+ from .data_utils import read_image
10
+
11
+
12
+ class CommDataset(Dataset):
13
+ """Image Person ReID Dataset"""
14
+
15
+ def __init__(self, img_items, transform=None, relabel=True):
16
+ self.img_items = img_items
17
+ self.transform = transform
18
+ self.relabel = relabel
19
+
20
+ pid_set = set()
21
+ cam_set = set()
22
+ for i in img_items:
23
+ pid_set.add(i[1])
24
+ cam_set.add(i[2])
25
+
26
+ self.pids = sorted(list(pid_set))
27
+ self.cams = sorted(list(cam_set))
28
+ if relabel:
29
+ self.pid_dict = dict([(p, i) for i, p in enumerate(self.pids)])
30
+ self.cam_dict = dict([(p, i) for i, p in enumerate(self.cams)])
31
+
32
+ def __len__(self):
33
+ return len(self.img_items)
34
+
35
+ def __getitem__(self, index):
36
+ img_item = self.img_items[index]
37
+ img_path = img_item[0]
38
+ pid = img_item[1]
39
+ camid = img_item[2]
40
+ img = read_image(img_path)
41
+ if self.transform is not None: img = self.transform(img)
42
+ if self.relabel:
43
+ pid = self.pid_dict[pid]
44
+ camid = self.cam_dict[camid]
45
+ return {
46
+ "images": img,
47
+ "targets": pid,
48
+ "camids": camid,
49
+ "img_paths": img_path,
50
+ }
51
+
52
+ @property
53
+ def num_classes(self):
54
+ return len(self.pids)
55
+
56
+ @property
57
+ def num_cameras(self):
58
+ return len(self.cams)