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.
- dnt/__init__.py +3 -2
- dnt/analysis/__init__.py +3 -2
- dnt/analysis/count.py +54 -37
- dnt/analysis/interaction2.py +518 -0
- dnt/analysis/stop.py +22 -17
- dnt/analysis/stop2.py +289 -0
- dnt/analysis/stop3.py +758 -0
- dnt/detect/signal/detector.py +326 -0
- dnt/detect/timestamp.py +105 -0
- dnt/detect/yolov8/detector.py +179 -36
- dnt/detect/yolov8/segmentor.py +60 -2
- dnt/engine/__init__.py +8 -0
- dnt/engine/bbox_interp.py +83 -0
- dnt/engine/bbox_iou.py +20 -0
- dnt/engine/cluster.py +31 -0
- dnt/engine/iob.py +66 -0
- dnt/filter/filter.py +333 -2
- dnt/label/labeler.py +4 -4
- dnt/label/labeler2.py +605 -0
- dnt/shared/__init__.py +2 -1
- dnt/shared/data/coco.names +0 -0
- dnt/shared/data/openimages.names +0 -0
- dnt/shared/data/voc.names +0 -0
- dnt/shared/download.py +12 -0
- dnt/shared/synhcro.py +150 -0
- dnt/shared/util.py +17 -4
- dnt/third_party/fast-reid/__init__.py +1 -0
- dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
- dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
- dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
- dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
- dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
- dnt/third_party/fast-reid/configs/__init__.py +0 -0
- dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
- dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
- dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
- dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
- dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
- dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
- dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
- dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
- dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
- dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
- dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
- dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
- dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
- dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
- dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
- dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
- dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
- dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
- dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
- dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
- dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
- dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
- dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
- dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
- dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
- dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
- dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
- dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
- dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
- dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
- dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
- dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
- dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
- dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
- dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
- dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
- dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
- dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
- dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
- dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
- dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
- dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
- dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
- dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
- dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
- dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
- dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
- dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
- dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
- dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
- dnt/track/__init__.py +2 -0
- dnt/track/botsort/__init__.py +4 -0
- dnt/track/botsort/bot_tracker/__init__.py +3 -0
- dnt/track/botsort/bot_tracker/basetrack.py +60 -0
- dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
- dnt/track/botsort/bot_tracker/gmc.py +316 -0
- dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
- dnt/track/botsort/bot_tracker/matching.py +194 -0
- dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
- dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
- dnt/track/botsort/inference.py +96 -0
- dnt/track/config.py +120 -0
- dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
- dnt/track/dsort/configs/deep_sort.yaml +0 -0
- dnt/track/dsort/configs/fastreid.yaml +1 -1
- dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
- dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
- dnt/track/dsort/deep_sort/deep_sort.py +31 -20
- dnt/track/dsort/deep_sort/sort/detection.py +2 -1
- dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
- dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
- dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
- dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
- dnt/track/dsort/deep_sort/sort/track.py +2 -1
- dnt/track/dsort/deep_sort/sort/tracker.py +1 -1
- dnt/track/dsort/dsort.py +43 -33
- dnt/track/re_class.py +117 -0
- dnt/track/sort/sort.py +9 -6
- dnt/track/tracker.py +213 -32
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/METADATA +41 -13
- dnt-0.3.1.7.dist-info/RECORD +315 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/WHEEL +1 -1
- dnt/analysis/yield.py +0 -9
- dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
- dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
- dnt/track/dsort/deep_sort/deep/test.py +0 -77
- dnt/track/dsort/deep_sort/deep/train.py +0 -189
- dnt/track/dsort/utils/asserts.py +0 -13
- dnt/track/dsort/utils/draw.py +0 -36
- dnt/track/dsort/utils/json_logger.py +0 -383
- dnt/track/dsort/utils/log.py +0 -17
- dnt/track/dsort/utils/parser.py +0 -35
- dnt/track/dsort/utils/tools.py +0 -39
- dnt-0.2.4.dist-info/RECORD +0 -64
- /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info/licenses}/LICENSE +0 -0
- {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
|
dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml
ADDED
|
@@ -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: .
|
dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml
ADDED
|
@@ -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: .
|
dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml
ADDED
|
@@ -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: .
|
dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml
ADDED
|
@@ -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: .
|