dnt 0.2.1__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 +4 -1
- dnt/analysis/__init__.py +3 -1
- dnt/analysis/count.py +107 -0
- dnt/analysis/interaction2.py +518 -0
- dnt/analysis/position.py +12 -0
- dnt/analysis/stop.py +92 -33
- dnt/analysis/stop2.py +289 -0
- dnt/analysis/stop3.py +758 -0
- dnt/detect/__init__.py +1 -1
- dnt/detect/signal/detector.py +326 -0
- dnt/detect/timestamp.py +105 -0
- dnt/detect/yolov8/detector.py +182 -35
- dnt/detect/yolov8/segmentor.py +171 -0
- 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/__init__.py +4 -0
- dnt/filter/filter.py +450 -21
- dnt/label/__init__.py +1 -1
- dnt/label/labeler.py +215 -14
- 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 +3 -1
- 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 -21
- 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 +44 -27
- dnt/track/re_class.py +117 -0
- dnt/track/sort/sort.py +9 -7
- dnt/track/tracker.py +225 -20
- dnt-0.3.1.8.dist-info/METADATA +117 -0
- dnt-0.3.1.8.dist-info/RECORD +315 -0
- {dnt-0.2.1.dist-info → dnt-0.3.1.8.dist-info}/WHEEL +1 -1
- 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.1.dist-info/METADATA +0 -35
- dnt-0.2.1.dist-info/RECORD +0 -60
- /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
- {dnt-0.2.1.dist-info → dnt-0.3.1.8.dist-info/licenses}/LICENSE +0 -0
- {dnt-0.2.1.dist-info → dnt-0.3.1.8.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: liaoxingyu
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import torchvision.transforms as T
|
|
8
|
+
|
|
9
|
+
from .transforms import *
|
|
10
|
+
from .autoaugment import AutoAugment
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def build_transforms(cfg, is_train=True):
|
|
14
|
+
res = []
|
|
15
|
+
|
|
16
|
+
if is_train:
|
|
17
|
+
size_train = cfg.INPUT.SIZE_TRAIN
|
|
18
|
+
|
|
19
|
+
# crop
|
|
20
|
+
do_crop = cfg.INPUT.CROP.ENABLED
|
|
21
|
+
crop_size = cfg.INPUT.CROP.SIZE
|
|
22
|
+
crop_scale = cfg.INPUT.CROP.SCALE
|
|
23
|
+
crop_ratio = cfg.INPUT.CROP.RATIO
|
|
24
|
+
|
|
25
|
+
# augmix augmentation
|
|
26
|
+
do_augmix = cfg.INPUT.AUGMIX.ENABLED
|
|
27
|
+
augmix_prob = cfg.INPUT.AUGMIX.PROB
|
|
28
|
+
|
|
29
|
+
# auto augmentation
|
|
30
|
+
do_autoaug = cfg.INPUT.AUTOAUG.ENABLED
|
|
31
|
+
autoaug_prob = cfg.INPUT.AUTOAUG.PROB
|
|
32
|
+
|
|
33
|
+
# horizontal filp
|
|
34
|
+
do_flip = cfg.INPUT.FLIP.ENABLED
|
|
35
|
+
flip_prob = cfg.INPUT.FLIP.PROB
|
|
36
|
+
|
|
37
|
+
# padding
|
|
38
|
+
do_pad = cfg.INPUT.PADDING.ENABLED
|
|
39
|
+
padding_size = cfg.INPUT.PADDING.SIZE
|
|
40
|
+
padding_mode = cfg.INPUT.PADDING.MODE
|
|
41
|
+
|
|
42
|
+
# color jitter
|
|
43
|
+
do_cj = cfg.INPUT.CJ.ENABLED
|
|
44
|
+
cj_prob = cfg.INPUT.CJ.PROB
|
|
45
|
+
cj_brightness = cfg.INPUT.CJ.BRIGHTNESS
|
|
46
|
+
cj_contrast = cfg.INPUT.CJ.CONTRAST
|
|
47
|
+
cj_saturation = cfg.INPUT.CJ.SATURATION
|
|
48
|
+
cj_hue = cfg.INPUT.CJ.HUE
|
|
49
|
+
|
|
50
|
+
# random affine
|
|
51
|
+
do_affine = cfg.INPUT.AFFINE.ENABLED
|
|
52
|
+
|
|
53
|
+
# random erasing
|
|
54
|
+
do_rea = cfg.INPUT.REA.ENABLED
|
|
55
|
+
rea_prob = cfg.INPUT.REA.PROB
|
|
56
|
+
rea_value = cfg.INPUT.REA.VALUE
|
|
57
|
+
|
|
58
|
+
# random patch
|
|
59
|
+
do_rpt = cfg.INPUT.RPT.ENABLED
|
|
60
|
+
rpt_prob = cfg.INPUT.RPT.PROB
|
|
61
|
+
|
|
62
|
+
if do_autoaug:
|
|
63
|
+
res.append(T.RandomApply([AutoAugment()], p=autoaug_prob))
|
|
64
|
+
|
|
65
|
+
if size_train[0] > 0:
|
|
66
|
+
res.append(T.Resize(size_train[0] if len(size_train) == 1 else size_train, interpolation=3))
|
|
67
|
+
|
|
68
|
+
if do_crop:
|
|
69
|
+
res.append(T.RandomResizedCrop(size=crop_size[0] if len(crop_size) == 1 else crop_size,
|
|
70
|
+
interpolation=3,
|
|
71
|
+
scale=crop_scale, ratio=crop_ratio))
|
|
72
|
+
if do_pad:
|
|
73
|
+
res.extend([T.Pad(padding_size, padding_mode=padding_mode),
|
|
74
|
+
T.RandomCrop(size_train[0] if len(size_train) == 1 else size_train)])
|
|
75
|
+
if do_flip:
|
|
76
|
+
res.append(T.RandomHorizontalFlip(p=flip_prob))
|
|
77
|
+
|
|
78
|
+
if do_cj:
|
|
79
|
+
res.append(T.RandomApply([T.ColorJitter(cj_brightness, cj_contrast, cj_saturation, cj_hue)], p=cj_prob))
|
|
80
|
+
if do_affine:
|
|
81
|
+
res.append(T.RandomAffine(degrees=10, translate=None, scale=[0.9, 1.1], shear=0.1, resample=False,
|
|
82
|
+
fillcolor=0))
|
|
83
|
+
if do_augmix:
|
|
84
|
+
res.append(AugMix(prob=augmix_prob))
|
|
85
|
+
res.append(ToTensor())
|
|
86
|
+
if do_rea:
|
|
87
|
+
res.append(T.RandomErasing(p=rea_prob, value=rea_value))
|
|
88
|
+
if do_rpt:
|
|
89
|
+
res.append(RandomPatch(prob_happen=rpt_prob))
|
|
90
|
+
else:
|
|
91
|
+
size_test = cfg.INPUT.SIZE_TEST
|
|
92
|
+
do_crop = cfg.INPUT.CROP.ENABLED
|
|
93
|
+
crop_size = cfg.INPUT.CROP.SIZE
|
|
94
|
+
|
|
95
|
+
if size_test[0] > 0:
|
|
96
|
+
res.append(T.Resize(size_test[0] if len(size_test) == 1 else size_test, interpolation=3))
|
|
97
|
+
if do_crop:
|
|
98
|
+
res.append(T.CenterCrop(size=crop_size[0] if len(crop_size) == 1 else crop_size))
|
|
99
|
+
res.append(ToTensor())
|
|
100
|
+
return T.Compose(res)
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: liaoxingyu
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
import numpy as np
|
|
8
|
+
import torch
|
|
9
|
+
from PIL import Image, ImageOps, ImageEnhance
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
def to_tensor(pic):
|
|
13
|
+
"""Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.
|
|
14
|
+
|
|
15
|
+
See ``ToTensor`` for more details.
|
|
16
|
+
|
|
17
|
+
Args:
|
|
18
|
+
pic (PIL Image or numpy.ndarray): Image to be converted to tensor.
|
|
19
|
+
|
|
20
|
+
Returns:
|
|
21
|
+
Tensor: Converted image.
|
|
22
|
+
"""
|
|
23
|
+
if isinstance(pic, np.ndarray):
|
|
24
|
+
assert len(pic.shape) in (2, 3)
|
|
25
|
+
# handle numpy array
|
|
26
|
+
if pic.ndim == 2:
|
|
27
|
+
pic = pic[:, :, None]
|
|
28
|
+
|
|
29
|
+
img = torch.from_numpy(pic.transpose((2, 0, 1)))
|
|
30
|
+
# backward compatibility
|
|
31
|
+
if isinstance(img, torch.ByteTensor):
|
|
32
|
+
return img.float()
|
|
33
|
+
else:
|
|
34
|
+
return img
|
|
35
|
+
|
|
36
|
+
# handle PIL Image
|
|
37
|
+
if pic.mode == 'I':
|
|
38
|
+
img = torch.from_numpy(np.array(pic, np.int32, copy=False))
|
|
39
|
+
elif pic.mode == 'I;16':
|
|
40
|
+
img = torch.from_numpy(np.array(pic, np.int16, copy=False))
|
|
41
|
+
elif pic.mode == 'F':
|
|
42
|
+
img = torch.from_numpy(np.array(pic, np.float32, copy=False))
|
|
43
|
+
elif pic.mode == '1':
|
|
44
|
+
img = 255 * torch.from_numpy(np.array(pic, np.uint8, copy=False))
|
|
45
|
+
else:
|
|
46
|
+
img = torch.ByteTensor(torch.ByteStorage.from_buffer(pic.tobytes()))
|
|
47
|
+
# PIL image mode: L, LA, P, I, F, RGB, YCbCr, RGBA, CMYK
|
|
48
|
+
if pic.mode == 'YCbCr':
|
|
49
|
+
nchannel = 3
|
|
50
|
+
elif pic.mode == 'I;16':
|
|
51
|
+
nchannel = 1
|
|
52
|
+
else:
|
|
53
|
+
nchannel = len(pic.mode)
|
|
54
|
+
img = img.view(pic.size[1], pic.size[0], nchannel)
|
|
55
|
+
# put it from HWC to CHW format
|
|
56
|
+
# yikes, this transpose takes 80% of the loading time/CPU
|
|
57
|
+
img = img.transpose(0, 1).transpose(0, 2).contiguous()
|
|
58
|
+
if isinstance(img, torch.ByteTensor):
|
|
59
|
+
return img.float()
|
|
60
|
+
else:
|
|
61
|
+
return img
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
def int_parameter(level, maxval):
|
|
65
|
+
"""Helper function to scale `val` between 0 and maxval .
|
|
66
|
+
Args:
|
|
67
|
+
level: Level of the operation that will be between [0, `PARAMETER_MAX`].
|
|
68
|
+
maxval: Maximum value that the operation can have. This will be scaled to
|
|
69
|
+
level/PARAMETER_MAX.
|
|
70
|
+
Returns:
|
|
71
|
+
An int that results from scaling `maxval` according to `level`.
|
|
72
|
+
"""
|
|
73
|
+
return int(level * maxval / 10)
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
def float_parameter(level, maxval):
|
|
77
|
+
"""Helper function to scale `val` between 0 and maxval.
|
|
78
|
+
Args:
|
|
79
|
+
level: Level of the operation that will be between [0, `PARAMETER_MAX`].
|
|
80
|
+
maxval: Maximum value that the operation can have. This will be scaled to
|
|
81
|
+
level/PARAMETER_MAX.
|
|
82
|
+
Returns:
|
|
83
|
+
A float that results from scaling `maxval` according to `level`.
|
|
84
|
+
"""
|
|
85
|
+
return float(level) * maxval / 10.
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
def sample_level(n):
|
|
89
|
+
return np.random.uniform(low=0.1, high=n)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
def autocontrast(pil_img, *args):
|
|
93
|
+
return ImageOps.autocontrast(pil_img)
|
|
94
|
+
|
|
95
|
+
|
|
96
|
+
def equalize(pil_img, *args):
|
|
97
|
+
return ImageOps.equalize(pil_img)
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def posterize(pil_img, level, *args):
|
|
101
|
+
level = int_parameter(sample_level(level), 4)
|
|
102
|
+
return ImageOps.posterize(pil_img, 4 - level)
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
def rotate(pil_img, level, *args):
|
|
106
|
+
degrees = int_parameter(sample_level(level), 30)
|
|
107
|
+
if np.random.uniform() > 0.5:
|
|
108
|
+
degrees = -degrees
|
|
109
|
+
return pil_img.rotate(degrees, resample=Image.BILINEAR)
|
|
110
|
+
|
|
111
|
+
|
|
112
|
+
def solarize(pil_img, level, *args):
|
|
113
|
+
level = int_parameter(sample_level(level), 256)
|
|
114
|
+
return ImageOps.solarize(pil_img, 256 - level)
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def shear_x(pil_img, level):
|
|
118
|
+
level = float_parameter(sample_level(level), 0.3)
|
|
119
|
+
if np.random.uniform() > 0.5:
|
|
120
|
+
level = -level
|
|
121
|
+
return pil_img.transform(pil_img.size,
|
|
122
|
+
Image.AFFINE, (1, level, 0, 0, 1, 0),
|
|
123
|
+
resample=Image.BILINEAR)
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
def shear_y(pil_img, level):
|
|
127
|
+
level = float_parameter(sample_level(level), 0.3)
|
|
128
|
+
if np.random.uniform() > 0.5:
|
|
129
|
+
level = -level
|
|
130
|
+
return pil_img.transform(pil_img.size,
|
|
131
|
+
Image.AFFINE, (1, 0, 0, level, 1, 0),
|
|
132
|
+
resample=Image.BILINEAR)
|
|
133
|
+
|
|
134
|
+
|
|
135
|
+
def translate_x(pil_img, level):
|
|
136
|
+
level = int_parameter(sample_level(level), pil_img.size[0] / 3)
|
|
137
|
+
if np.random.random() > 0.5:
|
|
138
|
+
level = -level
|
|
139
|
+
return pil_img.transform(pil_img.size,
|
|
140
|
+
Image.AFFINE, (1, 0, level, 0, 1, 0),
|
|
141
|
+
resample=Image.BILINEAR)
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
def translate_y(pil_img, level):
|
|
145
|
+
level = int_parameter(sample_level(level), pil_img.size[1] / 3)
|
|
146
|
+
if np.random.random() > 0.5:
|
|
147
|
+
level = -level
|
|
148
|
+
return pil_img.transform(pil_img.size,
|
|
149
|
+
Image.AFFINE, (1, 0, 0, 0, 1, level),
|
|
150
|
+
resample=Image.BILINEAR)
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
# operation that overlaps with ImageNet-C's test set
|
|
154
|
+
def color(pil_img, level, *args):
|
|
155
|
+
level = float_parameter(sample_level(level), 1.8) + 0.1
|
|
156
|
+
return ImageEnhance.Color(pil_img).enhance(level)
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
# operation that overlaps with ImageNet-C's test set
|
|
160
|
+
def contrast(pil_img, level, *args):
|
|
161
|
+
level = float_parameter(sample_level(level), 1.8) + 0.1
|
|
162
|
+
return ImageEnhance.Contrast(pil_img).enhance(level)
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
# operation that overlaps with ImageNet-C's test set
|
|
166
|
+
def brightness(pil_img, level, *args):
|
|
167
|
+
level = float_parameter(sample_level(level), 1.8) + 0.1
|
|
168
|
+
return ImageEnhance.Brightness(pil_img).enhance(level)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
# operation that overlaps with ImageNet-C's test set
|
|
172
|
+
def sharpness(pil_img, level, *args):
|
|
173
|
+
level = float_parameter(sample_level(level), 1.8) + 0.1
|
|
174
|
+
return ImageEnhance.Sharpness(pil_img).enhance(level)
|
|
175
|
+
|
|
176
|
+
|
|
177
|
+
augmentations = [
|
|
178
|
+
autocontrast, equalize, posterize, rotate, solarize, shear_x, shear_y,
|
|
179
|
+
translate_x, translate_y
|
|
180
|
+
]
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: liaoxingyu
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
|
|
7
|
+
__all__ = ['ToTensor', 'RandomPatch', 'AugMix', ]
|
|
8
|
+
|
|
9
|
+
import math
|
|
10
|
+
import random
|
|
11
|
+
from collections import deque
|
|
12
|
+
|
|
13
|
+
import numpy as np
|
|
14
|
+
import torch
|
|
15
|
+
|
|
16
|
+
from .functional import to_tensor, augmentations
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
class ToTensor(object):
|
|
20
|
+
"""Convert a ``PIL Image`` or ``numpy.ndarray`` to tensor.
|
|
21
|
+
|
|
22
|
+
Converts a PIL Image or numpy.ndarray (H x W x C) in the range
|
|
23
|
+
[0, 255] to a torch.FloatTensor of shape (C x H x W) in the range [0.0, 255.0]
|
|
24
|
+
if the PIL Image belongs to one of the modes (L, LA, P, I, F, RGB, YCbCr, RGBA, CMYK, 1)
|
|
25
|
+
or if the numpy.ndarray has dtype = np.uint8
|
|
26
|
+
|
|
27
|
+
In the other cases, tensors are returned without scaling.
|
|
28
|
+
"""
|
|
29
|
+
|
|
30
|
+
def __call__(self, pic):
|
|
31
|
+
"""
|
|
32
|
+
Args:
|
|
33
|
+
pic (PIL Image or numpy.ndarray): Image to be converted to tensor.
|
|
34
|
+
|
|
35
|
+
Returns:
|
|
36
|
+
Tensor: Converted image.
|
|
37
|
+
"""
|
|
38
|
+
return to_tensor(pic)
|
|
39
|
+
|
|
40
|
+
def __repr__(self):
|
|
41
|
+
return self.__class__.__name__ + '()'
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
class RandomPatch(object):
|
|
45
|
+
"""Random patch data augmentation.
|
|
46
|
+
There is a patch pool that stores randomly extracted pathces from person images.
|
|
47
|
+
For each input image, RandomPatch
|
|
48
|
+
1) extracts a random patch and stores the patch in the patch pool;
|
|
49
|
+
2) randomly selects a patch from the patch pool and pastes it on the
|
|
50
|
+
input (at random position) to simulate occlusion.
|
|
51
|
+
Reference:
|
|
52
|
+
- Zhou et al. Omni-Scale Feature Learning for Person Re-Identification. ICCV, 2019.
|
|
53
|
+
- Zhou et al. Learning Generalisable Omni-Scale Representations
|
|
54
|
+
for Person Re-Identification. arXiv preprint, 2019.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
def __init__(self, prob_happen=0.5, pool_capacity=50000, min_sample_size=100,
|
|
58
|
+
patch_min_area=0.01, patch_max_area=0.5, patch_min_ratio=0.1, prob_flip_leftright=0.5,
|
|
59
|
+
):
|
|
60
|
+
self.prob_happen = prob_happen
|
|
61
|
+
|
|
62
|
+
self.patch_min_area = patch_min_area
|
|
63
|
+
self.patch_max_area = patch_max_area
|
|
64
|
+
self.patch_min_ratio = patch_min_ratio
|
|
65
|
+
|
|
66
|
+
self.prob_flip_leftright = prob_flip_leftright
|
|
67
|
+
|
|
68
|
+
self.patchpool = deque(maxlen=pool_capacity)
|
|
69
|
+
self.min_sample_size = min_sample_size
|
|
70
|
+
|
|
71
|
+
def generate_wh(self, W, H):
|
|
72
|
+
area = W * H
|
|
73
|
+
for attempt in range(100):
|
|
74
|
+
target_area = random.uniform(self.patch_min_area, self.patch_max_area) * area
|
|
75
|
+
aspect_ratio = random.uniform(self.patch_min_ratio, 1. / self.patch_min_ratio)
|
|
76
|
+
h = int(round(math.sqrt(target_area * aspect_ratio)))
|
|
77
|
+
w = int(round(math.sqrt(target_area / aspect_ratio)))
|
|
78
|
+
if w < W and h < H:
|
|
79
|
+
return w, h
|
|
80
|
+
return None, None
|
|
81
|
+
|
|
82
|
+
def transform_patch(self, patch):
|
|
83
|
+
if random.uniform(0, 1) > self.prob_flip_leftright:
|
|
84
|
+
patch = torch.flip(patch, dims=[2])
|
|
85
|
+
return patch
|
|
86
|
+
|
|
87
|
+
def __call__(self, img):
|
|
88
|
+
_, H, W = img.size() # original image size
|
|
89
|
+
|
|
90
|
+
# collect new patch
|
|
91
|
+
w, h = self.generate_wh(W, H)
|
|
92
|
+
if w is not None and h is not None:
|
|
93
|
+
x1 = random.randint(0, W - w)
|
|
94
|
+
y1 = random.randint(0, H - h)
|
|
95
|
+
new_patch = img[..., y1:y1 + h, x1:x1 + w]
|
|
96
|
+
self.patchpool.append(new_patch)
|
|
97
|
+
|
|
98
|
+
if len(self.patchpool) < self.min_sample_size:
|
|
99
|
+
return img
|
|
100
|
+
|
|
101
|
+
if random.uniform(0, 1) > self.prob_happen:
|
|
102
|
+
return img
|
|
103
|
+
|
|
104
|
+
# paste a randomly selected patch on a random position
|
|
105
|
+
patch = random.sample(self.patchpool, 1)[0]
|
|
106
|
+
_, patchH, patchW = patch.size()
|
|
107
|
+
x1 = random.randint(0, W - patchW)
|
|
108
|
+
y1 = random.randint(0, H - patchH)
|
|
109
|
+
patch = self.transform_patch(patch)
|
|
110
|
+
img[..., y1:y1 + patchH, x1:x1 + patchW] = patch
|
|
111
|
+
|
|
112
|
+
return img
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
class AugMix(object):
|
|
116
|
+
""" Perform AugMix augmentation and compute mixture.
|
|
117
|
+
"""
|
|
118
|
+
|
|
119
|
+
def __init__(self, prob=0.5, aug_prob_coeff=0.1, mixture_width=3, mixture_depth=1, aug_severity=1):
|
|
120
|
+
"""
|
|
121
|
+
Args:
|
|
122
|
+
prob: Probability of taking augmix
|
|
123
|
+
aug_prob_coeff: Probability distribution coefficients.
|
|
124
|
+
mixture_width: Number of augmentation chains to mix per augmented example.
|
|
125
|
+
mixture_depth: Depth of augmentation chains. -1 denotes stochastic depth in [1, 3]'
|
|
126
|
+
aug_severity: Severity of underlying augmentation operators (between 1 to 10).
|
|
127
|
+
"""
|
|
128
|
+
# fmt: off
|
|
129
|
+
self.prob = prob
|
|
130
|
+
self.aug_prob_coeff = aug_prob_coeff
|
|
131
|
+
self.mixture_width = mixture_width
|
|
132
|
+
self.mixture_depth = mixture_depth
|
|
133
|
+
self.aug_severity = aug_severity
|
|
134
|
+
self.augmentations = augmentations
|
|
135
|
+
# fmt: on
|
|
136
|
+
|
|
137
|
+
def __call__(self, image):
|
|
138
|
+
"""Perform AugMix augmentations and compute mixture.
|
|
139
|
+
|
|
140
|
+
Returns:
|
|
141
|
+
mixed: Augmented and mixed image.
|
|
142
|
+
"""
|
|
143
|
+
if random.random() > self.prob:
|
|
144
|
+
# Avoid the warning: the given NumPy array is not writeable
|
|
145
|
+
return np.asarray(image).copy()
|
|
146
|
+
|
|
147
|
+
ws = np.float32(
|
|
148
|
+
np.random.dirichlet([self.aug_prob_coeff] * self.mixture_width))
|
|
149
|
+
m = np.float32(np.random.beta(self.aug_prob_coeff, self.aug_prob_coeff))
|
|
150
|
+
|
|
151
|
+
mix = np.zeros([image.size[1], image.size[0], 3])
|
|
152
|
+
for i in range(self.mixture_width):
|
|
153
|
+
image_aug = image.copy()
|
|
154
|
+
depth = self.mixture_depth if self.mixture_depth > 0 else np.random.randint(1, 4)
|
|
155
|
+
for _ in range(depth):
|
|
156
|
+
op = np.random.choice(self.augmentations)
|
|
157
|
+
image_aug = op(image_aug, self.aug_severity)
|
|
158
|
+
mix += ws[i] * np.asarray(image_aug)
|
|
159
|
+
|
|
160
|
+
mixed = (1 - m) * image + m * mix
|
|
161
|
+
return mixed.astype(np.uint8)
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# encoding: utf-8
|
|
2
|
+
"""
|
|
3
|
+
@author: liaoxingyu
|
|
4
|
+
@contact: sherlockliao01@gmail.com
|
|
5
|
+
"""
|
|
6
|
+
from .train_loop import *
|
|
7
|
+
|
|
8
|
+
__all__ = [k for k in globals().keys() if not k.startswith("_")]
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
# prefer to let hooks and defaults live in separate namespaces (therefore not in __all__)
|
|
12
|
+
# but still make them available here
|
|
13
|
+
from .hooks import *
|
|
14
|
+
from .defaults import *
|
|
15
|
+
from .launch import *
|