dnt 0.2.4__py3-none-any.whl → 0.3.1.7__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 (311) hide show
  1. dnt/__init__.py +3 -2
  2. dnt/analysis/__init__.py +3 -2
  3. dnt/analysis/count.py +54 -37
  4. dnt/analysis/interaction2.py +518 -0
  5. dnt/analysis/stop.py +22 -17
  6. dnt/analysis/stop2.py +289 -0
  7. dnt/analysis/stop3.py +758 -0
  8. dnt/detect/signal/detector.py +326 -0
  9. dnt/detect/timestamp.py +105 -0
  10. dnt/detect/yolov8/detector.py +179 -36
  11. dnt/detect/yolov8/segmentor.py +60 -2
  12. dnt/engine/__init__.py +8 -0
  13. dnt/engine/bbox_interp.py +83 -0
  14. dnt/engine/bbox_iou.py +20 -0
  15. dnt/engine/cluster.py +31 -0
  16. dnt/engine/iob.py +66 -0
  17. dnt/filter/filter.py +333 -2
  18. dnt/label/labeler.py +4 -4
  19. dnt/label/labeler2.py +605 -0
  20. dnt/shared/__init__.py +2 -1
  21. dnt/shared/data/coco.names +0 -0
  22. dnt/shared/data/openimages.names +0 -0
  23. dnt/shared/data/voc.names +0 -0
  24. dnt/shared/download.py +12 -0
  25. dnt/shared/synhcro.py +150 -0
  26. dnt/shared/util.py +17 -4
  27. dnt/third_party/fast-reid/__init__.py +1 -0
  28. dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
  29. dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
  30. dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
  31. dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
  32. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
  33. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
  34. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
  35. dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
  36. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
  37. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
  38. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
  39. dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
  40. dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
  41. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
  42. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
  43. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
  44. dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
  45. dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
  46. dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
  47. dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
  48. dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
  49. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
  50. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
  51. dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
  52. dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
  53. dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
  54. dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
  55. dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
  56. dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
  57. dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
  58. dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
  59. dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
  60. dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
  61. dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
  62. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
  63. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
  64. dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
  65. dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
  66. dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
  67. dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
  68. dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
  69. dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
  70. dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
  71. dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
  72. dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
  73. dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
  74. dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
  75. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
  76. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
  77. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
  78. dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
  79. dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
  80. dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
  81. dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
  82. dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
  83. dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
  84. dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
  85. dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
  86. dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
  87. dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
  88. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
  89. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
  90. dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
  91. dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
  92. dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
  93. dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
  94. dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
  95. dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
  96. dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
  97. dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
  98. dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
  99. dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
  100. dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
  101. dnt/third_party/fast-reid/configs/__init__.py +0 -0
  102. dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
  103. dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
  104. dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
  105. dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
  106. dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
  107. dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
  108. dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
  109. dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
  110. dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
  111. dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
  112. dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
  113. dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
  114. dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
  115. dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
  116. dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
  117. dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
  118. dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
  119. dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
  120. dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
  121. dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
  122. dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
  123. dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
  124. dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
  125. dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
  126. dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
  127. dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
  128. dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
  129. dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
  130. dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
  131. dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
  132. dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
  133. dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
  134. dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
  135. dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
  136. dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
  137. dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
  138. dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
  139. dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
  140. dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
  141. dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
  142. dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
  143. dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
  144. dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
  145. dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
  146. dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
  147. dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
  148. dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
  149. dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
  150. dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
  151. dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
  152. dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
  153. dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
  154. dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
  155. dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
  156. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
  157. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
  158. dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
  159. dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
  160. dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
  161. dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
  162. dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
  163. dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
  164. dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
  165. dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
  166. dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
  167. dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
  168. dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
  169. dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
  170. dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
  171. dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
  172. dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
  173. dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
  174. dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
  175. dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
  176. dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
  177. dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
  178. dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
  179. dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
  180. dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
  181. dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
  182. dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
  183. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
  184. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
  185. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
  186. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
  187. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
  188. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
  189. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
  190. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
  191. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
  192. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
  193. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
  194. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
  195. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
  196. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
  197. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
  198. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
  199. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
  200. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
  201. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
  202. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
  203. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
  204. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
  205. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
  206. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
  207. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
  208. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
  209. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
  210. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
  211. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
  212. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
  213. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
  214. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
  215. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
  216. dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
  217. dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
  218. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
  219. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
  220. dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
  221. dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
  222. dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
  223. dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
  224. dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
  225. dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
  226. dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
  227. dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
  228. dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
  229. dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
  230. dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
  231. dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
  232. dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
  233. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
  234. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
  235. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
  236. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
  237. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
  238. dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
  239. dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
  240. dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
  241. dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
  242. dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
  243. dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
  244. dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
  245. dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
  246. dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
  247. dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
  248. dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
  249. dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
  250. dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
  251. dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
  252. dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
  253. dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
  254. dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
  255. dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
  256. dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
  257. dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
  258. dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
  259. dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
  260. dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
  261. dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
  262. dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
  263. dnt/track/__init__.py +2 -0
  264. dnt/track/botsort/__init__.py +4 -0
  265. dnt/track/botsort/bot_tracker/__init__.py +3 -0
  266. dnt/track/botsort/bot_tracker/basetrack.py +60 -0
  267. dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
  268. dnt/track/botsort/bot_tracker/gmc.py +316 -0
  269. dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
  270. dnt/track/botsort/bot_tracker/matching.py +194 -0
  271. dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
  272. dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
  273. dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
  274. dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
  275. dnt/track/botsort/inference.py +96 -0
  276. dnt/track/config.py +120 -0
  277. dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
  278. dnt/track/dsort/configs/deep_sort.yaml +0 -0
  279. dnt/track/dsort/configs/fastreid.yaml +1 -1
  280. dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
  281. dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
  282. dnt/track/dsort/deep_sort/deep_sort.py +31 -20
  283. dnt/track/dsort/deep_sort/sort/detection.py +2 -1
  284. dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
  285. dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
  286. dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
  287. dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
  288. dnt/track/dsort/deep_sort/sort/track.py +2 -1
  289. dnt/track/dsort/deep_sort/sort/tracker.py +1 -1
  290. dnt/track/dsort/dsort.py +43 -33
  291. dnt/track/re_class.py +117 -0
  292. dnt/track/sort/sort.py +9 -6
  293. dnt/track/tracker.py +213 -32
  294. {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/METADATA +41 -13
  295. dnt-0.3.1.7.dist-info/RECORD +315 -0
  296. {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/WHEEL +1 -1
  297. dnt/analysis/yield.py +0 -9
  298. dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
  299. dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
  300. dnt/track/dsort/deep_sort/deep/test.py +0 -77
  301. dnt/track/dsort/deep_sort/deep/train.py +0 -189
  302. dnt/track/dsort/utils/asserts.py +0 -13
  303. dnt/track/dsort/utils/draw.py +0 -36
  304. dnt/track/dsort/utils/json_logger.py +0 -383
  305. dnt/track/dsort/utils/log.py +0 -17
  306. dnt/track/dsort/utils/parser.py +0 -35
  307. dnt/track/dsort/utils/tools.py +0 -39
  308. dnt-0.2.4.dist-info/RECORD +0 -64
  309. /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
  310. {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info/licenses}/LICENSE +0 -0
  311. {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,596 @@
1
+ import logging
2
+ import math
3
+
4
+ import numpy as np
5
+ import torch
6
+ import torch.nn as nn
7
+
8
+ from fastreid.layers import get_norm
9
+ from fastreid.utils import comm
10
+ from fastreid.utils.checkpoint import get_missing_parameters_message, get_unexpected_parameters_message
11
+ from .config import cfg as regnet_cfg
12
+ from ..build import BACKBONE_REGISTRY
13
+
14
+ logger = logging.getLogger(__name__)
15
+ model_urls = {
16
+ '800x': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160905981/RegNetX-200MF_dds_8gpu.pyth',
17
+ '800y': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160906567/RegNetY-800MF_dds_8gpu.pyth',
18
+ '1600x': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160990626/RegNetX-1.6GF_dds_8gpu.pyth',
19
+ '1600y': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160906681/RegNetY-1.6GF_dds_8gpu.pyth',
20
+ '3200x': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160906139/RegNetX-3.2GF_dds_8gpu.pyth',
21
+ '3200y': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160906834/RegNetY-3.2GF_dds_8gpu.pyth',
22
+ '4000x': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160906383/RegNetX-4.0GF_dds_8gpu.pyth',
23
+ '4000y': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160906838/RegNetY-4.0GF_dds_8gpu.pyth',
24
+ '6400x': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/161116590/RegNetX-6.4GF_dds_8gpu.pyth',
25
+ '6400y': 'https://dl.fbaipublicfiles.com/pycls/dds_baselines/160907112/RegNetY-6.4GF_dds_8gpu.pyth',
26
+ }
27
+
28
+
29
+ def init_weights(m):
30
+ """Performs ResNet-style weight initialization."""
31
+ if isinstance(m, nn.Conv2d):
32
+ # Note that there is no bias due to BN
33
+ fan_out = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
34
+ m.weight.data.normal_(mean=0.0, std=math.sqrt(2.0 / fan_out))
35
+ elif isinstance(m, nn.BatchNorm2d):
36
+ zero_init_gamma = (
37
+ hasattr(m, "final_bn") and m.final_bn and regnet_cfg.BN.ZERO_INIT_FINAL_GAMMA
38
+ )
39
+ m.weight.data.fill_(0.0 if zero_init_gamma else 1.0)
40
+ m.bias.data.zero_()
41
+ elif isinstance(m, nn.Linear):
42
+ m.weight.data.normal_(mean=0.0, std=0.01)
43
+ m.bias.data.zero_()
44
+
45
+
46
+ def get_stem_fun(stem_type):
47
+ """Retrives the stem function by name."""
48
+ stem_funs = {
49
+ "res_stem_cifar": ResStemCifar,
50
+ "res_stem_in": ResStemIN,
51
+ "simple_stem_in": SimpleStemIN,
52
+ }
53
+ assert stem_type in stem_funs.keys(), "Stem type '{}' not supported".format(
54
+ stem_type
55
+ )
56
+ return stem_funs[stem_type]
57
+
58
+
59
+ def get_block_fun(block_type):
60
+ """Retrieves the block function by name."""
61
+ block_funs = {
62
+ "vanilla_block": VanillaBlock,
63
+ "res_basic_block": ResBasicBlock,
64
+ "res_bottleneck_block": ResBottleneckBlock,
65
+ }
66
+ assert block_type in block_funs.keys(), "Block type '{}' not supported".format(
67
+ block_type
68
+ )
69
+ return block_funs[block_type]
70
+
71
+
72
+ def drop_connect(x, drop_ratio):
73
+ """Drop connect (adapted from DARTS)."""
74
+ keep_ratio = 1.0 - drop_ratio
75
+ mask = torch.empty([x.shape[0], 1, 1, 1], dtype=x.dtype, device=x.device)
76
+ mask.bernoulli_(keep_ratio)
77
+ x.div_(keep_ratio)
78
+ x.mul_(mask)
79
+ return x
80
+
81
+ class AnyHead(nn.Module):
82
+ """AnyNet head."""
83
+
84
+ def __init__(self, w_in, nc):
85
+ super(AnyHead, self).__init__()
86
+ self.avg_pool = nn.AdaptiveAvgPool2d((1, 1))
87
+ self.fc = nn.Linear(w_in, nc, bias=True)
88
+
89
+ def forward(self, x):
90
+ x = self.avg_pool(x)
91
+ x = x.view(x.size(0), -1)
92
+ x = self.fc(x)
93
+ return x
94
+
95
+
96
+ class VanillaBlock(nn.Module):
97
+ """Vanilla block: [3x3 conv, BN, Relu] x2"""
98
+
99
+ def __init__(self, w_in, w_out, stride, bn_norm, bm=None, gw=None, se_r=None):
100
+ assert (
101
+ bm is None and gw is None and se_r is None
102
+ ), "Vanilla block does not support bm, gw, and se_r options"
103
+ super(VanillaBlock, self).__init__()
104
+ self.construct(w_in, w_out, stride, bn_norm)
105
+
106
+ def construct(self, w_in, w_out, stride, bn_norm):
107
+ # 3x3, BN, ReLU
108
+ self.a = nn.Conv2d(
109
+ w_in, w_out, kernel_size=3, stride=stride, padding=1, bias=False
110
+ )
111
+ self.a_bn = get_norm(bn_norm, w_out)
112
+ self.a_relu = nn.ReLU(inplace=regnet_cfg.MEM.RELU_INPLACE)
113
+ # 3x3, BN, ReLU
114
+ self.b = nn.Conv2d(w_out, w_out, kernel_size=3, stride=1, padding=1, bias=False)
115
+ self.b_bn = get_norm(bn_norm, w_out)
116
+ self.b_relu = nn.ReLU(inplace=regnet_cfg.MEM.RELU_INPLACE)
117
+
118
+ def forward(self, x):
119
+ for layer in self.children():
120
+ x = layer(x)
121
+ return x
122
+
123
+
124
+ class BasicTransform(nn.Module):
125
+ """Basic transformation: [3x3 conv, BN, Relu] x2"""
126
+
127
+ def __init__(self, w_in, w_out, stride, bn_norm):
128
+ super(BasicTransform, self).__init__()
129
+ self.construct(w_in, w_out, stride, bn_norm)
130
+
131
+ def construct(self, w_in, w_out, stride, bn_norm):
132
+ # 3x3, BN, ReLU
133
+ self.a = nn.Conv2d(
134
+ w_in, w_out, kernel_size=3, stride=stride, padding=1, bias=False
135
+ )
136
+ self.a_bn = get_norm(bn_norm, w_out)
137
+ self.a_relu = nn.ReLU(inplace=regnet_cfg.MEM.RELU_INPLACE)
138
+ # 3x3, BN
139
+ self.b = nn.Conv2d(w_out, w_out, kernel_size=3, stride=1, padding=1, bias=False)
140
+ self.b_bn = get_norm(bn_norm, w_out)
141
+ self.b_bn.final_bn = True
142
+
143
+ def forward(self, x):
144
+ for layer in self.children():
145
+ x = layer(x)
146
+ return x
147
+
148
+
149
+ class ResBasicBlock(nn.Module):
150
+ """Residual basic block: x + F(x), F = basic transform"""
151
+
152
+ def __init__(self, w_in, w_out, stride, bn_norm, bm=None, gw=None, se_r=None):
153
+ assert (
154
+ bm is None and gw is None and se_r is None
155
+ ), "Basic transform does not support bm, gw, and se_r options"
156
+ super(ResBasicBlock, self).__init__()
157
+ self.construct(w_in, w_out, stride, bn_norm)
158
+
159
+ def _add_skip_proj(self, w_in, w_out, stride, bn_norm):
160
+ self.proj = nn.Conv2d(
161
+ w_in, w_out, kernel_size=1, stride=stride, padding=0, bias=False
162
+ )
163
+ self.bn = get_norm(bn_norm, w_out)
164
+
165
+ def construct(self, w_in, w_out, stride, bn_norm):
166
+ # Use skip connection with projection if shape changes
167
+ self.proj_block = (w_in != w_out) or (stride != 1)
168
+ if self.proj_block:
169
+ self._add_skip_proj(w_in, w_out, stride, bn_norm)
170
+ self.f = BasicTransform(w_in, w_out, stride, bn_norm)
171
+ self.relu = nn.ReLU(regnet_cfg.MEM.RELU_INPLACE)
172
+
173
+ def forward(self, x):
174
+ if self.proj_block:
175
+ x = self.bn(self.proj(x)) + self.f(x)
176
+ else:
177
+ x = x + self.f(x)
178
+ x = self.relu(x)
179
+ return x
180
+
181
+
182
+ class SE(nn.Module):
183
+ """Squeeze-and-Excitation (SE) block"""
184
+
185
+ def __init__(self, w_in, w_se):
186
+ super(SE, self).__init__()
187
+ self.construct(w_in, w_se)
188
+
189
+ def construct(self, w_in, w_se):
190
+ # AvgPool
191
+ self.avg_pool = nn.AdaptiveAvgPool2d((1, 1))
192
+ # FC, Activation, FC, Sigmoid
193
+ self.f_ex = nn.Sequential(
194
+ nn.Conv2d(w_in, w_se, kernel_size=1, bias=True),
195
+ nn.ReLU(inplace=regnet_cfg.MEM.RELU_INPLACE),
196
+ nn.Conv2d(w_se, w_in, kernel_size=1, bias=True),
197
+ nn.Sigmoid(),
198
+ )
199
+
200
+ def forward(self, x):
201
+ return x * self.f_ex(self.avg_pool(x))
202
+
203
+
204
+ class BottleneckTransform(nn.Module):
205
+ """Bottlenect transformation: 1x1, 3x3, 1x1"""
206
+
207
+ def __init__(self, w_in, w_out, stride, bn_norm, bm, gw, se_r):
208
+ super(BottleneckTransform, self).__init__()
209
+ self.construct(w_in, w_out, stride, bn_norm, bm, gw, se_r)
210
+
211
+ def construct(self, w_in, w_out, stride, bn_norm, bm, gw, se_r):
212
+ # Compute the bottleneck width
213
+ w_b = int(round(w_out * bm))
214
+ # Compute the number of groups
215
+ num_gs = w_b // gw
216
+ # 1x1, BN, ReLU
217
+ self.a = nn.Conv2d(w_in, w_b, kernel_size=1, stride=1, padding=0, bias=False)
218
+ self.a_bn = get_norm(bn_norm, w_b)
219
+ self.a_relu = nn.ReLU(inplace=regnet_cfg.MEM.RELU_INPLACE)
220
+ # 3x3, BN, ReLU
221
+ self.b = nn.Conv2d(
222
+ w_b, w_b, kernel_size=3, stride=stride, padding=1, groups=num_gs, bias=False
223
+ )
224
+ self.b_bn = get_norm(bn_norm, w_b)
225
+ self.b_relu = nn.ReLU(inplace=regnet_cfg.MEM.RELU_INPLACE)
226
+ # Squeeze-and-Excitation (SE)
227
+ if se_r:
228
+ w_se = int(round(w_in * se_r))
229
+ self.se = SE(w_b, w_se)
230
+ # 1x1, BN
231
+ self.c = nn.Conv2d(w_b, w_out, kernel_size=1, stride=1, padding=0, bias=False)
232
+ self.c_bn = get_norm(bn_norm, w_out)
233
+ self.c_bn.final_bn = True
234
+
235
+ def forward(self, x):
236
+ for layer in self.children():
237
+ x = layer(x)
238
+ return x
239
+
240
+
241
+ class ResBottleneckBlock(nn.Module):
242
+ """Residual bottleneck block: x + F(x), F = bottleneck transform"""
243
+
244
+ def __init__(self, w_in, w_out, stride, bn_norm, bm=1.0, gw=1, se_r=None):
245
+ super(ResBottleneckBlock, self).__init__()
246
+ self.construct(w_in, w_out, stride, bn_norm, bm, gw, se_r)
247
+
248
+ def _add_skip_proj(self, w_in, w_out, stride, bn_norm):
249
+ self.proj = nn.Conv2d(
250
+ w_in, w_out, kernel_size=1, stride=stride, padding=0, bias=False
251
+ )
252
+ self.bn = get_norm(bn_norm, w_out)
253
+
254
+ def construct(self, w_in, w_out, stride, bn_norm, bm, gw, se_r):
255
+ # Use skip connection with projection if shape changes
256
+ self.proj_block = (w_in != w_out) or (stride != 1)
257
+ if self.proj_block:
258
+ self._add_skip_proj(w_in, w_out, stride, bn_norm)
259
+ self.f = BottleneckTransform(w_in, w_out, stride, bn_norm, bm, gw, se_r)
260
+ self.relu = nn.ReLU(regnet_cfg.MEM.RELU_INPLACE)
261
+
262
+ def forward(self, x):
263
+ if self.proj_block:
264
+ x = self.bn(self.proj(x)) + self.f(x)
265
+ else:
266
+ x = x + self.f(x)
267
+ x = self.relu(x)
268
+ return x
269
+
270
+
271
+ class ResStemCifar(nn.Module):
272
+ """ResNet stem for CIFAR."""
273
+
274
+ def __init__(self, w_in, w_out, bn_norm):
275
+ super(ResStemCifar, self).__init__()
276
+ self.construct(w_in, w_out, bn_norm)
277
+
278
+ def construct(self, w_in, w_out, bn_norm):
279
+ # 3x3, BN, ReLU
280
+ self.conv = nn.Conv2d(
281
+ w_in, w_out, kernel_size=3, stride=1, padding=1, bias=False
282
+ )
283
+ self.bn = get_norm(bn_norm, w_out)
284
+ self.relu = nn.ReLU(regnet_cfg.MEM.RELU_INPLACE)
285
+
286
+ def forward(self, x):
287
+ for layer in self.children():
288
+ x = layer(x)
289
+ return x
290
+
291
+
292
+ class ResStemIN(nn.Module):
293
+ """ResNet stem for ImageNet."""
294
+
295
+ def __init__(self, w_in, w_out, bn_norm):
296
+ super(ResStemIN, self).__init__()
297
+ self.construct(w_in, w_out, bn_norm)
298
+
299
+ def construct(self, w_in, w_out, bn_norm):
300
+ # 7x7, BN, ReLU, maxpool
301
+ self.conv = nn.Conv2d(
302
+ w_in, w_out, kernel_size=7, stride=2, padding=3, bias=False
303
+ )
304
+ self.bn = get_norm(bn_norm, w_out)
305
+ self.relu = nn.ReLU(regnet_cfg.MEM.RELU_INPLACE)
306
+ self.pool = nn.MaxPool2d(kernel_size=3, stride=2, padding=1)
307
+
308
+ def forward(self, x):
309
+ for layer in self.children():
310
+ x = layer(x)
311
+ return x
312
+
313
+
314
+ class SimpleStemIN(nn.Module):
315
+ """Simple stem for ImageNet."""
316
+
317
+ def __init__(self, in_w, out_w, bn_norm):
318
+ super(SimpleStemIN, self).__init__()
319
+ self.construct(in_w, out_w, bn_norm)
320
+
321
+ def construct(self, in_w, out_w, bn_norm):
322
+ # 3x3, BN, ReLU
323
+ self.conv = nn.Conv2d(
324
+ in_w, out_w, kernel_size=3, stride=2, padding=1, bias=False
325
+ )
326
+ self.bn = get_norm(bn_norm, out_w)
327
+ self.relu = nn.ReLU(regnet_cfg.MEM.RELU_INPLACE)
328
+
329
+ def forward(self, x):
330
+ for layer in self.children():
331
+ x = layer(x)
332
+ return x
333
+
334
+
335
+ class AnyStage(nn.Module):
336
+ """AnyNet stage (sequence of blocks w/ the same output shape)."""
337
+
338
+ def __init__(self, w_in, w_out, stride, bn_norm, d, block_fun, bm, gw, se_r):
339
+ super(AnyStage, self).__init__()
340
+ self.construct(w_in, w_out, stride, bn_norm, d, block_fun, bm, gw, se_r)
341
+
342
+ def construct(self, w_in, w_out, stride, bn_norm, d, block_fun, bm, gw, se_r):
343
+ # Construct the blocks
344
+ for i in range(d):
345
+ # Stride and w_in apply to the first block of the stage
346
+ b_stride = stride if i == 0 else 1
347
+ b_w_in = w_in if i == 0 else w_out
348
+ # Construct the block
349
+ self.add_module(
350
+ "b{}".format(i + 1), block_fun(b_w_in, w_out, b_stride, bn_norm, bm, gw, se_r)
351
+ )
352
+
353
+ def forward(self, x):
354
+ for block in self.children():
355
+ x = block(x)
356
+ return x
357
+
358
+
359
+ class AnyNet(nn.Module):
360
+ """AnyNet model."""
361
+
362
+ def __init__(self, **kwargs):
363
+ super(AnyNet, self).__init__()
364
+ if kwargs:
365
+ self.construct(
366
+ stem_type=kwargs["stem_type"],
367
+ stem_w=kwargs["stem_w"],
368
+ block_type=kwargs["block_type"],
369
+ ds=kwargs["ds"],
370
+ ws=kwargs["ws"],
371
+ ss=kwargs["ss"],
372
+ bn_norm=kwargs["bn_norm"],
373
+ bms=kwargs["bms"],
374
+ gws=kwargs["gws"],
375
+ se_r=kwargs["se_r"],
376
+ )
377
+ else:
378
+ self.construct(
379
+ stem_type=regnet_cfg.ANYNET.STEM_TYPE,
380
+ stem_w=regnet_cfg.ANYNET.STEM_W,
381
+ block_type=regnet_cfg.ANYNET.BLOCK_TYPE,
382
+ ds=regnet_cfg.ANYNET.DEPTHS,
383
+ ws=regnet_cfg.ANYNET.WIDTHS,
384
+ ss=regnet_cfg.ANYNET.STRIDES,
385
+ bn_norm=regnet_cfg.ANYNET.BN_NORM,
386
+ bms=regnet_cfg.ANYNET.BOT_MULS,
387
+ gws=regnet_cfg.ANYNET.GROUP_WS,
388
+ se_r=regnet_cfg.ANYNET.SE_R if regnet_cfg.ANYNET.SE_ON else None,
389
+ )
390
+ self.apply(init_weights)
391
+
392
+ def construct(self, stem_type, stem_w, block_type, ds, ws, ss, bn_norm, bms, gws, se_r):
393
+ # Generate dummy bot muls and gs for models that do not use them
394
+ bms = bms if bms else [1.0 for _d in ds]
395
+ gws = gws if gws else [1 for _d in ds]
396
+ # Group params by stage
397
+ stage_params = list(zip(ds, ws, ss, bms, gws))
398
+ # Construct the stem
399
+ stem_fun = get_stem_fun(stem_type)
400
+ self.stem = stem_fun(3, stem_w, bn_norm)
401
+ # Construct the stages
402
+ block_fun = get_block_fun(block_type)
403
+ prev_w = stem_w
404
+ for i, (d, w, s, bm, gw) in enumerate(stage_params):
405
+ self.add_module(
406
+ "s{}".format(i + 1), AnyStage(prev_w, w, s, bn_norm, d, block_fun, bm, gw, se_r)
407
+ )
408
+ prev_w = w
409
+ # Construct the head
410
+ self.in_planes = prev_w
411
+ # self.head = AnyHead(w_in=prev_w, nc=nc)
412
+
413
+ def forward(self, x):
414
+ for module in self.children():
415
+ x = module(x)
416
+ return x
417
+
418
+
419
+ def quantize_float(f, q):
420
+ """Converts a float to closest non-zero int divisible by q."""
421
+ return int(round(f / q) * q)
422
+
423
+
424
+ def adjust_ws_gs_comp(ws, bms, gs):
425
+ """Adjusts the compatibility of widths and groups."""
426
+ ws_bot = [int(w * b) for w, b in zip(ws, bms)]
427
+ gs = [min(g, w_bot) for g, w_bot in zip(gs, ws_bot)]
428
+ ws_bot = [quantize_float(w_bot, g) for w_bot, g in zip(ws_bot, gs)]
429
+ ws = [int(w_bot / b) for w_bot, b in zip(ws_bot, bms)]
430
+ return ws, gs
431
+
432
+
433
+ def get_stages_from_blocks(ws, rs):
434
+ """Gets ws/ds of network at each stage from per block values."""
435
+ ts_temp = zip(ws + [0], [0] + ws, rs + [0], [0] + rs)
436
+ ts = [w != wp or r != rp for w, wp, r, rp in ts_temp]
437
+ s_ws = [w for w, t in zip(ws, ts[:-1]) if t]
438
+ s_ds = np.diff([d for d, t in zip(range(len(ts)), ts) if t]).tolist()
439
+ return s_ws, s_ds
440
+
441
+
442
+ def generate_regnet(w_a, w_0, w_m, d, q=8):
443
+ """Generates per block ws from RegNet parameters."""
444
+ assert w_a >= 0 and w_0 > 0 and w_m > 1 and w_0 % q == 0
445
+ ws_cont = np.arange(d) * w_a + w_0
446
+ ks = np.round(np.log(ws_cont / w_0) / np.log(w_m))
447
+ ws = w_0 * np.power(w_m, ks)
448
+ ws = np.round(np.divide(ws, q)) * q
449
+ num_stages, max_stage = len(np.unique(ws)), ks.max() + 1
450
+ ws, ws_cont = ws.astype(int).tolist(), ws_cont.tolist()
451
+ return ws, num_stages, max_stage, ws_cont
452
+
453
+
454
+ class RegNet(AnyNet):
455
+ """RegNet model."""
456
+
457
+ def __init__(self, last_stride, bn_norm):
458
+ # Generate RegNet ws per block
459
+ b_ws, num_s, _, _ = generate_regnet(
460
+ regnet_cfg.REGNET.WA, regnet_cfg.REGNET.W0, regnet_cfg.REGNET.WM, regnet_cfg.REGNET.DEPTH
461
+ )
462
+ # Convert to per stage format
463
+ ws, ds = get_stages_from_blocks(b_ws, b_ws)
464
+ # Generate group widths and bot muls
465
+ gws = [regnet_cfg.REGNET.GROUP_W for _ in range(num_s)]
466
+ bms = [regnet_cfg.REGNET.BOT_MUL for _ in range(num_s)]
467
+ # Adjust the compatibility of ws and gws
468
+ ws, gws = adjust_ws_gs_comp(ws, bms, gws)
469
+ # Use the same stride for each stage
470
+ ss = [regnet_cfg.REGNET.STRIDE for _ in range(num_s)]
471
+ ss[-1] = last_stride
472
+ # Use SE for RegNetY
473
+ se_r = regnet_cfg.REGNET.SE_R if regnet_cfg.REGNET.SE_ON else None
474
+ # Construct the model
475
+ kwargs = {
476
+ "stem_type": regnet_cfg.REGNET.STEM_TYPE,
477
+ "stem_w": regnet_cfg.REGNET.STEM_W,
478
+ "block_type": regnet_cfg.REGNET.BLOCK_TYPE,
479
+ "ss": ss,
480
+ "ds": ds,
481
+ "ws": ws,
482
+ "bn_norm": bn_norm,
483
+ "bms": bms,
484
+ "gws": gws,
485
+ "se_r": se_r,
486
+ }
487
+ super(RegNet, self).__init__(**kwargs)
488
+
489
+
490
+ def init_pretrained_weights(key):
491
+ """Initializes model with pretrained weights.
492
+
493
+ Layers that don't match with pretrained layers in name or size are kept unchanged.
494
+ """
495
+ import os
496
+ import errno
497
+ import gdown
498
+
499
+ def _get_torch_home():
500
+ ENV_TORCH_HOME = 'TORCH_HOME'
501
+ ENV_XDG_CACHE_HOME = 'XDG_CACHE_HOME'
502
+ DEFAULT_CACHE_DIR = '~/.cache'
503
+ torch_home = os.path.expanduser(
504
+ os.getenv(
505
+ ENV_TORCH_HOME,
506
+ os.path.join(
507
+ os.getenv(ENV_XDG_CACHE_HOME, DEFAULT_CACHE_DIR), 'torch'
508
+ )
509
+ )
510
+ )
511
+ return torch_home
512
+
513
+ torch_home = _get_torch_home()
514
+ model_dir = os.path.join(torch_home, 'checkpoints')
515
+ try:
516
+ os.makedirs(model_dir)
517
+ except OSError as e:
518
+ if e.errno == errno.EEXIST:
519
+ # Directory already exists, ignore.
520
+ pass
521
+ else:
522
+ # Unexpected OSError, re-raise.
523
+ raise
524
+
525
+ filename = model_urls[key].split('/')[-1]
526
+
527
+ cached_file = os.path.join(model_dir, filename)
528
+
529
+ if not os.path.exists(cached_file):
530
+ if comm.is_main_process():
531
+ gdown.download(model_urls[key], cached_file, quiet=False)
532
+
533
+ comm.synchronize()
534
+
535
+ logger.info(f"Loading pretrained model from {cached_file}")
536
+ state_dict = torch.load(cached_file, map_location=torch.device('cpu'))['model_state']
537
+
538
+ return state_dict
539
+
540
+
541
+ @BACKBONE_REGISTRY.register()
542
+ def build_regnet_backbone(cfg):
543
+ # fmt: off
544
+ pretrain = cfg.MODEL.BACKBONE.PRETRAIN
545
+ pretrain_path = cfg.MODEL.BACKBONE.PRETRAIN_PATH
546
+ last_stride = cfg.MODEL.BACKBONE.LAST_STRIDE
547
+ bn_norm = cfg.MODEL.BACKBONE.NORM
548
+ depth = cfg.MODEL.BACKBONE.DEPTH
549
+ # fmt: on
550
+
551
+ cfg_files = {
552
+ '200x': 'fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml',
553
+ '200y': 'fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml',
554
+ '400x': 'fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml',
555
+ '400y': 'fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml',
556
+ '800x': 'fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml',
557
+ '800y': 'fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml',
558
+ '1600x': 'fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml',
559
+ '1600y': 'fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml',
560
+ '3200x': 'fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml',
561
+ '3200y': 'fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml',
562
+ '4000x': 'fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml',
563
+ '4000y': 'fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml',
564
+ '6400x': 'fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml',
565
+ '6400y': 'fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml',
566
+ }[depth]
567
+
568
+ regnet_cfg.merge_from_file(cfg_files)
569
+ model = RegNet(last_stride, bn_norm)
570
+
571
+ if pretrain:
572
+ # Load pretrain path if specifically
573
+ if pretrain_path:
574
+ try:
575
+ state_dict = torch.load(pretrain_path, map_location=torch.device('cpu'))
576
+ logger.info(f"Loading pretrained model from {pretrain_path}")
577
+ except FileNotFoundError as e:
578
+ logger.info(f'{pretrain_path} is not found! Please check this path.')
579
+ raise e
580
+ except KeyError as e:
581
+ logger.info("State dict keys error! Please check the state dict.")
582
+ raise e
583
+ else:
584
+ key = depth
585
+ state_dict = init_pretrained_weights(key)
586
+
587
+ incompatible = model.load_state_dict(state_dict, strict=False)
588
+ if incompatible.missing_keys:
589
+ logger.info(
590
+ get_missing_parameters_message(incompatible.missing_keys)
591
+ )
592
+ if incompatible.unexpected_keys:
593
+ logger.info(
594
+ get_unexpected_parameters_message(incompatible.unexpected_keys)
595
+ )
596
+ return model
@@ -0,0 +1,26 @@
1
+ MODEL:
2
+ TYPE: regnet
3
+ NUM_CLASSES: 1000
4
+ REGNET:
5
+ DEPTH: 18
6
+ W0: 80
7
+ WA: 34.01
8
+ WM: 2.25
9
+ GROUP_W: 24
10
+ OPTIM:
11
+ LR_POLICY: cos
12
+ BASE_LR: 0.8
13
+ MAX_EPOCH: 100
14
+ MOMENTUM: 0.9
15
+ WEIGHT_DECAY: 5e-5
16
+ WARMUP_ITERS: 5
17
+ TRAIN:
18
+ DATASET: imagenet
19
+ IM_SIZE: 224
20
+ BATCH_SIZE: 1024
21
+ TEST:
22
+ DATASET: imagenet
23
+ IM_SIZE: 256
24
+ BATCH_SIZE: 800
25
+ NUM_GPUS: 8
26
+ OUT_DIR: .
@@ -0,0 +1,26 @@
1
+ MODEL:
2
+ TYPE: regnet
3
+ NUM_CLASSES: 1000
4
+ REGNET:
5
+ DEPTH: 19
6
+ W0: 168
7
+ WA: 73.36
8
+ WM: 2.37
9
+ GROUP_W: 112
10
+ OPTIM:
11
+ LR_POLICY: cos
12
+ BASE_LR: 0.4
13
+ MAX_EPOCH: 100
14
+ MOMENTUM: 0.9
15
+ WEIGHT_DECAY: 5e-5
16
+ WARMUP_ITERS: 5
17
+ TRAIN:
18
+ DATASET: imagenet
19
+ IM_SIZE: 224
20
+ BATCH_SIZE: 512
21
+ TEST:
22
+ DATASET: imagenet
23
+ IM_SIZE: 256
24
+ BATCH_SIZE: 400
25
+ NUM_GPUS: 8
26
+ OUT_DIR: .
@@ -0,0 +1,26 @@
1
+ MODEL:
2
+ TYPE: regnet
3
+ NUM_CLASSES: 1000
4
+ REGNET:
5
+ DEPTH: 22
6
+ W0: 216
7
+ WA: 55.59
8
+ WM: 2.1
9
+ GROUP_W: 128
10
+ OPTIM:
11
+ LR_POLICY: cos
12
+ BASE_LR: 0.4
13
+ MAX_EPOCH: 100
14
+ MOMENTUM: 0.9
15
+ WEIGHT_DECAY: 5e-5
16
+ WARMUP_ITERS: 5
17
+ TRAIN:
18
+ DATASET: imagenet
19
+ IM_SIZE: 224
20
+ BATCH_SIZE: 512
21
+ TEST:
22
+ DATASET: imagenet
23
+ IM_SIZE: 256
24
+ BATCH_SIZE: 400
25
+ NUM_GPUS: 8
26
+ OUT_DIR: .
@@ -0,0 +1,26 @@
1
+ MODEL:
2
+ TYPE: regnet
3
+ NUM_CLASSES: 1000
4
+ REGNET:
5
+ DEPTH: 13
6
+ W0: 24
7
+ WA: 36.44
8
+ WM: 2.49
9
+ GROUP_W: 8
10
+ OPTIM:
11
+ LR_POLICY: cos
12
+ BASE_LR: 0.8
13
+ MAX_EPOCH: 100
14
+ MOMENTUM: 0.9
15
+ WEIGHT_DECAY: 5e-5
16
+ WARMUP_ITERS: 5
17
+ TRAIN:
18
+ DATASET: imagenet
19
+ IM_SIZE: 224
20
+ BATCH_SIZE: 1024
21
+ TEST:
22
+ DATASET: imagenet
23
+ IM_SIZE: 256
24
+ BATCH_SIZE: 800
25
+ NUM_GPUS: 8
26
+ OUT_DIR: .