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,503 @@
1
+ #!/usr/bin/env python3
2
+ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved.
3
+
4
+ import copy
5
+ import logging
6
+ import os
7
+ from collections import defaultdict
8
+ from typing import Any
9
+ from typing import Optional, List, Dict, NamedTuple, Tuple, Iterable
10
+
11
+ import numpy as np
12
+ import torch
13
+ import torch.nn as nn
14
+ from termcolor import colored
15
+ from torch.nn.parallel import DistributedDataParallel, DataParallel
16
+
17
+ from fastreid.utils.file_io import PathManager
18
+
19
+
20
+ class _IncompatibleKeys(
21
+ NamedTuple(
22
+ # pyre-fixme[10]: Name `IncompatibleKeys` is used but not defined.
23
+ "IncompatibleKeys",
24
+ [
25
+ ("missing_keys", List[str]),
26
+ ("unexpected_keys", List[str]),
27
+ # pyre-fixme[24]: Generic type `tuple` expects at least 1 type parameter.
28
+ # pyre-fixme[24]: Generic type `tuple` expects at least 1 type parameter.
29
+ # pyre-fixme[24]: Generic type `tuple` expects at least 1 type parameter.
30
+ ("incorrect_shapes", List[Tuple]),
31
+ ],
32
+ )
33
+ ):
34
+ pass
35
+
36
+
37
+ class Checkpointer(object):
38
+ """
39
+ A checkpointer that can save/load model as well as extra checkpointable
40
+ objects.
41
+ """
42
+
43
+ def __init__(
44
+ self,
45
+ model: nn.Module,
46
+ save_dir: str = "",
47
+ *,
48
+ save_to_disk: bool = True,
49
+ **checkpointables: object,
50
+ ):
51
+ """
52
+ Args:
53
+ model (nn.Module): model.
54
+ save_dir (str): a directory to save and find checkpoints.
55
+ save_to_disk (bool): if True, save checkpoint to disk, otherwise
56
+ disable saving for this checkpointer.
57
+ checkpointables (object): any checkpointable objects, i.e., objects
58
+ that have the `state_dict()` and `load_state_dict()` method. For
59
+ example, it can be used like
60
+ `Checkpointer(model, "dir", optimizer=optimizer)`.
61
+ """
62
+ if isinstance(model, (DistributedDataParallel, DataParallel)):
63
+ model = model.module
64
+ self.model = model
65
+ self.checkpointables = copy.copy(checkpointables)
66
+ self.logger = logging.getLogger(__name__)
67
+ self.save_dir = save_dir
68
+ self.save_to_disk = save_to_disk
69
+
70
+ self.path_manager = PathManager
71
+
72
+ def save(self, name: str, **kwargs: Dict[str, str]):
73
+ """
74
+ Dump model and checkpointables to a file.
75
+
76
+ Args:
77
+ name (str): name of the file.
78
+ kwargs (dict): extra arbitrary data to save.
79
+ """
80
+ if not self.save_dir or not self.save_to_disk:
81
+ return
82
+
83
+ data = {}
84
+ data["model"] = self.model.state_dict()
85
+ for key, obj in self.checkpointables.items():
86
+ data[key] = obj.state_dict()
87
+ data.update(kwargs)
88
+
89
+ basename = "{}.pth".format(name)
90
+ save_file = os.path.join(self.save_dir, basename)
91
+ assert os.path.basename(save_file) == basename, basename
92
+ self.logger.info("Saving checkpoint to {}".format(save_file))
93
+ with PathManager.open(save_file, "wb") as f:
94
+ torch.save(data, f)
95
+ self.tag_last_checkpoint(basename)
96
+
97
+ def load(self, path: str, checkpointables: Optional[List[str]] = None) -> object:
98
+ """
99
+ Load from the given checkpoint. When path points to network file, this
100
+ function has to be called on all ranks.
101
+
102
+ Args:
103
+ path (str): path or url to the checkpoint. If empty, will not load
104
+ anything.
105
+ checkpointables (list): List of checkpointable names to load. If not
106
+ specified (None), will load all the possible checkpointables.
107
+ Returns:
108
+ dict:
109
+ extra data loaded from the checkpoint that has not been
110
+ processed. For example, those saved with
111
+ :meth:`.save(**extra_data)`.
112
+ """
113
+ if not path:
114
+ # no checkpoint provided
115
+ self.logger.info("No checkpoint found. Training model from scratch")
116
+ return {}
117
+ self.logger.info("Loading checkpoint from {}".format(path))
118
+ if not os.path.isfile(path):
119
+ path = self.path_manager.get_local_path(path)
120
+ assert os.path.isfile(path), "Checkpoint {} not found!".format(path)
121
+
122
+ checkpoint = self._load_file(path)
123
+ incompatible = self._load_model(checkpoint)
124
+ if (
125
+ incompatible is not None
126
+ ): # handle some existing subclasses that returns None
127
+ self._log_incompatible_keys(incompatible)
128
+
129
+ for key in self.checkpointables if checkpointables is None else checkpointables:
130
+ if key in checkpoint: # pyre-ignore
131
+ self.logger.info("Loading {} from {}".format(key, path))
132
+ obj = self.checkpointables[key]
133
+ obj.load_state_dict(checkpoint.pop(key)) # pyre-ignore
134
+
135
+ # return any further checkpoint data
136
+ return checkpoint
137
+
138
+ def has_checkpoint(self):
139
+ """
140
+ Returns:
141
+ bool: whether a checkpoint exists in the target directory.
142
+ """
143
+ save_file = os.path.join(self.save_dir, "last_checkpoint")
144
+ return PathManager.exists(save_file)
145
+
146
+ def get_checkpoint_file(self):
147
+ """
148
+ Returns:
149
+ str: The latest checkpoint file in target directory.
150
+ """
151
+ save_file = os.path.join(self.save_dir, "last_checkpoint")
152
+ try:
153
+ with PathManager.open(save_file, "r") as f:
154
+ last_saved = f.read().strip()
155
+ except IOError:
156
+ # if file doesn't exist, maybe because it has just been
157
+ # deleted by a separate process
158
+ return ""
159
+ return os.path.join(self.save_dir, last_saved)
160
+
161
+ def get_all_checkpoint_files(self):
162
+ """
163
+ Returns:
164
+ list: All available checkpoint files (.pth files) in target
165
+ directory.
166
+ """
167
+ all_model_checkpoints = [
168
+ os.path.join(self.save_dir, file)
169
+ for file in PathManager.ls(self.save_dir)
170
+ if PathManager.isfile(os.path.join(self.save_dir, file))
171
+ and file.endswith(".pth")
172
+ ]
173
+ return all_model_checkpoints
174
+
175
+ def resume_or_load(self, path: str, *, resume: bool = True):
176
+ """
177
+ If `resume` is True, this method attempts to resume from the last
178
+ checkpoint, if exists. Otherwise, load checkpoint from the given path.
179
+ This is useful when restarting an interrupted training job.
180
+
181
+ Args:
182
+ path (str): path to the checkpoint.
183
+ resume (bool): if True, resume from the last checkpoint if it exists.
184
+ Returns:
185
+ same as :meth:`load`.
186
+ """
187
+ if resume and self.has_checkpoint():
188
+ path = self.get_checkpoint_file()
189
+ return self.load(path)
190
+ else:
191
+ return self.load(path, checkpointables=[])
192
+
193
+ def tag_last_checkpoint(self, last_filename_basename: str):
194
+ """
195
+ Tag the last checkpoint.
196
+
197
+ Args:
198
+ last_filename_basename (str): the basename of the last filename.
199
+ """
200
+ save_file = os.path.join(self.save_dir, "last_checkpoint")
201
+ with PathManager.open(save_file, "w") as f:
202
+ f.write(last_filename_basename)
203
+
204
+ def _load_file(self, f: str):
205
+ """
206
+ Load a checkpoint file. Can be overwritten by subclasses to support
207
+ different formats.
208
+
209
+ Args:
210
+ f (str): a locally mounted file path.
211
+ Returns:
212
+ dict: with keys "model" and optionally others that are saved by
213
+ the checkpointer dict["model"] must be a dict which maps strings
214
+ to torch.Tensor or numpy arrays.
215
+ """
216
+ return torch.load(f, map_location=torch.device("cpu"))
217
+
218
+ def _load_model(self, checkpoint: Any):
219
+ """
220
+ Load weights from a checkpoint.
221
+
222
+ Args:
223
+ checkpoint (Any): checkpoint contains the weights.
224
+ """
225
+ checkpoint_state_dict = checkpoint.pop("model")
226
+ self._convert_ndarray_to_tensor(checkpoint_state_dict)
227
+
228
+ # if the state_dict comes from a model that was wrapped in a
229
+ # DataParallel or DistributedDataParallel during serialization,
230
+ # remove the "module" prefix before performing the matching.
231
+ _strip_prefix_if_present(checkpoint_state_dict, "module.")
232
+
233
+ # work around https://github.com/pytorch/pytorch/issues/24139
234
+ model_state_dict = self.model.state_dict()
235
+ incorrect_shapes = []
236
+ for k in list(checkpoint_state_dict.keys()):
237
+ if k in model_state_dict:
238
+ shape_model = tuple(model_state_dict[k].shape)
239
+ shape_checkpoint = tuple(checkpoint_state_dict[k].shape)
240
+ if shape_model != shape_checkpoint:
241
+ incorrect_shapes.append((k, shape_checkpoint, shape_model))
242
+ checkpoint_state_dict.pop(k)
243
+
244
+ incompatible = self.model.load_state_dict(checkpoint_state_dict, strict=False)
245
+ return _IncompatibleKeys(
246
+ missing_keys=incompatible.missing_keys,
247
+ unexpected_keys=incompatible.unexpected_keys,
248
+ incorrect_shapes=incorrect_shapes,
249
+ )
250
+
251
+ def _log_incompatible_keys(self, incompatible: _IncompatibleKeys) -> None:
252
+ """
253
+ Log information about the incompatible keys returned by ``_load_model``.
254
+ """
255
+ for k, shape_checkpoint, shape_model in incompatible.incorrect_shapes:
256
+ self.logger.warning(
257
+ "Skip loading parameter '{}' to the model due to incompatible "
258
+ "shapes: {} in the checkpoint but {} in the "
259
+ "model! You might want to double check if this is expected.".format(
260
+ k, shape_checkpoint, shape_model
261
+ )
262
+ )
263
+ if incompatible.missing_keys:
264
+ missing_keys = _filter_reused_missing_keys(
265
+ self.model, incompatible.missing_keys
266
+ )
267
+ if missing_keys:
268
+ self.logger.info(get_missing_parameters_message(missing_keys))
269
+ if incompatible.unexpected_keys:
270
+ self.logger.info(
271
+ get_unexpected_parameters_message(incompatible.unexpected_keys)
272
+ )
273
+
274
+ def _convert_ndarray_to_tensor(self, state_dict: dict):
275
+ """
276
+ In-place convert all numpy arrays in the state_dict to torch tensor.
277
+
278
+ Args:
279
+ state_dict (dict): a state-dict to be loaded to the model.
280
+ """
281
+ # model could be an OrderedDict with _metadata attribute
282
+ # (as returned by Pytorch's state_dict()). We should preserve these
283
+ # properties.
284
+ for k in list(state_dict.keys()):
285
+ v = state_dict[k]
286
+ if not isinstance(v, np.ndarray) and not isinstance(
287
+ v, torch.Tensor
288
+ ):
289
+ raise ValueError(
290
+ "Unsupported type found in checkpoint! {}: {}".format(
291
+ k, type(v)
292
+ )
293
+ )
294
+ if not isinstance(v, torch.Tensor):
295
+ state_dict[k] = torch.from_numpy(v)
296
+
297
+
298
+ class PeriodicCheckpointer:
299
+ """
300
+ Save checkpoints periodically. When `.step(iteration)` is called, it will
301
+ execute `checkpointer.save` on the given checkpointer, if iteration is a
302
+ multiple of period or if `max_iter` is reached.
303
+ """
304
+
305
+ def __init__(self, checkpointer: Any, period: int, max_epoch: int = None):
306
+ """
307
+ Args:
308
+ checkpointer (Any): the checkpointer object used to save
309
+ checkpoints.
310
+ period (int): the period to save checkpoint.
311
+ max_epoch (int): maximum number of epochs. When it is reached,
312
+ a checkpoint named "model_final" will be saved.
313
+ """
314
+ self.checkpointer = checkpointer
315
+ self.period = int(period)
316
+ self.max_epoch = max_epoch
317
+ self.best_metric = -1
318
+
319
+ def step(self, epoch: int, **kwargs: Any):
320
+ """
321
+ Perform the appropriate action at the given iteration.
322
+
323
+ Args:
324
+ epoch (int): the current epoch, ranged in [0, max_epoch-1].
325
+ kwargs (Any): extra data to save, same as in
326
+ :meth:`Checkpointer.save`.
327
+ """
328
+ epoch = int(epoch)
329
+ additional_state = {"epoch": epoch}
330
+ additional_state.update(kwargs)
331
+ if (epoch + 1) % self.period == 0 and epoch < self.max_epoch - 1:
332
+ if additional_state["metric"] > self.best_metric:
333
+ self.checkpointer.save(
334
+ "model_best", **additional_state
335
+ )
336
+ self.best_metric = additional_state["metric"]
337
+ # Put it behind best model save to make last checkpoint valid
338
+ self.checkpointer.save(
339
+ "model_{:04d}".format(epoch), **additional_state
340
+ )
341
+ if epoch >= self.max_epoch - 1:
342
+ if additional_state["metric"] > self.best_metric:
343
+ self.checkpointer.save(
344
+ "model_best", **additional_state
345
+ )
346
+ self.checkpointer.save("model_final", **additional_state)
347
+
348
+ def save(self, name: str, **kwargs: Any):
349
+ """
350
+ Same argument as :meth:`Checkpointer.save`.
351
+ Use this method to manually save checkpoints outside the schedule.
352
+
353
+ Args:
354
+ name (str): file name.
355
+ kwargs (Any): extra data to save, same as in
356
+ :meth:`Checkpointer.save`.
357
+ """
358
+ self.checkpointer.save(name, **kwargs)
359
+
360
+
361
+ def _filter_reused_missing_keys(model: nn.Module, keys: List[str]) -> List[str]:
362
+ """
363
+ Filter "missing keys" to not include keys that have been loaded with another name.
364
+ """
365
+ keyset = set(keys)
366
+ param_to_names = defaultdict(set) # param -> names that points to it
367
+ for module_prefix, module in _named_modules_with_dup(model):
368
+ for name, param in list(module.named_parameters(recurse=False)) + list(
369
+ module.named_buffers(recurse=False) # pyre-ignore
370
+ ):
371
+ full_name = (module_prefix + "." if module_prefix else "") + name
372
+ param_to_names[param].add(full_name)
373
+ for names in param_to_names.values():
374
+ # if one name appears missing but its alias exists, then this
375
+ # name is not considered missing
376
+ if any(n in keyset for n in names) and not all(n in keyset for n in names):
377
+ [keyset.remove(n) for n in names if n in keyset]
378
+ return list(keyset)
379
+
380
+
381
+ def get_missing_parameters_message(keys: List[str]) -> str:
382
+ """
383
+ Get a logging-friendly message to report parameter names (keys) that are in
384
+ the model but not found in a checkpoint.
385
+
386
+ Args:
387
+ keys (list[str]): List of keys that were not found in the checkpoint.
388
+ Returns:
389
+ str: message.
390
+ """
391
+ groups = _group_checkpoint_keys(keys)
392
+ msg = "Some model parameters or buffers are not found in the checkpoint:\n"
393
+ msg += "\n".join(
394
+ " " + colored(k + _group_to_str(v), "blue") for k, v in groups.items()
395
+ )
396
+ return msg
397
+
398
+
399
+ def get_unexpected_parameters_message(keys: List[str]) -> str:
400
+ """
401
+ Get a logging-friendly message to report parameter names (keys) that are in
402
+ the checkpoint but not found in the model.
403
+
404
+ Args:
405
+ keys (list[str]): List of keys that were not found in the model.
406
+ Returns:
407
+ str: message.
408
+ """
409
+ groups = _group_checkpoint_keys(keys)
410
+ msg = "The checkpoint state_dict contains keys that are not used by the model:\n"
411
+ msg += "\n".join(
412
+ " " + colored(k + _group_to_str(v), "magenta") for k, v in groups.items()
413
+ )
414
+ return msg
415
+
416
+
417
+ def _strip_prefix_if_present(state_dict: Dict[str, Any], prefix: str) -> None:
418
+ """
419
+ Strip the prefix in metadata, if any.
420
+
421
+ Args:
422
+ state_dict (OrderedDict): a state-dict to be loaded to the model.
423
+ prefix (str): prefix.
424
+ """
425
+ keys = sorted(state_dict.keys())
426
+ if not all(len(key) == 0 or key.startswith(prefix) for key in keys):
427
+ return
428
+
429
+ for key in keys:
430
+ newkey = key[len(prefix):]
431
+ state_dict[newkey] = state_dict.pop(key)
432
+
433
+ # also strip the prefix in metadata, if any..
434
+ try:
435
+ metadata = state_dict._metadata # pyre-ignore
436
+ except AttributeError:
437
+ pass
438
+ else:
439
+ for key in list(metadata.keys()):
440
+ # for the metadata dict, the key can be:
441
+ # '': for the DDP module, which we want to remove.
442
+ # 'module': for the actual model.
443
+ # 'module.xx.xx': for the rest.
444
+
445
+ if len(key) == 0:
446
+ continue
447
+ newkey = key[len(prefix):]
448
+ metadata[newkey] = metadata.pop(key)
449
+
450
+
451
+ def _group_checkpoint_keys(keys: List[str]) -> Dict[str, List[str]]:
452
+ """
453
+ Group keys based on common prefixes. A prefix is the string up to the final
454
+ "." in each key.
455
+
456
+ Args:
457
+ keys (list[str]): list of parameter names, i.e. keys in the model
458
+ checkpoint dict.
459
+ Returns:
460
+ dict[list]: keys with common prefixes are grouped into lists.
461
+ """
462
+ groups = defaultdict(list)
463
+ for key in keys:
464
+ pos = key.rfind(".")
465
+ if pos >= 0:
466
+ head, tail = key[:pos], [key[pos + 1:]]
467
+ else:
468
+ head, tail = key, []
469
+ groups[head].extend(tail)
470
+ return groups
471
+
472
+
473
+ def _group_to_str(group: List[str]) -> str:
474
+ """
475
+ Format a group of parameter name suffixes into a loggable string.
476
+
477
+ Args:
478
+ group (list[str]): list of parameter name suffixes.
479
+ Returns:
480
+ str: formated string.
481
+ """
482
+ if len(group) == 0:
483
+ return ""
484
+
485
+ if len(group) == 1:
486
+ return "." + group[0]
487
+
488
+ return ".{" + ", ".join(group) + "}"
489
+
490
+
491
+ def _named_modules_with_dup(
492
+ model: nn.Module, prefix: str = ""
493
+ ) -> Iterable[Tuple[str, nn.Module]]:
494
+ """
495
+ The same as `model.named_modules()`, except that it includes
496
+ duplicated modules that have more than one name.
497
+ """
498
+ yield prefix, model
499
+ for name, module in model._modules.items(): # pyre-ignore
500
+ if module is None:
501
+ continue
502
+ submodule_prefix = prefix + ("." if prefix else "") + name
503
+ yield from _named_modules_with_dup(module, submodule_prefix)
@@ -0,0 +1,158 @@
1
+ # encoding: utf-8
2
+ """
3
+ @author: xingyu liao
4
+ @contact: sherlockliao01@gmail.com
5
+ """
6
+
7
+ # based on
8
+ # https://github.com/facebookresearch/detectron2/blob/master/detectron2/utils/collect_env.py
9
+ import importlib
10
+ import os
11
+ import re
12
+ import subprocess
13
+ import sys
14
+ from collections import defaultdict
15
+
16
+ import PIL
17
+ import numpy as np
18
+ import torch
19
+ import torchvision
20
+ from tabulate import tabulate
21
+
22
+ __all__ = ["collect_env_info"]
23
+
24
+
25
+ def collect_torch_env():
26
+ try:
27
+ import torch.__config__
28
+
29
+ return torch.__config__.show()
30
+ except ImportError:
31
+ # compatible with older versions of pytorch
32
+ from torch.utils.collect_env import get_pretty_env_info
33
+
34
+ return get_pretty_env_info()
35
+
36
+
37
+ def get_env_module():
38
+ var_name = "FASTREID_ENV_MODULE"
39
+ return var_name, os.environ.get(var_name, "<not set>")
40
+
41
+
42
+ def detect_compute_compatibility(CUDA_HOME, so_file):
43
+ try:
44
+ cuobjdump = os.path.join(CUDA_HOME, "bin", "cuobjdump")
45
+ if os.path.isfile(cuobjdump):
46
+ output = subprocess.check_output(
47
+ "'{}' --list-elf '{}'".format(cuobjdump, so_file), shell=True
48
+ )
49
+ output = output.decode("utf-8").strip().split("\n")
50
+ sm = []
51
+ for line in output:
52
+ line = re.findall(r"\.sm_[0-9]*\.", line)[0]
53
+ sm.append(line.strip("."))
54
+ sm = sorted(set(sm))
55
+ return ", ".join(sm)
56
+ else:
57
+ return so_file + "; cannot find cuobjdump"
58
+ except Exception:
59
+ # unhandled failure
60
+ return so_file
61
+
62
+
63
+ def collect_env_info():
64
+ has_gpu = torch.cuda.is_available() # true for both CUDA & ROCM
65
+ torch_version = torch.__version__
66
+
67
+ # NOTE: the use of CUDA_HOME and ROCM_HOME requires the CUDA/ROCM build deps, though in
68
+ # theory detectron2 should be made runnable with only the corresponding runtimes
69
+ from torch.utils.cpp_extension import CUDA_HOME
70
+
71
+ has_rocm = False
72
+ if tuple(map(int, torch_version.split(".")[:2])) >= (1, 5):
73
+ from torch.utils.cpp_extension import ROCM_HOME
74
+
75
+ if (getattr(torch.version, "hip", None) is not None) and (ROCM_HOME is not None):
76
+ has_rocm = True
77
+ has_cuda = has_gpu and (not has_rocm)
78
+
79
+ data = []
80
+ data.append(("sys.platform", sys.platform))
81
+ data.append(("Python", sys.version.replace("\n", "")))
82
+ data.append(("numpy", np.__version__))
83
+
84
+ try:
85
+ import fastreid # noqa
86
+
87
+ data.append(
88
+ ("fastreid", fastreid.__version__ + " @" + os.path.dirname(fastreid.__file__))
89
+ )
90
+ except ImportError:
91
+ data.append(("fastreid", "failed to import"))
92
+
93
+ data.append(get_env_module())
94
+ data.append(("PyTorch", torch_version + " @" + os.path.dirname(torch.__file__)))
95
+ data.append(("PyTorch debug build", torch.version.debug))
96
+
97
+ data.append(("GPU available", has_gpu))
98
+ if has_gpu:
99
+ devices = defaultdict(list)
100
+ for k in range(torch.cuda.device_count()):
101
+ devices[torch.cuda.get_device_name(k)].append(str(k))
102
+ for name, devids in devices.items():
103
+ data.append(("GPU " + ",".join(devids), name))
104
+
105
+ if has_rocm:
106
+ data.append(("ROCM_HOME", str(ROCM_HOME)))
107
+ else:
108
+ data.append(("CUDA_HOME", str(CUDA_HOME)))
109
+
110
+ cuda_arch_list = os.environ.get("TORCH_CUDA_ARCH_LIST", None)
111
+ if cuda_arch_list:
112
+ data.append(("TORCH_CUDA_ARCH_LIST", cuda_arch_list))
113
+ data.append(("Pillow", PIL.__version__))
114
+
115
+ try:
116
+ data.append(
117
+ (
118
+ "torchvision",
119
+ str(torchvision.__version__) + " @" + os.path.dirname(torchvision.__file__),
120
+ )
121
+ )
122
+ if has_cuda:
123
+ try:
124
+ torchvision_C = importlib.util.find_spec("torchvision._C").origin
125
+ msg = detect_compute_compatibility(CUDA_HOME, torchvision_C)
126
+ data.append(("torchvision arch flags", msg))
127
+ except ImportError:
128
+ data.append(("torchvision._C", "failed to find"))
129
+ except AttributeError:
130
+ data.append(("torchvision", "unknown"))
131
+
132
+ try:
133
+ import fvcore
134
+
135
+ data.append(("fvcore", fvcore.__version__))
136
+ except ImportError:
137
+ pass
138
+
139
+ try:
140
+ import cv2
141
+
142
+ data.append(("cv2", cv2.__version__))
143
+ except ImportError:
144
+ pass
145
+ env_str = tabulate(data) + "\n"
146
+ env_str += collect_torch_env()
147
+ return env_str
148
+
149
+
150
+ if __name__ == "__main__":
151
+ try:
152
+ import detectron2 # noqa
153
+ except ImportError:
154
+ print(collect_env_info())
155
+ else:
156
+ from fastreid.utils.collect_env import collect_env_info
157
+
158
+ print(collect_env_info())