dnt 0.2.4__py3-none-any.whl → 0.3.1.8__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.
- 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 +631 -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.3.1.8.dist-info/METADATA +117 -0
- dnt-0.3.1.8.dist-info/RECORD +315 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.8.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/METADATA +0 -35
- 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.8.dist-info/licenses}/LICENSE +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.8.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,525 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: xingyu liao
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
# based on:
|
|
8
|
+
# https://github.com/KaiyangZhou/deep-person-reid/blob/master/torchreid/models/osnet.py
|
|
9
|
+
|
|
10
|
+
import logging
|
|
11
|
+
|
|
12
|
+
import torch
|
|
13
|
+
from torch import nn
|
|
14
|
+
|
|
15
|
+
from fastreid.layers import get_norm
|
|
16
|
+
from fastreid.utils import comm
|
|
17
|
+
from fastreid.utils.checkpoint import get_missing_parameters_message, get_unexpected_parameters_message
|
|
18
|
+
from .build import BACKBONE_REGISTRY
|
|
19
|
+
|
|
20
|
+
logger = logging.getLogger(__name__)
|
|
21
|
+
model_urls = {
|
|
22
|
+
'osnet_x1_0':
|
|
23
|
+
'https://drive.google.com/uc?id=1LaG1EJpHrxdAxKnSCJ_i0u-nbxSAeiFY',
|
|
24
|
+
'osnet_x0_75':
|
|
25
|
+
'https://drive.google.com/uc?id=1uwA9fElHOk3ZogwbeY5GkLI6QPTX70Hq',
|
|
26
|
+
'osnet_x0_5':
|
|
27
|
+
'https://drive.google.com/uc?id=16DGLbZukvVYgINws8u8deSaOqjybZ83i',
|
|
28
|
+
'osnet_x0_25':
|
|
29
|
+
'https://drive.google.com/uc?id=1rb8UN5ZzPKRc_xvtHlyDh-cSz88YX9hs',
|
|
30
|
+
'osnet_ibn_x1_0':
|
|
31
|
+
'https://drive.google.com/uc?id=1sr90V6irlYYDd4_4ISU2iruoRG8J__6l'
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
##########
|
|
36
|
+
# Basic layers
|
|
37
|
+
##########
|
|
38
|
+
class ConvLayer(nn.Module):
|
|
39
|
+
"""Convolution layer (conv + bn + relu)."""
|
|
40
|
+
|
|
41
|
+
def __init__(
|
|
42
|
+
self,
|
|
43
|
+
in_channels,
|
|
44
|
+
out_channels,
|
|
45
|
+
kernel_size,
|
|
46
|
+
bn_norm,
|
|
47
|
+
stride=1,
|
|
48
|
+
padding=0,
|
|
49
|
+
groups=1,
|
|
50
|
+
IN=False
|
|
51
|
+
):
|
|
52
|
+
super(ConvLayer, self).__init__()
|
|
53
|
+
self.conv = nn.Conv2d(
|
|
54
|
+
in_channels,
|
|
55
|
+
out_channels,
|
|
56
|
+
kernel_size,
|
|
57
|
+
stride=stride,
|
|
58
|
+
padding=padding,
|
|
59
|
+
bias=False,
|
|
60
|
+
groups=groups
|
|
61
|
+
)
|
|
62
|
+
if IN:
|
|
63
|
+
self.bn = nn.InstanceNorm2d(out_channels, affine=True)
|
|
64
|
+
else:
|
|
65
|
+
self.bn = get_norm(bn_norm, out_channels)
|
|
66
|
+
self.relu = nn.ReLU(inplace=True)
|
|
67
|
+
|
|
68
|
+
def forward(self, x):
|
|
69
|
+
x = self.conv(x)
|
|
70
|
+
x = self.bn(x)
|
|
71
|
+
x = self.relu(x)
|
|
72
|
+
return x
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
class Conv1x1(nn.Module):
|
|
76
|
+
"""1x1 convolution + bn + relu."""
|
|
77
|
+
|
|
78
|
+
def __init__(self, in_channels, out_channels, bn_norm, stride=1, groups=1):
|
|
79
|
+
super(Conv1x1, self).__init__()
|
|
80
|
+
self.conv = nn.Conv2d(
|
|
81
|
+
in_channels,
|
|
82
|
+
out_channels,
|
|
83
|
+
1,
|
|
84
|
+
stride=stride,
|
|
85
|
+
padding=0,
|
|
86
|
+
bias=False,
|
|
87
|
+
groups=groups
|
|
88
|
+
)
|
|
89
|
+
self.bn = get_norm(bn_norm, out_channels)
|
|
90
|
+
self.relu = nn.ReLU(inplace=True)
|
|
91
|
+
|
|
92
|
+
def forward(self, x):
|
|
93
|
+
x = self.conv(x)
|
|
94
|
+
x = self.bn(x)
|
|
95
|
+
x = self.relu(x)
|
|
96
|
+
return x
|
|
97
|
+
|
|
98
|
+
|
|
99
|
+
class Conv1x1Linear(nn.Module):
|
|
100
|
+
"""1x1 convolution + bn (w/o non-linearity)."""
|
|
101
|
+
|
|
102
|
+
def __init__(self, in_channels, out_channels, bn_norm, stride=1):
|
|
103
|
+
super(Conv1x1Linear, self).__init__()
|
|
104
|
+
self.conv = nn.Conv2d(
|
|
105
|
+
in_channels, out_channels, 1, stride=stride, padding=0, bias=False
|
|
106
|
+
)
|
|
107
|
+
self.bn = get_norm(bn_norm, out_channels)
|
|
108
|
+
|
|
109
|
+
def forward(self, x):
|
|
110
|
+
x = self.conv(x)
|
|
111
|
+
x = self.bn(x)
|
|
112
|
+
return x
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class Conv3x3(nn.Module):
|
|
116
|
+
"""3x3 convolution + bn + relu."""
|
|
117
|
+
|
|
118
|
+
def __init__(self, in_channels, out_channels, bn_norm, stride=1, groups=1):
|
|
119
|
+
super(Conv3x3, self).__init__()
|
|
120
|
+
self.conv = nn.Conv2d(
|
|
121
|
+
in_channels,
|
|
122
|
+
out_channels,
|
|
123
|
+
3,
|
|
124
|
+
stride=stride,
|
|
125
|
+
padding=1,
|
|
126
|
+
bias=False,
|
|
127
|
+
groups=groups
|
|
128
|
+
)
|
|
129
|
+
self.bn = get_norm(bn_norm, out_channels)
|
|
130
|
+
self.relu = nn.ReLU(inplace=True)
|
|
131
|
+
|
|
132
|
+
def forward(self, x):
|
|
133
|
+
x = self.conv(x)
|
|
134
|
+
x = self.bn(x)
|
|
135
|
+
x = self.relu(x)
|
|
136
|
+
return x
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
class LightConv3x3(nn.Module):
|
|
140
|
+
"""Lightweight 3x3 convolution.
|
|
141
|
+
1x1 (linear) + dw 3x3 (nonlinear).
|
|
142
|
+
"""
|
|
143
|
+
|
|
144
|
+
def __init__(self, in_channels, out_channels, bn_norm):
|
|
145
|
+
super(LightConv3x3, self).__init__()
|
|
146
|
+
self.conv1 = nn.Conv2d(
|
|
147
|
+
in_channels, out_channels, 1, stride=1, padding=0, bias=False
|
|
148
|
+
)
|
|
149
|
+
self.conv2 = nn.Conv2d(
|
|
150
|
+
out_channels,
|
|
151
|
+
out_channels,
|
|
152
|
+
3,
|
|
153
|
+
stride=1,
|
|
154
|
+
padding=1,
|
|
155
|
+
bias=False,
|
|
156
|
+
groups=out_channels
|
|
157
|
+
)
|
|
158
|
+
self.bn = get_norm(bn_norm, out_channels)
|
|
159
|
+
self.relu = nn.ReLU(inplace=True)
|
|
160
|
+
|
|
161
|
+
def forward(self, x):
|
|
162
|
+
x = self.conv1(x)
|
|
163
|
+
x = self.conv2(x)
|
|
164
|
+
x = self.bn(x)
|
|
165
|
+
x = self.relu(x)
|
|
166
|
+
return x
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
##########
|
|
170
|
+
# Building blocks for omni-scale feature learning
|
|
171
|
+
##########
|
|
172
|
+
class ChannelGate(nn.Module):
|
|
173
|
+
"""A mini-network that generates channel-wise gates conditioned on input tensor."""
|
|
174
|
+
|
|
175
|
+
def __init__(
|
|
176
|
+
self,
|
|
177
|
+
in_channels,
|
|
178
|
+
num_gates=None,
|
|
179
|
+
return_gates=False,
|
|
180
|
+
gate_activation='sigmoid',
|
|
181
|
+
reduction=16,
|
|
182
|
+
layer_norm=False
|
|
183
|
+
):
|
|
184
|
+
super(ChannelGate, self).__init__()
|
|
185
|
+
if num_gates is None: num_gates = in_channels
|
|
186
|
+
self.return_gates = return_gates
|
|
187
|
+
|
|
188
|
+
self.global_avgpool = nn.AdaptiveAvgPool2d(1)
|
|
189
|
+
|
|
190
|
+
self.fc1 = nn.Conv2d(
|
|
191
|
+
in_channels,
|
|
192
|
+
in_channels // reduction,
|
|
193
|
+
kernel_size=1,
|
|
194
|
+
bias=True,
|
|
195
|
+
padding=0
|
|
196
|
+
)
|
|
197
|
+
self.norm1 = None
|
|
198
|
+
if layer_norm: self.norm1 = nn.LayerNorm((in_channels // reduction, 1, 1))
|
|
199
|
+
self.relu = nn.ReLU(inplace=True)
|
|
200
|
+
self.fc2 = nn.Conv2d(
|
|
201
|
+
in_channels // reduction,
|
|
202
|
+
num_gates,
|
|
203
|
+
kernel_size=1,
|
|
204
|
+
bias=True,
|
|
205
|
+
padding=0
|
|
206
|
+
)
|
|
207
|
+
if gate_activation == 'sigmoid':
|
|
208
|
+
self.gate_activation = nn.Sigmoid()
|
|
209
|
+
elif gate_activation == 'relu':
|
|
210
|
+
self.gate_activation = nn.ReLU(inplace=True)
|
|
211
|
+
elif gate_activation == 'linear':
|
|
212
|
+
self.gate_activation = nn.Identity()
|
|
213
|
+
else:
|
|
214
|
+
raise RuntimeError(
|
|
215
|
+
"Unknown gate activation: {}".format(gate_activation)
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
def forward(self, x):
|
|
219
|
+
input = x
|
|
220
|
+
x = self.global_avgpool(x)
|
|
221
|
+
x = self.fc1(x)
|
|
222
|
+
if self.norm1 is not None: x = self.norm1(x)
|
|
223
|
+
x = self.relu(x)
|
|
224
|
+
x = self.fc2(x)
|
|
225
|
+
x = self.gate_activation(x)
|
|
226
|
+
if self.return_gates: return x
|
|
227
|
+
return input * x
|
|
228
|
+
|
|
229
|
+
|
|
230
|
+
class OSBlock(nn.Module):
|
|
231
|
+
"""Omni-scale feature learning block."""
|
|
232
|
+
|
|
233
|
+
def __init__(
|
|
234
|
+
self,
|
|
235
|
+
in_channels,
|
|
236
|
+
out_channels,
|
|
237
|
+
bn_norm,
|
|
238
|
+
IN=False,
|
|
239
|
+
bottleneck_reduction=4,
|
|
240
|
+
**kwargs
|
|
241
|
+
):
|
|
242
|
+
super(OSBlock, self).__init__()
|
|
243
|
+
mid_channels = out_channels // bottleneck_reduction
|
|
244
|
+
self.conv1 = Conv1x1(in_channels, mid_channels, bn_norm)
|
|
245
|
+
self.conv2a = LightConv3x3(mid_channels, mid_channels, bn_norm)
|
|
246
|
+
self.conv2b = nn.Sequential(
|
|
247
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
248
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
249
|
+
)
|
|
250
|
+
self.conv2c = nn.Sequential(
|
|
251
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
252
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
253
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
254
|
+
)
|
|
255
|
+
self.conv2d = nn.Sequential(
|
|
256
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
257
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
258
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
259
|
+
LightConv3x3(mid_channels, mid_channels, bn_norm),
|
|
260
|
+
)
|
|
261
|
+
self.gate = ChannelGate(mid_channels)
|
|
262
|
+
self.conv3 = Conv1x1Linear(mid_channels, out_channels, bn_norm)
|
|
263
|
+
self.downsample = None
|
|
264
|
+
if in_channels != out_channels:
|
|
265
|
+
self.downsample = Conv1x1Linear(in_channels, out_channels, bn_norm)
|
|
266
|
+
self.IN = None
|
|
267
|
+
if IN: self.IN = nn.InstanceNorm2d(out_channels, affine=True)
|
|
268
|
+
self.relu = nn.ReLU(True)
|
|
269
|
+
|
|
270
|
+
def forward(self, x):
|
|
271
|
+
identity = x
|
|
272
|
+
x1 = self.conv1(x)
|
|
273
|
+
x2a = self.conv2a(x1)
|
|
274
|
+
x2b = self.conv2b(x1)
|
|
275
|
+
x2c = self.conv2c(x1)
|
|
276
|
+
x2d = self.conv2d(x1)
|
|
277
|
+
x2 = self.gate(x2a) + self.gate(x2b) + self.gate(x2c) + self.gate(x2d)
|
|
278
|
+
x3 = self.conv3(x2)
|
|
279
|
+
if self.downsample is not None:
|
|
280
|
+
identity = self.downsample(identity)
|
|
281
|
+
out = x3 + identity
|
|
282
|
+
if self.IN is not None:
|
|
283
|
+
out = self.IN(out)
|
|
284
|
+
return self.relu(out)
|
|
285
|
+
|
|
286
|
+
|
|
287
|
+
##########
|
|
288
|
+
# Network architecture
|
|
289
|
+
##########
|
|
290
|
+
class OSNet(nn.Module):
|
|
291
|
+
"""Omni-Scale Network.
|
|
292
|
+
|
|
293
|
+
Reference:
|
|
294
|
+
- Zhou et al. Omni-Scale Feature Learning for Person Re-Identification. ICCV, 2019.
|
|
295
|
+
- Zhou et al. Learning Generalisable Omni-Scale Representations
|
|
296
|
+
for Person Re-Identification. arXiv preprint, 2019.
|
|
297
|
+
"""
|
|
298
|
+
|
|
299
|
+
def __init__(
|
|
300
|
+
self,
|
|
301
|
+
blocks,
|
|
302
|
+
layers,
|
|
303
|
+
channels,
|
|
304
|
+
bn_norm,
|
|
305
|
+
IN=False,
|
|
306
|
+
**kwargs
|
|
307
|
+
):
|
|
308
|
+
super(OSNet, self).__init__()
|
|
309
|
+
num_blocks = len(blocks)
|
|
310
|
+
assert num_blocks == len(layers)
|
|
311
|
+
assert num_blocks == len(channels) - 1
|
|
312
|
+
|
|
313
|
+
# convolutional backbone
|
|
314
|
+
self.conv1 = ConvLayer(3, channels[0], 7, bn_norm, stride=2, padding=3, IN=IN)
|
|
315
|
+
self.maxpool = nn.MaxPool2d(3, stride=2, padding=1)
|
|
316
|
+
self.conv2 = self._make_layer(
|
|
317
|
+
blocks[0],
|
|
318
|
+
layers[0],
|
|
319
|
+
channels[0],
|
|
320
|
+
channels[1],
|
|
321
|
+
bn_norm,
|
|
322
|
+
reduce_spatial_size=True,
|
|
323
|
+
IN=IN
|
|
324
|
+
)
|
|
325
|
+
self.conv3 = self._make_layer(
|
|
326
|
+
blocks[1],
|
|
327
|
+
layers[1],
|
|
328
|
+
channels[1],
|
|
329
|
+
channels[2],
|
|
330
|
+
bn_norm,
|
|
331
|
+
reduce_spatial_size=True
|
|
332
|
+
)
|
|
333
|
+
self.conv4 = self._make_layer(
|
|
334
|
+
blocks[2],
|
|
335
|
+
layers[2],
|
|
336
|
+
channels[2],
|
|
337
|
+
channels[3],
|
|
338
|
+
bn_norm,
|
|
339
|
+
reduce_spatial_size=False
|
|
340
|
+
)
|
|
341
|
+
self.conv5 = Conv1x1(channels[3], channels[3], bn_norm)
|
|
342
|
+
|
|
343
|
+
self._init_params()
|
|
344
|
+
|
|
345
|
+
def _make_layer(
|
|
346
|
+
self,
|
|
347
|
+
block,
|
|
348
|
+
layer,
|
|
349
|
+
in_channels,
|
|
350
|
+
out_channels,
|
|
351
|
+
bn_norm,
|
|
352
|
+
reduce_spatial_size,
|
|
353
|
+
IN=False
|
|
354
|
+
):
|
|
355
|
+
layers = []
|
|
356
|
+
|
|
357
|
+
layers.append(block(in_channels, out_channels, bn_norm, IN=IN))
|
|
358
|
+
for i in range(1, layer):
|
|
359
|
+
layers.append(block(out_channels, out_channels, bn_norm, IN=IN))
|
|
360
|
+
|
|
361
|
+
if reduce_spatial_size:
|
|
362
|
+
layers.append(
|
|
363
|
+
nn.Sequential(
|
|
364
|
+
Conv1x1(out_channels, out_channels, bn_norm),
|
|
365
|
+
nn.AvgPool2d(2, stride=2),
|
|
366
|
+
)
|
|
367
|
+
)
|
|
368
|
+
|
|
369
|
+
return nn.Sequential(*layers)
|
|
370
|
+
|
|
371
|
+
def _init_params(self):
|
|
372
|
+
for m in self.modules():
|
|
373
|
+
if isinstance(m, nn.Conv2d):
|
|
374
|
+
nn.init.kaiming_normal_(
|
|
375
|
+
m.weight, mode='fan_out', nonlinearity='relu'
|
|
376
|
+
)
|
|
377
|
+
if m.bias is not None:
|
|
378
|
+
nn.init.constant_(m.bias, 0)
|
|
379
|
+
|
|
380
|
+
elif isinstance(m, nn.BatchNorm2d):
|
|
381
|
+
nn.init.constant_(m.weight, 1)
|
|
382
|
+
nn.init.constant_(m.bias, 0)
|
|
383
|
+
|
|
384
|
+
elif isinstance(m, nn.BatchNorm1d):
|
|
385
|
+
nn.init.constant_(m.weight, 1)
|
|
386
|
+
nn.init.constant_(m.bias, 0)
|
|
387
|
+
|
|
388
|
+
elif isinstance(m, nn.Linear):
|
|
389
|
+
nn.init.normal_(m.weight, 0, 0.01)
|
|
390
|
+
if m.bias is not None:
|
|
391
|
+
nn.init.constant_(m.bias, 0)
|
|
392
|
+
|
|
393
|
+
def forward(self, x):
|
|
394
|
+
x = self.conv1(x)
|
|
395
|
+
x = self.maxpool(x)
|
|
396
|
+
x = self.conv2(x)
|
|
397
|
+
x = self.conv3(x)
|
|
398
|
+
x = self.conv4(x)
|
|
399
|
+
x = self.conv5(x)
|
|
400
|
+
return x
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
def init_pretrained_weights(model, key=''):
|
|
404
|
+
"""Initializes model with pretrained weights.
|
|
405
|
+
|
|
406
|
+
Layers that don't match with pretrained layers in name or size are kept unchanged.
|
|
407
|
+
"""
|
|
408
|
+
import os
|
|
409
|
+
import errno
|
|
410
|
+
import gdown
|
|
411
|
+
from collections import OrderedDict
|
|
412
|
+
import warnings
|
|
413
|
+
import logging
|
|
414
|
+
|
|
415
|
+
logger = logging.getLogger(__name__)
|
|
416
|
+
|
|
417
|
+
def _get_torch_home():
|
|
418
|
+
ENV_TORCH_HOME = 'TORCH_HOME'
|
|
419
|
+
ENV_XDG_CACHE_HOME = 'XDG_CACHE_HOME'
|
|
420
|
+
DEFAULT_CACHE_DIR = '~/.cache'
|
|
421
|
+
torch_home = os.path.expanduser(
|
|
422
|
+
os.getenv(
|
|
423
|
+
ENV_TORCH_HOME,
|
|
424
|
+
os.path.join(
|
|
425
|
+
os.getenv(ENV_XDG_CACHE_HOME, DEFAULT_CACHE_DIR), 'torch'
|
|
426
|
+
)
|
|
427
|
+
)
|
|
428
|
+
)
|
|
429
|
+
return torch_home
|
|
430
|
+
|
|
431
|
+
torch_home = _get_torch_home()
|
|
432
|
+
model_dir = os.path.join(torch_home, 'checkpoints')
|
|
433
|
+
try:
|
|
434
|
+
os.makedirs(model_dir)
|
|
435
|
+
except OSError as e:
|
|
436
|
+
if e.errno == errno.EEXIST:
|
|
437
|
+
# Directory already exists, ignore.
|
|
438
|
+
pass
|
|
439
|
+
else:
|
|
440
|
+
# Unexpected OSError, re-raise.
|
|
441
|
+
raise
|
|
442
|
+
filename = key + '_imagenet.pth'
|
|
443
|
+
cached_file = os.path.join(model_dir, filename)
|
|
444
|
+
|
|
445
|
+
if not os.path.exists(cached_file):
|
|
446
|
+
logger.info(f"Pretrain model don't exist, downloading from {model_urls[key]}")
|
|
447
|
+
if comm.is_main_process():
|
|
448
|
+
gdown.download(model_urls[key], cached_file, quiet=False)
|
|
449
|
+
|
|
450
|
+
comm.synchronize()
|
|
451
|
+
|
|
452
|
+
state_dict = torch.load(cached_file, map_location=torch.device('cpu'))
|
|
453
|
+
model_dict = model.state_dict()
|
|
454
|
+
new_state_dict = OrderedDict()
|
|
455
|
+
matched_layers, discarded_layers = [], []
|
|
456
|
+
|
|
457
|
+
for k, v in state_dict.items():
|
|
458
|
+
if k.startswith('module.'):
|
|
459
|
+
k = k[7:] # discard module.
|
|
460
|
+
|
|
461
|
+
if k in model_dict and model_dict[k].size() == v.size():
|
|
462
|
+
new_state_dict[k] = v
|
|
463
|
+
matched_layers.append(k)
|
|
464
|
+
else:
|
|
465
|
+
discarded_layers.append(k)
|
|
466
|
+
|
|
467
|
+
model_dict.update(new_state_dict)
|
|
468
|
+
return model_dict
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
@BACKBONE_REGISTRY.register()
|
|
472
|
+
def build_osnet_backbone(cfg):
|
|
473
|
+
"""
|
|
474
|
+
Create a OSNet instance from config.
|
|
475
|
+
Returns:
|
|
476
|
+
OSNet: a :class:`OSNet` instance
|
|
477
|
+
"""
|
|
478
|
+
|
|
479
|
+
# fmt: off
|
|
480
|
+
pretrain = cfg.MODEL.BACKBONE.PRETRAIN
|
|
481
|
+
pretrain_path = cfg.MODEL.BACKBONE.PRETRAIN_PATH
|
|
482
|
+
with_ibn = cfg.MODEL.BACKBONE.WITH_IBN
|
|
483
|
+
bn_norm = cfg.MODEL.BACKBONE.NORM
|
|
484
|
+
depth = cfg.MODEL.BACKBONE.DEPTH
|
|
485
|
+
# fmt: on
|
|
486
|
+
|
|
487
|
+
num_blocks_per_stage = [2, 2, 2]
|
|
488
|
+
num_channels_per_stage = {
|
|
489
|
+
"x1_0": [64, 256, 384, 512],
|
|
490
|
+
"x0_75": [48, 192, 288, 384],
|
|
491
|
+
"x0_5": [32, 128, 192, 256],
|
|
492
|
+
"x0_25": [16, 64, 96, 128]}[depth]
|
|
493
|
+
model = OSNet([OSBlock, OSBlock, OSBlock], num_blocks_per_stage, num_channels_per_stage,
|
|
494
|
+
bn_norm, IN=with_ibn)
|
|
495
|
+
|
|
496
|
+
if pretrain:
|
|
497
|
+
# Load pretrain path if specifically
|
|
498
|
+
if pretrain_path:
|
|
499
|
+
try:
|
|
500
|
+
state_dict = torch.load(pretrain_path, map_location=torch.device('cpu'))
|
|
501
|
+
logger.info(f"Loading pretrained model from {pretrain_path}")
|
|
502
|
+
except FileNotFoundError as e:
|
|
503
|
+
logger.info(f'{pretrain_path} is not found! Please check this path.')
|
|
504
|
+
raise e
|
|
505
|
+
except KeyError as e:
|
|
506
|
+
logger.info("State dict keys error! Please check the state dict.")
|
|
507
|
+
raise e
|
|
508
|
+
else:
|
|
509
|
+
if with_ibn:
|
|
510
|
+
pretrain_key = "osnet_ibn_" + depth
|
|
511
|
+
else:
|
|
512
|
+
pretrain_key = "osnet_" + depth
|
|
513
|
+
|
|
514
|
+
state_dict = init_pretrained_weights(model, pretrain_key)
|
|
515
|
+
|
|
516
|
+
incompatible = model.load_state_dict(state_dict, strict=False)
|
|
517
|
+
if incompatible.missing_keys:
|
|
518
|
+
logger.info(
|
|
519
|
+
get_missing_parameters_message(incompatible.missing_keys)
|
|
520
|
+
)
|
|
521
|
+
if incompatible.unexpected_keys:
|
|
522
|
+
logger.info(
|
|
523
|
+
get_unexpected_parameters_message(incompatible.unexpected_keys)
|
|
524
|
+
)
|
|
525
|
+
return model
|