dnt 0.2.4__py3-none-any.whl → 0.3.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dnt might be problematic. Click here for more details.
- dnt/__init__.py +3 -2
- dnt/analysis/__init__.py +3 -2
- dnt/analysis/interaction.py +503 -0
- dnt/analysis/stop.py +22 -17
- dnt/analysis/stop2.py +289 -0
- dnt/analysis/stop3.py +754 -0
- dnt/detect/signal/detector.py +317 -0
- dnt/detect/yolov8/detector.py +116 -16
- 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 +321 -1
- dnt/label/labeler.py +4 -4
- dnt/label/labeler2.py +502 -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 +28 -18
- 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/dsort.py +21 -28
- dnt/track/re_class.py +94 -0
- dnt/track/sort/sort.py +5 -1
- dnt/track/tracker.py +207 -30
- {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/METADATA +30 -10
- dnt-0.3.1.3.dist-info/RECORD +314 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.3.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.3.dist-info}/LICENSE +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: xingyu liao
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import torch
|
|
8
|
+
import torch.nn.functional as F
|
|
9
|
+
from torch import nn
|
|
10
|
+
from torch.nn import Conv2d, ReLU
|
|
11
|
+
from torch.nn.modules.utils import _pair
|
|
12
|
+
from fastreid.layers import get_norm
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
class SplAtConv2d(nn.Module):
|
|
16
|
+
"""Split-Attention Conv2d
|
|
17
|
+
"""
|
|
18
|
+
|
|
19
|
+
def __init__(self, in_channels, channels, kernel_size, stride=(1, 1), padding=(0, 0),
|
|
20
|
+
dilation=(1, 1), groups=1, bias=True,
|
|
21
|
+
radix=2, reduction_factor=4,
|
|
22
|
+
rectify=False, rectify_avg=False, norm_layer=None,
|
|
23
|
+
dropblock_prob=0.0, **kwargs):
|
|
24
|
+
super(SplAtConv2d, self).__init__()
|
|
25
|
+
padding = _pair(padding)
|
|
26
|
+
self.rectify = rectify and (padding[0] > 0 or padding[1] > 0)
|
|
27
|
+
self.rectify_avg = rectify_avg
|
|
28
|
+
inter_channels = max(in_channels * radix // reduction_factor, 32)
|
|
29
|
+
self.radix = radix
|
|
30
|
+
self.cardinality = groups
|
|
31
|
+
self.channels = channels
|
|
32
|
+
self.dropblock_prob = dropblock_prob
|
|
33
|
+
if self.rectify:
|
|
34
|
+
from rfconv import RFConv2d
|
|
35
|
+
self.conv = RFConv2d(in_channels, channels * radix, kernel_size, stride, padding, dilation,
|
|
36
|
+
groups=groups * radix, bias=bias, average_mode=rectify_avg, **kwargs)
|
|
37
|
+
else:
|
|
38
|
+
self.conv = Conv2d(in_channels, channels * radix, kernel_size, stride, padding, dilation,
|
|
39
|
+
groups=groups * radix, bias=bias, **kwargs)
|
|
40
|
+
self.use_bn = norm_layer is not None
|
|
41
|
+
if self.use_bn:
|
|
42
|
+
self.bn0 = get_norm(norm_layer, channels * radix)
|
|
43
|
+
self.relu = ReLU(inplace=True)
|
|
44
|
+
self.fc1 = Conv2d(channels, inter_channels, 1, groups=self.cardinality)
|
|
45
|
+
if self.use_bn:
|
|
46
|
+
self.bn1 = get_norm(norm_layer, inter_channels)
|
|
47
|
+
self.fc2 = Conv2d(inter_channels, channels * radix, 1, groups=self.cardinality)
|
|
48
|
+
if dropblock_prob > 0.0:
|
|
49
|
+
self.dropblock = DropBlock2D(dropblock_prob, 3)
|
|
50
|
+
self.rsoftmax = rSoftMax(radix, groups)
|
|
51
|
+
|
|
52
|
+
def forward(self, x):
|
|
53
|
+
x = self.conv(x)
|
|
54
|
+
if self.use_bn:
|
|
55
|
+
x = self.bn0(x)
|
|
56
|
+
if self.dropblock_prob > 0.0:
|
|
57
|
+
x = self.dropblock(x)
|
|
58
|
+
x = self.relu(x)
|
|
59
|
+
|
|
60
|
+
batch, rchannel = x.shape[:2]
|
|
61
|
+
if self.radix > 1:
|
|
62
|
+
if torch.__version__ < '1.5':
|
|
63
|
+
splited = torch.split(x, int(rchannel // self.radix), dim=1)
|
|
64
|
+
else:
|
|
65
|
+
splited = torch.split(x, rchannel // self.radix, dim=1)
|
|
66
|
+
gap = sum(splited)
|
|
67
|
+
else:
|
|
68
|
+
gap = x
|
|
69
|
+
gap = F.adaptive_avg_pool2d(gap, 1)
|
|
70
|
+
gap = self.fc1(gap)
|
|
71
|
+
|
|
72
|
+
if self.use_bn:
|
|
73
|
+
gap = self.bn1(gap)
|
|
74
|
+
gap = self.relu(gap)
|
|
75
|
+
|
|
76
|
+
atten = self.fc2(gap)
|
|
77
|
+
atten = self.rsoftmax(atten).view(batch, -1, 1, 1)
|
|
78
|
+
|
|
79
|
+
if self.radix > 1:
|
|
80
|
+
if torch.__version__ < '1.5':
|
|
81
|
+
attens = torch.split(atten, int(rchannel // self.radix), dim=1)
|
|
82
|
+
else:
|
|
83
|
+
attens = torch.split(atten, rchannel // self.radix, dim=1)
|
|
84
|
+
out = sum([att * split for (att, split) in zip(attens, splited)])
|
|
85
|
+
else:
|
|
86
|
+
out = atten * x
|
|
87
|
+
return out.contiguous()
|
|
88
|
+
|
|
89
|
+
|
|
90
|
+
class rSoftMax(nn.Module):
|
|
91
|
+
def __init__(self, radix, cardinality):
|
|
92
|
+
super().__init__()
|
|
93
|
+
self.radix = radix
|
|
94
|
+
self.cardinality = cardinality
|
|
95
|
+
|
|
96
|
+
def forward(self, x):
|
|
97
|
+
batch = x.size(0)
|
|
98
|
+
if self.radix > 1:
|
|
99
|
+
x = x.view(batch, self.cardinality, self.radix, -1).transpose(1, 2)
|
|
100
|
+
x = F.softmax(x, dim=1)
|
|
101
|
+
x = x.reshape(batch, -1)
|
|
102
|
+
else:
|
|
103
|
+
x = torch.sigmoid(x)
|
|
104
|
+
return x
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
class DropBlock2D(object):
|
|
108
|
+
def __init__(self, *args, **kwargs):
|
|
109
|
+
raise NotImplementedError
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: xingyu liao
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import math
|
|
8
|
+
import warnings
|
|
9
|
+
|
|
10
|
+
import torch
|
|
11
|
+
from torch import nn, Tensor
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
def weights_init_kaiming(m):
|
|
15
|
+
classname = m.__class__.__name__
|
|
16
|
+
if classname.find('Linear') != -1:
|
|
17
|
+
nn.init.normal_(m.weight, 0, 0.01)
|
|
18
|
+
if m.bias is not None:
|
|
19
|
+
nn.init.constant_(m.bias, 0.0)
|
|
20
|
+
elif classname.find('Conv') != -1:
|
|
21
|
+
nn.init.kaiming_normal_(m.weight, mode='fan_out')
|
|
22
|
+
if m.bias is not None:
|
|
23
|
+
nn.init.constant_(m.bias, 0.0)
|
|
24
|
+
elif classname.find('BatchNorm') != -1:
|
|
25
|
+
if m.affine:
|
|
26
|
+
nn.init.constant_(m.weight, 1.0)
|
|
27
|
+
nn.init.constant_(m.bias, 0.0)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
def weights_init_classifier(m):
|
|
31
|
+
classname = m.__class__.__name__
|
|
32
|
+
if classname.find('Linear') != -1:
|
|
33
|
+
nn.init.normal_(m.weight, std=0.001)
|
|
34
|
+
if m.bias is not None:
|
|
35
|
+
nn.init.constant_(m.bias, 0.0)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
from torch.nn.init import _calculate_fan_in_and_fan_out
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _no_grad_trunc_normal_(tensor, mean, std, a, b):
|
|
42
|
+
# Cut & paste from PyTorch official master until it's in a few official releases - RW
|
|
43
|
+
# Method based on https://people.sc.fsu.edu/~jburkardt/presentations/truncated_normal.pdf
|
|
44
|
+
def norm_cdf(x):
|
|
45
|
+
# Computes standard normal cumulative distribution function
|
|
46
|
+
return (1. + math.erf(x / math.sqrt(2.))) / 2.
|
|
47
|
+
|
|
48
|
+
if (mean < a - 2 * std) or (mean > b + 2 * std):
|
|
49
|
+
warnings.warn("mean is more than 2 std from [a, b] in nn.init.trunc_normal_. "
|
|
50
|
+
"The distribution of values may be incorrect.",
|
|
51
|
+
stacklevel=2)
|
|
52
|
+
|
|
53
|
+
with torch.no_grad():
|
|
54
|
+
# Values are generated by using a truncated uniform distribution and
|
|
55
|
+
# then using the inverse CDF for the normal distribution.
|
|
56
|
+
# Get upper and lower cdf values
|
|
57
|
+
l = norm_cdf((a - mean) / std)
|
|
58
|
+
u = norm_cdf((b - mean) / std)
|
|
59
|
+
|
|
60
|
+
# Uniformly fill tensor with values from [l, u], then translate to
|
|
61
|
+
# [2l-1, 2u-1].
|
|
62
|
+
tensor.uniform_(2 * l - 1, 2 * u - 1)
|
|
63
|
+
|
|
64
|
+
# Use inverse cdf transform for normal distribution to get truncated
|
|
65
|
+
# standard normal
|
|
66
|
+
tensor.erfinv_()
|
|
67
|
+
|
|
68
|
+
# Transform to proper mean, std
|
|
69
|
+
tensor.mul_(std * math.sqrt(2.))
|
|
70
|
+
tensor.add_(mean)
|
|
71
|
+
|
|
72
|
+
# Clamp to ensure it's in the proper range
|
|
73
|
+
tensor.clamp_(min=a, max=b)
|
|
74
|
+
return tensor
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def trunc_normal_(tensor, mean=0., std=1., a=-2., b=2.):
|
|
78
|
+
# type: (Tensor, float, float, float, float) -> Tensor
|
|
79
|
+
r"""Fills the input Tensor with values drawn from a truncated
|
|
80
|
+
normal distribution. The values are effectively drawn from the
|
|
81
|
+
normal distribution :math:`\mathcal{N}(\text{mean}, \text{std}^2)`
|
|
82
|
+
with values outside :math:`[a, b]` redrawn until they are within
|
|
83
|
+
the bounds. The method used for generating the random values works
|
|
84
|
+
best when :math:`a \leq \text{mean} \leq b`.
|
|
85
|
+
Args:
|
|
86
|
+
tensor: an n-dimensional `torch.Tensor`
|
|
87
|
+
mean: the mean of the normal distribution
|
|
88
|
+
std: the standard deviation of the normal distribution
|
|
89
|
+
a: the minimum cutoff value
|
|
90
|
+
b: the maximum cutoff value
|
|
91
|
+
Examples:
|
|
92
|
+
>>> w = torch.empty(3, 5)
|
|
93
|
+
>>> nn.init.trunc_normal_(w)
|
|
94
|
+
"""
|
|
95
|
+
return _no_grad_trunc_normal_(tensor, mean, std, a, b)
|
|
96
|
+
|
|
97
|
+
|
|
98
|
+
def variance_scaling_(tensor, scale=1.0, mode='fan_in', distribution='normal'):
|
|
99
|
+
fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
|
|
100
|
+
if mode == 'fan_in':
|
|
101
|
+
denom = fan_in
|
|
102
|
+
elif mode == 'fan_out':
|
|
103
|
+
denom = fan_out
|
|
104
|
+
elif mode == 'fan_avg':
|
|
105
|
+
denom = (fan_in + fan_out) / 2
|
|
106
|
+
|
|
107
|
+
variance = scale / denom
|
|
108
|
+
|
|
109
|
+
if distribution == "truncated_normal":
|
|
110
|
+
# constant is stddev of standard normal truncated to (-2, 2)
|
|
111
|
+
trunc_normal_(tensor, std=math.sqrt(variance) / .87962566103423978)
|
|
112
|
+
elif distribution == "normal":
|
|
113
|
+
tensor.normal_(std=math.sqrt(variance))
|
|
114
|
+
elif distribution == "uniform":
|
|
115
|
+
bound = math.sqrt(3 * variance)
|
|
116
|
+
tensor.uniform_(-bound, bound)
|
|
117
|
+
else:
|
|
118
|
+
raise ValueError(f"invalid distribution {distribution}")
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
def lecun_normal_(tensor):
|
|
122
|
+
variance_scaling_(tensor, mode='fan_in', distribution='truncated_normal')
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: sherlock
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from . import losses
|
|
8
|
+
from .backbones import (
|
|
9
|
+
BACKBONE_REGISTRY,
|
|
10
|
+
build_resnet_backbone,
|
|
11
|
+
build_backbone,
|
|
12
|
+
)
|
|
13
|
+
from .heads import (
|
|
14
|
+
REID_HEADS_REGISTRY,
|
|
15
|
+
build_heads,
|
|
16
|
+
EmbeddingHead,
|
|
17
|
+
)
|
|
18
|
+
from .meta_arch import (
|
|
19
|
+
build_model,
|
|
20
|
+
META_ARCH_REGISTRY,
|
|
21
|
+
)
|
|
22
|
+
|
|
23
|
+
__all__ = [k for k in globals().keys() if not k.startswith("_")]
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: liaoxingyu
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from .build import build_backbone, BACKBONE_REGISTRY
|
|
8
|
+
|
|
9
|
+
from .resnet import build_resnet_backbone
|
|
10
|
+
from .osnet import build_osnet_backbone
|
|
11
|
+
from .resnest import build_resnest_backbone
|
|
12
|
+
from .resnext import build_resnext_backbone
|
|
13
|
+
from .regnet import build_regnet_backbone, build_effnet_backbone
|
|
14
|
+
from .shufflenet import build_shufflenetv2_backbone
|
|
15
|
+
from .mobilenet import build_mobilenetv2_backbone
|
|
16
|
+
from .mobilenetv3 import build_mobilenetv3_backbone
|
|
17
|
+
from .repvgg import build_repvgg_backbone
|
|
18
|
+
from .vision_transformer import build_vit_backbone
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: liaoxingyu
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
from ...utils.registry import Registry
|
|
8
|
+
|
|
9
|
+
BACKBONE_REGISTRY = Registry("BACKBONE")
|
|
10
|
+
BACKBONE_REGISTRY.__doc__ = """
|
|
11
|
+
Registry for backbones, which extract feature maps from images
|
|
12
|
+
The registered object must be a callable that accepts two arguments:
|
|
13
|
+
1. A :class:`fastreid.config.CfgNode`
|
|
14
|
+
It must returns an instance of :class:`Backbone`.
|
|
15
|
+
"""
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
def build_backbone(cfg):
|
|
19
|
+
"""
|
|
20
|
+
Build a backbone from `cfg.MODEL.BACKBONE.NAME`.
|
|
21
|
+
Returns:
|
|
22
|
+
an instance of :class:`Backbone`
|
|
23
|
+
"""
|
|
24
|
+
|
|
25
|
+
backbone_name = cfg.MODEL.BACKBONE.NAME
|
|
26
|
+
backbone = BACKBONE_REGISTRY.get(backbone_name)(cfg)
|
|
27
|
+
return backbone
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Creates a MobileNetV2 Model as defined in:
|
|
3
|
+
Mark Sandler, Andrew Howard, Menglong Zhu, Andrey Zhmoginov, Liang-Chieh Chen. (2018).
|
|
4
|
+
MobileNetV2: Inverted Residuals and Linear Bottlenecks
|
|
5
|
+
arXiv preprint arXiv:1801.04381.
|
|
6
|
+
import from https://github.com/tonylins/pytorch-mobilenet-v2
|
|
7
|
+
"""
|
|
8
|
+
import logging
|
|
9
|
+
import math
|
|
10
|
+
|
|
11
|
+
import torch
|
|
12
|
+
import torch.nn as nn
|
|
13
|
+
|
|
14
|
+
from fastreid.layers import get_norm
|
|
15
|
+
from fastreid.utils.checkpoint import get_missing_parameters_message, get_unexpected_parameters_message
|
|
16
|
+
from .build import BACKBONE_REGISTRY
|
|
17
|
+
|
|
18
|
+
logger = logging.getLogger(__name__)
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
def _make_divisible(v, divisor, min_value=None):
|
|
22
|
+
"""
|
|
23
|
+
This function is taken from the original tf repo.
|
|
24
|
+
It ensures that all layers have a channel number that is divisible by 8
|
|
25
|
+
It can be seen here:
|
|
26
|
+
https://github.com/tensorflow/models/blob/master/research/slim/nets/mobilenet/mobilenet.py
|
|
27
|
+
:param v:
|
|
28
|
+
:param divisor:
|
|
29
|
+
:param min_value:
|
|
30
|
+
:return:
|
|
31
|
+
"""
|
|
32
|
+
if min_value is None:
|
|
33
|
+
min_value = divisor
|
|
34
|
+
new_v = max(min_value, int(v + divisor / 2) // divisor * divisor)
|
|
35
|
+
# Make sure that round down does not go down by more than 10%.
|
|
36
|
+
if new_v < 0.9 * v:
|
|
37
|
+
new_v += divisor
|
|
38
|
+
return new_v
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def conv_3x3_bn(inp, oup, stride, bn_norm):
|
|
42
|
+
return nn.Sequential(
|
|
43
|
+
nn.Conv2d(inp, oup, 3, stride, 1, bias=False),
|
|
44
|
+
get_norm(bn_norm, oup),
|
|
45
|
+
nn.ReLU6(inplace=True)
|
|
46
|
+
)
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def conv_1x1_bn(inp, oup, bn_norm):
|
|
50
|
+
return nn.Sequential(
|
|
51
|
+
nn.Conv2d(inp, oup, 1, 1, 0, bias=False),
|
|
52
|
+
get_norm(bn_norm, oup),
|
|
53
|
+
nn.ReLU6(inplace=True)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
class InvertedResidual(nn.Module):
|
|
58
|
+
def __init__(self, inp, oup, bn_norm, stride, expand_ratio):
|
|
59
|
+
super(InvertedResidual, self).__init__()
|
|
60
|
+
assert stride in [1, 2]
|
|
61
|
+
|
|
62
|
+
hidden_dim = round(inp * expand_ratio)
|
|
63
|
+
self.identity = stride == 1 and inp == oup
|
|
64
|
+
|
|
65
|
+
if expand_ratio == 1:
|
|
66
|
+
self.conv = nn.Sequential(
|
|
67
|
+
# dw
|
|
68
|
+
nn.Conv2d(hidden_dim, hidden_dim, 3, stride, 1, groups=hidden_dim, bias=False),
|
|
69
|
+
get_norm(bn_norm, hidden_dim),
|
|
70
|
+
nn.ReLU6(inplace=True),
|
|
71
|
+
# pw-linear
|
|
72
|
+
nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False),
|
|
73
|
+
get_norm(bn_norm, oup),
|
|
74
|
+
)
|
|
75
|
+
else:
|
|
76
|
+
self.conv = nn.Sequential(
|
|
77
|
+
# pw
|
|
78
|
+
nn.Conv2d(inp, hidden_dim, 1, 1, 0, bias=False),
|
|
79
|
+
get_norm(bn_norm, hidden_dim),
|
|
80
|
+
nn.ReLU6(inplace=True),
|
|
81
|
+
# dw
|
|
82
|
+
nn.Conv2d(hidden_dim, hidden_dim, 3, stride, 1, groups=hidden_dim, bias=False),
|
|
83
|
+
get_norm(bn_norm, hidden_dim),
|
|
84
|
+
nn.ReLU6(inplace=True),
|
|
85
|
+
# pw-linear
|
|
86
|
+
nn.Conv2d(hidden_dim, oup, 1, 1, 0, bias=False),
|
|
87
|
+
nn.BatchNorm2d(oup),
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
def forward(self, x):
|
|
91
|
+
if self.identity:
|
|
92
|
+
return x + self.conv(x)
|
|
93
|
+
else:
|
|
94
|
+
return self.conv(x)
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
class MobileNetV2(nn.Module):
|
|
98
|
+
def __init__(self, bn_norm, width_mult=1.):
|
|
99
|
+
super(MobileNetV2, self).__init__()
|
|
100
|
+
# setting of inverted residual blocks
|
|
101
|
+
self.cfgs = [
|
|
102
|
+
# t, c, n, s
|
|
103
|
+
[1, 16, 1, 1],
|
|
104
|
+
[6, 24, 2, 2],
|
|
105
|
+
[6, 32, 3, 2],
|
|
106
|
+
[6, 64, 4, 2],
|
|
107
|
+
[6, 96, 3, 1],
|
|
108
|
+
[6, 160, 3, 2],
|
|
109
|
+
[6, 320, 1, 1],
|
|
110
|
+
]
|
|
111
|
+
|
|
112
|
+
# building first layer
|
|
113
|
+
input_channel = _make_divisible(32 * width_mult, 4 if width_mult == 0.1 else 8)
|
|
114
|
+
layers = [conv_3x3_bn(3, input_channel, 2, bn_norm)]
|
|
115
|
+
# building inverted residual blocks
|
|
116
|
+
block = InvertedResidual
|
|
117
|
+
for t, c, n, s in self.cfgs:
|
|
118
|
+
output_channel = _make_divisible(c * width_mult, 4 if width_mult == 0.1 else 8)
|
|
119
|
+
for i in range(n):
|
|
120
|
+
layers.append(block(input_channel, output_channel, bn_norm, s if i == 0 else 1, t))
|
|
121
|
+
input_channel = output_channel
|
|
122
|
+
self.features = nn.Sequential(*layers)
|
|
123
|
+
# building last several layers
|
|
124
|
+
output_channel = _make_divisible(1280 * width_mult, 4 if width_mult == 0.1 else 8) if width_mult > 1.0 else 1280
|
|
125
|
+
self.conv = conv_1x1_bn(input_channel, output_channel, bn_norm)
|
|
126
|
+
|
|
127
|
+
self._initialize_weights()
|
|
128
|
+
|
|
129
|
+
def forward(self, x):
|
|
130
|
+
x = self.features(x)
|
|
131
|
+
x = self.conv(x)
|
|
132
|
+
return x
|
|
133
|
+
|
|
134
|
+
def _initialize_weights(self):
|
|
135
|
+
for m in self.modules():
|
|
136
|
+
if isinstance(m, nn.Conv2d):
|
|
137
|
+
n = m.kernel_size[0] * m.kernel_size[1] * m.out_channels
|
|
138
|
+
m.weight.data.normal_(0, math.sqrt(2. / n))
|
|
139
|
+
if m.bias is not None:
|
|
140
|
+
m.bias.data.zero_()
|
|
141
|
+
elif isinstance(m, nn.BatchNorm2d):
|
|
142
|
+
m.weight.data.fill_(1)
|
|
143
|
+
m.bias.data.zero_()
|
|
144
|
+
elif isinstance(m, nn.Linear):
|
|
145
|
+
m.weight.data.normal_(0, 0.01)
|
|
146
|
+
m.bias.data.zero_()
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
@BACKBONE_REGISTRY.register()
|
|
150
|
+
def build_mobilenetv2_backbone(cfg):
|
|
151
|
+
"""
|
|
152
|
+
Create a MobileNetV2 instance from config.
|
|
153
|
+
Returns:
|
|
154
|
+
MobileNetV2: a :class: `MobileNetV2` instance.
|
|
155
|
+
"""
|
|
156
|
+
# fmt: off
|
|
157
|
+
pretrain = cfg.MODEL.BACKBONE.PRETRAIN
|
|
158
|
+
pretrain_path = cfg.MODEL.BACKBONE.PRETRAIN_PATH
|
|
159
|
+
bn_norm = cfg.MODEL.BACKBONE.NORM
|
|
160
|
+
depth = cfg.MODEL.BACKBONE.DEPTH
|
|
161
|
+
# fmt: on
|
|
162
|
+
|
|
163
|
+
width_mult = {
|
|
164
|
+
"1.0x": 1.0,
|
|
165
|
+
"0.75x": 0.75,
|
|
166
|
+
"0.5x": 0.5,
|
|
167
|
+
"0.35x": 0.35,
|
|
168
|
+
'0.25x': 0.25,
|
|
169
|
+
'0.1x': 0.1,
|
|
170
|
+
}[depth]
|
|
171
|
+
|
|
172
|
+
model = MobileNetV2(bn_norm, width_mult)
|
|
173
|
+
|
|
174
|
+
if pretrain:
|
|
175
|
+
try:
|
|
176
|
+
state_dict = torch.load(pretrain_path, map_location=torch.device('cpu'))
|
|
177
|
+
logger.info(f"Loading pretrained model from {pretrain_path}")
|
|
178
|
+
except FileNotFoundError as e:
|
|
179
|
+
logger.info(f'{pretrain_path} is not found! Please check this path.')
|
|
180
|
+
raise e
|
|
181
|
+
except KeyError as e:
|
|
182
|
+
logger.info("State dict keys error! Please check the state dict.")
|
|
183
|
+
raise e
|
|
184
|
+
|
|
185
|
+
incompatible = model.load_state_dict(state_dict, strict=False)
|
|
186
|
+
if incompatible.missing_keys:
|
|
187
|
+
logger.info(
|
|
188
|
+
get_missing_parameters_message(incompatible.missing_keys)
|
|
189
|
+
)
|
|
190
|
+
if incompatible.unexpected_keys:
|
|
191
|
+
logger.info(
|
|
192
|
+
get_unexpected_parameters_message(incompatible.unexpected_keys)
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
return model
|