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,490 @@
1
+ # -*- coding: utf-8 -*-
2
+ # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
3
+
4
+ """
5
+ This file contains components with some default boilerplate logic user may need
6
+ in training / testing. They will not work for everyone, but many users may find them useful.
7
+ The behavior of functions/classes in this file is subject to change,
8
+ since they are meant to represent the "common default behavior" people need in their projects.
9
+ """
10
+
11
+ import argparse
12
+ import logging
13
+ import os
14
+ import sys
15
+ from collections import OrderedDict
16
+
17
+ import torch
18
+ from torch.nn.parallel import DistributedDataParallel
19
+
20
+ from fastreid.data import build_reid_test_loader, build_reid_train_loader
21
+ from fastreid.evaluation import (ReidEvaluator,
22
+ inference_on_dataset, print_csv_format)
23
+ from fastreid.modeling.meta_arch import build_model
24
+ from fastreid.solver import build_lr_scheduler, build_optimizer
25
+ from fastreid.utils import comm
26
+ from fastreid.utils.checkpoint import Checkpointer
27
+ from fastreid.utils.collect_env import collect_env_info
28
+ from fastreid.utils.env import seed_all_rng
29
+ from fastreid.utils.events import CommonMetricPrinter, JSONWriter, TensorboardXWriter
30
+ from fastreid.utils.file_io import PathManager
31
+ from fastreid.utils.logger import setup_logger
32
+ from . import hooks
33
+ from .train_loop import TrainerBase, AMPTrainer, SimpleTrainer
34
+
35
+ __all__ = ["default_argument_parser", "default_setup", "DefaultPredictor", "DefaultTrainer"]
36
+
37
+
38
+ def default_argument_parser():
39
+ """
40
+ Create a parser with some common arguments used by fastreid users.
41
+ Returns:
42
+ argparse.ArgumentParser:
43
+ """
44
+ parser = argparse.ArgumentParser(description="fastreid Training")
45
+ parser.add_argument("--config-file", default="", metavar="FILE", help="path to config file")
46
+ parser.add_argument(
47
+ "--resume",
48
+ action="store_true",
49
+ help="whether to attempt to resume from the checkpoint directory",
50
+ )
51
+ parser.add_argument("--eval-only", action="store_true", help="perform evaluation only")
52
+ parser.add_argument("--num-gpus", type=int, default=1, help="number of gpus *per machine*")
53
+ parser.add_argument("--num-machines", type=int, default=1, help="total number of machines")
54
+ parser.add_argument(
55
+ "--machine-rank", type=int, default=0, help="the rank of this machine (unique per machine)"
56
+ )
57
+
58
+ # PyTorch still may leave orphan processes in multi-gpu training.
59
+ # Therefore we use a deterministic way to obtain port,
60
+ # so that users are aware of orphan processes by seeing the port occupied.
61
+ port = 2 ** 15 + 2 ** 14 + hash(os.getuid() if sys.platform != "win32" else 1) % 2 ** 14
62
+ parser.add_argument("--dist-url", default="tcp://127.0.0.1:{}".format(port))
63
+ parser.add_argument(
64
+ "opts",
65
+ help="Modify config options using the command-line",
66
+ default=None,
67
+ nargs=argparse.REMAINDER,
68
+ )
69
+ return parser
70
+
71
+
72
+ def default_setup(cfg, args):
73
+ """
74
+ Perform some basic common setups at the beginning of a job, including:
75
+ 1. Set up the detectron2 logger
76
+ 2. Log basic information about environment, cmdline arguments, and config
77
+ 3. Backup the config to the output directory
78
+ Args:
79
+ cfg (CfgNode): the full config to be used
80
+ args (argparse.NameSpace): the command line arguments to be logged
81
+ """
82
+ output_dir = cfg.OUTPUT_DIR
83
+ if comm.is_main_process() and output_dir:
84
+ PathManager.mkdirs(output_dir)
85
+
86
+ rank = comm.get_rank()
87
+ # setup_logger(output_dir, distributed_rank=rank, name="fvcore")
88
+ logger = setup_logger(output_dir, distributed_rank=rank)
89
+
90
+ logger.info("Rank of current process: {}. World size: {}".format(rank, comm.get_world_size()))
91
+ logger.info("Environment info:\n" + collect_env_info())
92
+
93
+ logger.info("Command line arguments: " + str(args))
94
+ if hasattr(args, "config_file") and args.config_file != "":
95
+ logger.info(
96
+ "Contents of args.config_file={}:\n{}".format(
97
+ args.config_file, PathManager.open(args.config_file, "r").read()
98
+ )
99
+ )
100
+
101
+ logger.info("Running with full config:\n{}".format(cfg))
102
+ if comm.is_main_process() and output_dir:
103
+ # Note: some of our scripts may expect the existence of
104
+ # config.yaml in output directory
105
+ path = os.path.join(output_dir, "config.yaml")
106
+ with PathManager.open(path, "w") as f:
107
+ f.write(cfg.dump())
108
+ logger.info("Full config saved to {}".format(os.path.abspath(path)))
109
+
110
+ # make sure each worker has a different, yet deterministic seed if specified
111
+ seed_all_rng()
112
+
113
+ # cudnn benchmark has large overhead. It shouldn't be used considering the small size of
114
+ # typical validation set.
115
+ if not (hasattr(args, "eval_only") and args.eval_only):
116
+ torch.backends.cudnn.benchmark = cfg.CUDNN_BENCHMARK
117
+
118
+
119
+ class DefaultPredictor:
120
+ """
121
+ Create a simple end-to-end predictor with the given config.
122
+ The predictor takes an BGR image, resizes it to the specified resolution,
123
+ runs the model and produces a dict of predictions.
124
+ This predictor takes care of model loading and input preprocessing for you.
125
+ If you'd like to do anything more fancy, please refer to its source code
126
+ as examples to build and use the model manually.
127
+ Attributes:
128
+ Examples:
129
+ .. code-block:: python
130
+ pred = DefaultPredictor(cfg)
131
+ inputs = cv2.imread("input.jpg")
132
+ outputs = pred(inputs)
133
+ """
134
+
135
+ def __init__(self, cfg):
136
+ self.cfg = cfg.clone() # cfg can be modified by model
137
+ self.cfg.defrost()
138
+ self.cfg.MODEL.BACKBONE.PRETRAIN = False
139
+ self.model = build_model(self.cfg)
140
+ self.model.eval()
141
+
142
+ Checkpointer(self.model).load(cfg.MODEL.WEIGHTS)
143
+
144
+ def __call__(self, image):
145
+ """
146
+ Args:
147
+ image (torch.tensor): an image tensor of shape (B, C, H, W).
148
+ Returns:
149
+ predictions (torch.tensor): the output features of the model
150
+ """
151
+ inputs = {"images": image.to(self.model.device)}
152
+ with torch.no_grad(): # https://github.com/sphinx-doc/sphinx/issues/4258
153
+ predictions = self.model(inputs)
154
+ return predictions.cpu()
155
+
156
+
157
+ class DefaultTrainer(TrainerBase):
158
+ """
159
+ A trainer with default training logic. Compared to `SimpleTrainer`, it
160
+ contains the following logic in addition:
161
+ 1. Create model, optimizer, scheduler, dataloader from the given config.
162
+ 2. Load a checkpoint or `cfg.MODEL.WEIGHTS`, if exists.
163
+ 3. Register a few common hooks.
164
+ It is created to simplify the **standard model training workflow** and reduce code boilerplate
165
+ for users who only need the standard training workflow, with standard features.
166
+ It means this class makes *many assumptions* about your training logic that
167
+ may easily become invalid in a new research. In fact, any assumptions beyond those made in the
168
+ :class:`SimpleTrainer` are too much for research.
169
+ The code of this class has been annotated about restrictive assumptions it mades.
170
+ When they do not work for you, you're encouraged to:
171
+ 1. Overwrite methods of this class, OR:
172
+ 2. Use :class:`SimpleTrainer`, which only does minimal SGD training and
173
+ nothing else. You can then add your own hooks if needed. OR:
174
+ 3. Write your own training loop similar to `tools/plain_train_net.py`.
175
+ Also note that the behavior of this class, like other functions/classes in
176
+ this file, is not stable, since it is meant to represent the "common default behavior".
177
+ It is only guaranteed to work well with the standard models and training workflow in fastreid.
178
+ To obtain more stable behavior, write your own training logic with other public APIs.
179
+ Attributes:
180
+ scheduler:
181
+ checkpointer:
182
+ cfg (CfgNode):
183
+ Examples:
184
+ .. code-block:: python
185
+ trainer = DefaultTrainer(cfg)
186
+ trainer.resume_or_load() # load last checkpoint or MODEL.WEIGHTS
187
+ trainer.train()
188
+ """
189
+
190
+ def __init__(self, cfg):
191
+ """
192
+ Args:
193
+ cfg (CfgNode):
194
+ """
195
+ super().__init__()
196
+ logger = logging.getLogger("fastreid")
197
+ if not logger.isEnabledFor(logging.INFO): # setup_logger is not called for fastreid
198
+ setup_logger()
199
+
200
+ # Assume these objects must be constructed in this order.
201
+ data_loader = self.build_train_loader(cfg)
202
+ cfg = self.auto_scale_hyperparams(cfg, data_loader.dataset.num_classes)
203
+ model = self.build_model(cfg)
204
+ optimizer, param_wrapper = self.build_optimizer(cfg, model)
205
+
206
+ # For training, wrap with DDP. But don't need this for inference.
207
+ if comm.get_world_size() > 1:
208
+ # ref to https://github.com/pytorch/pytorch/issues/22049 to set `find_unused_parameters=True`
209
+ # for part of the parameters is not updated.
210
+ model = DistributedDataParallel(
211
+ model, device_ids=[comm.get_local_rank()], broadcast_buffers=False,
212
+ )
213
+
214
+ self._trainer = (AMPTrainer if cfg.SOLVER.AMP.ENABLED else SimpleTrainer)(
215
+ model, data_loader, optimizer, param_wrapper
216
+ )
217
+
218
+ self.iters_per_epoch = len(data_loader.dataset) // cfg.SOLVER.IMS_PER_BATCH
219
+ self.scheduler = self.build_lr_scheduler(cfg, optimizer, self.iters_per_epoch)
220
+
221
+ # Assume no other objects need to be checkpointed.
222
+ # We can later make it checkpoint the stateful hooks
223
+ self.checkpointer = Checkpointer(
224
+ # Assume you want to save checkpoints together with logs/statistics
225
+ model,
226
+ cfg.OUTPUT_DIR,
227
+ save_to_disk=comm.is_main_process(),
228
+ optimizer=optimizer,
229
+ **self.scheduler,
230
+ )
231
+
232
+ self.start_epoch = 0
233
+ self.max_epoch = cfg.SOLVER.MAX_EPOCH
234
+ self.max_iter = self.max_epoch * self.iters_per_epoch
235
+ self.warmup_iters = cfg.SOLVER.WARMUP_ITERS
236
+ self.delay_epochs = cfg.SOLVER.DELAY_EPOCHS
237
+ self.cfg = cfg
238
+
239
+ self.register_hooks(self.build_hooks())
240
+
241
+ def resume_or_load(self, resume=True):
242
+ """
243
+ If `resume==True` and `cfg.OUTPUT_DIR` contains the last checkpoint (defined by
244
+ a `last_checkpoint` file), resume from the file. Resuming means loading all
245
+ available states (eg. optimizer and scheduler) and update iteration counter
246
+ from the checkpoint. ``cfg.MODEL.WEIGHTS`` will not be used.
247
+ Otherwise, this is considered as an independent training. The method will load model
248
+ weights from the file `cfg.MODEL.WEIGHTS` (but will not load other states) and start
249
+ from iteration 0.
250
+ Args:
251
+ resume (bool): whether to do resume or not
252
+ """
253
+ # The checkpoint stores the training iteration that just finished, thus we start
254
+ # at the next iteration (or iter zero if there's no checkpoint).
255
+ checkpoint = self.checkpointer.resume_or_load(self.cfg.MODEL.WEIGHTS, resume=resume)
256
+
257
+ if resume and self.checkpointer.has_checkpoint():
258
+ self.start_epoch = checkpoint.get("epoch", -1) + 1
259
+ # The checkpoint stores the training iteration that just finished, thus we start
260
+ # at the next iteration (or iter zero if there's no checkpoint).
261
+
262
+ def build_hooks(self):
263
+ """
264
+ Build a list of default hooks, including timing, evaluation,
265
+ checkpointing, lr scheduling, precise BN, writing events.
266
+ Returns:
267
+ list[HookBase]:
268
+ """
269
+ logger = logging.getLogger(__name__)
270
+ cfg = self.cfg.clone()
271
+ cfg.defrost()
272
+ cfg.DATALOADER.NUM_WORKERS = 0 # save some memory and time for PreciseBN
273
+ cfg.DATASETS.NAMES = tuple([cfg.TEST.PRECISE_BN.DATASET]) # set dataset name for PreciseBN
274
+
275
+ ret = [
276
+ hooks.IterationTimer(),
277
+ hooks.LRScheduler(self.optimizer, self.scheduler),
278
+ ]
279
+
280
+ if cfg.TEST.PRECISE_BN.ENABLED and hooks.get_bn_modules(self.model):
281
+ logger.info("Prepare precise BN dataset")
282
+ ret.append(hooks.PreciseBN(
283
+ # Run at the same freq as (but before) evaluation.
284
+ self.model,
285
+ # Build a new data loader to not affect training
286
+ self.build_train_loader(cfg),
287
+ cfg.TEST.PRECISE_BN.NUM_ITER,
288
+ ))
289
+
290
+ if len(cfg.MODEL.FREEZE_LAYERS) > 0 and cfg.SOLVER.FREEZE_ITERS > 0:
291
+ ret.append(hooks.LayerFreeze(
292
+ self.model,
293
+ cfg.MODEL.FREEZE_LAYERS,
294
+ cfg.SOLVER.FREEZE_ITERS,
295
+ ))
296
+
297
+ # Do PreciseBN before checkpointer, because it updates the model and need to
298
+ # be saved by checkpointer.
299
+ # This is not always the best: if checkpointing has a different frequency,
300
+ # some checkpoints may have more precise statistics than others.
301
+
302
+ def test_and_save_results():
303
+ self._last_eval_results = self.test(self.cfg, self.model)
304
+ return self._last_eval_results
305
+
306
+ # Do evaluation before checkpointer, because then if it fails,
307
+ # we can use the saved checkpoint to debug.
308
+ ret.append(hooks.EvalHook(cfg.TEST.EVAL_PERIOD, test_and_save_results))
309
+
310
+ if comm.is_main_process():
311
+ ret.append(hooks.PeriodicCheckpointer(self.checkpointer, cfg.SOLVER.CHECKPOINT_PERIOD))
312
+ # run writers in the end, so that evaluation metrics are written
313
+ ret.append(hooks.PeriodicWriter(self.build_writers(), 200))
314
+
315
+ return ret
316
+
317
+ def build_writers(self):
318
+ """
319
+ Build a list of writers to be used. By default it contains
320
+ writers that write metrics to the screen,
321
+ a json file, and a tensorboard event file respectively.
322
+ If you'd like a different list of writers, you can overwrite it in
323
+ your trainer.
324
+ Returns:
325
+ list[EventWriter]: a list of :class:`EventWriter` objects.
326
+ It is now implemented by:
327
+ .. code-block:: python
328
+ return [
329
+ CommonMetricPrinter(self.max_iter),
330
+ JSONWriter(os.path.join(self.cfg.OUTPUT_DIR, "metrics.json")),
331
+ TensorboardXWriter(self.cfg.OUTPUT_DIR),
332
+ ]
333
+ """
334
+ # Assume the default print/log frequency.
335
+ return [
336
+ # It may not always print what you want to see, since it prints "common" metrics only.
337
+ CommonMetricPrinter(self.max_iter),
338
+ JSONWriter(os.path.join(self.cfg.OUTPUT_DIR, "metrics.json")),
339
+ TensorboardXWriter(self.cfg.OUTPUT_DIR),
340
+ ]
341
+
342
+ def train(self):
343
+ """
344
+ Run training.
345
+ Returns:
346
+ OrderedDict of results, if evaluation is enabled. Otherwise None.
347
+ """
348
+ super().train(self.start_epoch, self.max_epoch, self.iters_per_epoch)
349
+ if comm.is_main_process():
350
+ assert hasattr(
351
+ self, "_last_eval_results"
352
+ ), "No evaluation results obtained during training!"
353
+ return self._last_eval_results
354
+
355
+ def run_step(self):
356
+ self._trainer.iter = self.iter
357
+ self._trainer.run_step()
358
+
359
+ @classmethod
360
+ def build_model(cls, cfg):
361
+ """
362
+ Returns:
363
+ torch.nn.Module:
364
+ It now calls :func:`fastreid.modeling.build_model`.
365
+ Overwrite it if you'd like a different model.
366
+ """
367
+ model = build_model(cfg)
368
+ logger = logging.getLogger(__name__)
369
+ logger.info("Model:\n{}".format(model))
370
+ return model
371
+
372
+ @classmethod
373
+ def build_optimizer(cls, cfg, model):
374
+ """
375
+ Returns:
376
+ torch.optim.Optimizer:
377
+ It now calls :func:`fastreid.solver.build_optimizer`.
378
+ Overwrite it if you'd like a different optimizer.
379
+ """
380
+ return build_optimizer(cfg, model)
381
+
382
+ @classmethod
383
+ def build_lr_scheduler(cls, cfg, optimizer, iters_per_epoch):
384
+ """
385
+ It now calls :func:`fastreid.solver.build_lr_scheduler`.
386
+ Overwrite it if you'd like a different scheduler.
387
+ """
388
+ return build_lr_scheduler(cfg, optimizer, iters_per_epoch)
389
+
390
+ @classmethod
391
+ def build_train_loader(cls, cfg):
392
+ """
393
+ Returns:
394
+ iterable
395
+ It now calls :func:`fastreid.data.build_reid_train_loader`.
396
+ Overwrite it if you'd like a different data loader.
397
+ """
398
+ logger = logging.getLogger(__name__)
399
+ logger.info("Prepare training set")
400
+ return build_reid_train_loader(cfg, combineall=cfg.DATASETS.COMBINEALL)
401
+
402
+ @classmethod
403
+ def build_test_loader(cls, cfg, dataset_name):
404
+ """
405
+ Returns:
406
+ iterable
407
+ It now calls :func:`fastreid.data.build_reid_test_loader`.
408
+ Overwrite it if you'd like a different data loader.
409
+ """
410
+ return build_reid_test_loader(cfg, dataset_name=dataset_name)
411
+
412
+ @classmethod
413
+ def build_evaluator(cls, cfg, dataset_name, output_dir=None):
414
+ data_loader, num_query = cls.build_test_loader(cfg, dataset_name)
415
+ return data_loader, ReidEvaluator(cfg, num_query, output_dir)
416
+
417
+ @classmethod
418
+ def test(cls, cfg, model):
419
+ """
420
+ Args:
421
+ cfg (CfgNode):
422
+ model (nn.Module):
423
+ Returns:
424
+ dict: a dict of result metrics
425
+ """
426
+ logger = logging.getLogger(__name__)
427
+
428
+ results = OrderedDict()
429
+ for idx, dataset_name in enumerate(cfg.DATASETS.TESTS):
430
+ logger.info("Prepare testing set")
431
+ try:
432
+ data_loader, evaluator = cls.build_evaluator(cfg, dataset_name)
433
+ except NotImplementedError:
434
+ logger.warn(
435
+ "No evaluator found. implement its `build_evaluator` method."
436
+ )
437
+ results[dataset_name] = {}
438
+ continue
439
+ results_i = inference_on_dataset(model, data_loader, evaluator, flip_test=cfg.TEST.FLIP.ENABLED)
440
+ results[dataset_name] = results_i
441
+
442
+ if comm.is_main_process():
443
+ assert isinstance(
444
+ results, dict
445
+ ), "Evaluator must return a dict on the main process. Got {} instead.".format(
446
+ results
447
+ )
448
+ logger.info("Evaluation results for {} in csv format:".format(dataset_name))
449
+ results_i['dataset'] = dataset_name
450
+ print_csv_format(results_i)
451
+
452
+ if len(results) == 1:
453
+ results = list(results.values())[0]
454
+
455
+ return results
456
+
457
+ @staticmethod
458
+ def auto_scale_hyperparams(cfg, num_classes):
459
+ r"""
460
+ This is used for auto-computation actual training iterations,
461
+ because some hyper-param, such as MAX_ITER, means training epochs rather than iters,
462
+ so we need to convert specific hyper-param to training iterations.
463
+ """
464
+ cfg = cfg.clone()
465
+ frozen = cfg.is_frozen()
466
+ cfg.defrost()
467
+
468
+ # If you don't hard-code the number of classes, it will compute the number automatically
469
+ if cfg.MODEL.HEADS.NUM_CLASSES == 0:
470
+ output_dir = cfg.OUTPUT_DIR
471
+ cfg.MODEL.HEADS.NUM_CLASSES = num_classes
472
+ logger = logging.getLogger(__name__)
473
+ logger.info(f"Auto-scaling the num_classes={cfg.MODEL.HEADS.NUM_CLASSES}")
474
+
475
+ # Update the saved config file to make the number of classes valid
476
+ if comm.is_main_process() and output_dir:
477
+ # Note: some of our scripts may expect the existence of
478
+ # config.yaml in output directory
479
+ path = os.path.join(output_dir, "config.yaml")
480
+ with PathManager.open(path, "w") as f:
481
+ f.write(cfg.dump())
482
+
483
+ if frozen: cfg.freeze()
484
+
485
+ return cfg
486
+
487
+
488
+ # Access basic attributes from the underlying trainer
489
+ for _attr in ["model", "data_loader", "optimizer", "grad_scaler"]:
490
+ setattr(DefaultTrainer, _attr, property(lambda self, x=_attr: getattr(self._trainer, x, None)))