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,518 @@
|
|
|
1
|
+
"""
|
|
2
|
+
This module is used to analyze the interaction between two tracks.
|
|
3
|
+
Author: Zhenyu Wang
|
|
4
|
+
Date: 2023/10/20
|
|
5
|
+
Email: wonstran@hotmail.com
|
|
6
|
+
Updates:
|
|
7
|
+
2025/03/19: Add the function of nearmiss based on PET
|
|
8
|
+
2023/10/20: Initial version
|
|
9
|
+
"""
|
|
10
|
+
from shapely.geometry import Point, Polygon, LineString, box
|
|
11
|
+
from shapely import intersection, distance, intersects
|
|
12
|
+
from shapelysmooth import taubin_smooth, chaikin_smooth, catmull_rom_smooth
|
|
13
|
+
import geopandas as gpd, pandas as pd
|
|
14
|
+
from tqdm import tqdm
|
|
15
|
+
import numpy as np
|
|
16
|
+
from dnt.label.labeler2 import Labeler
|
|
17
|
+
import os
|
|
18
|
+
|
|
19
|
+
class YieldAnalyzer:
|
|
20
|
+
def __init__(self,
|
|
21
|
+
waiting_dist_p:int=600,
|
|
22
|
+
waiting_dist_y:int=300,
|
|
23
|
+
leading_p:bool=False,
|
|
24
|
+
leading_axis_p:str='y',
|
|
25
|
+
leading_y:bool=True,
|
|
26
|
+
leading_axis_y:str='x',
|
|
27
|
+
yield_gap:int=10,
|
|
28
|
+
fps:int=30,
|
|
29
|
+
ref_point='bc',
|
|
30
|
+
ref_offset:tuple=(0,0),
|
|
31
|
+
filter_buffer:int=0,
|
|
32
|
+
p_zone:Polygon=None,
|
|
33
|
+
y_zone:Polygon=None) -> None:
|
|
34
|
+
'''
|
|
35
|
+
Parameters:
|
|
36
|
+
threshold: the hyperparameter to determine if a yield event (frame difference <=yield_gap*fps), default is 3 seconds
|
|
37
|
+
fps: frames per sencond, default is 30
|
|
38
|
+
ref_point: the reference point for lane recognition
|
|
39
|
+
br (buttom-right, default), bl (bottom-left), bc (bottom-center)
|
|
40
|
+
tl (top-left), tr (top-right), tc (top-center)
|
|
41
|
+
cc (center-center), cl (center-left), cr (center-right)
|
|
42
|
+
ref_offset: the offset (x, y) for reference point, default is (0, 0)
|
|
43
|
+
filter_buffer: the buffer between two track frames, default is 0 means tracks will be paired only if two tracks are overlapped in time
|
|
44
|
+
'''
|
|
45
|
+
self.waiting_dist_p = waiting_dist_p
|
|
46
|
+
self.waiting_dist_y = waiting_dist_y
|
|
47
|
+
self.leading_p = leading_p
|
|
48
|
+
self.leading_axis_p = leading_axis_p
|
|
49
|
+
self.leading_y = leading_y
|
|
50
|
+
self.leading_axis_y = leading_axis_y
|
|
51
|
+
self.yield_gap = yield_gap
|
|
52
|
+
self.fps = fps
|
|
53
|
+
self.ref_point = ref_point
|
|
54
|
+
self.ref_offset = ref_offset
|
|
55
|
+
self.filter_buffer = filter_buffer
|
|
56
|
+
self.p_zone = p_zone
|
|
57
|
+
self.y_zone = y_zone
|
|
58
|
+
|
|
59
|
+
def analyze(self, tracks_p:pd.DataFrame, tracks_y:pd.DataFrame, name_p:str='', name_y:str=''):
|
|
60
|
+
'''
|
|
61
|
+
Parameters:
|
|
62
|
+
tracks_p: tracks with priority
|
|
63
|
+
tracks_y: tracks should yield to tracks_p
|
|
64
|
+
'''
|
|
65
|
+
tracks_p = YieldAnalyzer.add_field_names(tracks_p)
|
|
66
|
+
tracks_y = YieldAnalyzer.add_field_names(tracks_y)
|
|
67
|
+
|
|
68
|
+
tracks_p = self.gen_ref(tracks_p, info=name_p)
|
|
69
|
+
tracks_y = self.gen_ref(tracks_y, info=name_y)
|
|
70
|
+
|
|
71
|
+
trajectories_p = self.gen_trajectory(tracks_p, info=name_p)
|
|
72
|
+
trajectories_y = self.gen_trajectory(tracks_y, info=name_y)
|
|
73
|
+
|
|
74
|
+
intersect_pairs = self.scan_intersections(trajectories_p, trajectories_y)
|
|
75
|
+
if (self.p_zone is not None) and (self.y_zone is not None):
|
|
76
|
+
intersect_pairs = self.scan_yield_events_byzone(intersect_pairs, tracks_p, tracks_y)
|
|
77
|
+
else:
|
|
78
|
+
intersect_pairs = self.scan_yield_events(intersect_pairs, tracks_p, tracks_y)
|
|
79
|
+
|
|
80
|
+
return intersect_pairs
|
|
81
|
+
|
|
82
|
+
def gen_ref(self, tracks:pd.DataFrame, info:str='', video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
83
|
+
if video_index and video_tot:
|
|
84
|
+
tqdm.pandas(desc='Generating ref {}, {} of {}'.format(info, video_index, video_tot), unit='frames')
|
|
85
|
+
else:
|
|
86
|
+
tqdm.pandas(desc='Generating ref {}'.format(info), unit='frames')
|
|
87
|
+
|
|
88
|
+
if self.ref_point == 'cc':
|
|
89
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w']//2 + self.ref_offset[0],
|
|
90
|
+
track['y'] + track['h']//2 + self.ref_offset[1]]), axis=1)
|
|
91
|
+
elif self.ref_point == 'tc':
|
|
92
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w']//2 + self.ref_offset[0],
|
|
93
|
+
track['y'] + self.ref_offset[1]]), axis=1)
|
|
94
|
+
elif self.ref_point == 'bc':
|
|
95
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w']//2 + self.ref_offset[0],
|
|
96
|
+
track['y'] + track['h'] + self.ref_offset[1]]), axis=1)
|
|
97
|
+
elif self.ref_point == 'cl':
|
|
98
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + self.ref_offset[0],
|
|
99
|
+
track['y'] + track['h']//2 + self.ref_offset[1]]), axis=1)
|
|
100
|
+
elif self.ref_point == 'cr':
|
|
101
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w'] + self.ref_offset[0],
|
|
102
|
+
track['y'] + track['h']//2 + self.ref_offset[1]]), axis=1)
|
|
103
|
+
elif self.ref_point == 'tl':
|
|
104
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + self.ref_offset[0],
|
|
105
|
+
track['y'] + self.ref_offset[1]]), axis=1)
|
|
106
|
+
elif self.ref_point == 'tr':
|
|
107
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w'] + self.ref_offset[0],
|
|
108
|
+
track['y'] + self.ref_offset[1]]), axis=1)
|
|
109
|
+
elif self.ref_point == 'bl':
|
|
110
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + self.ref_offset[0],
|
|
111
|
+
track['y'] + tracks['h'] + self.ref_offset[1]]), axis=1)
|
|
112
|
+
elif self.ref_point == 'br':
|
|
113
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w'] + self.ref_offset[0],
|
|
114
|
+
track['y'] + track['h'] + self.ref_offset[1]]), axis=1)
|
|
115
|
+
else:
|
|
116
|
+
tracks[['ref_x', 'ref_y']] = tracks.progress_apply(lambda track: pd.Series([track['x'] + track['w']//2 + self.ref_offset[0],
|
|
117
|
+
track['y'] + track['h'] + self.ref_offset[1]]), axis=1)
|
|
118
|
+
|
|
119
|
+
return tracks
|
|
120
|
+
|
|
121
|
+
def gen_trajectory(self, tracks:pd.DataFrame, info:str='', video_index:int=None, video_tot:int=None)->gpd.GeoDataFrame:
|
|
122
|
+
|
|
123
|
+
ids = tracks['track'].unique()
|
|
124
|
+
results = []
|
|
125
|
+
lines = []
|
|
126
|
+
pbar = tqdm(total=len(ids), unit='track')
|
|
127
|
+
if video_index and video_tot:
|
|
128
|
+
pbar.desc = 'Generating trajectory {}, {} of {}'.format(info, video_index, video_tot)
|
|
129
|
+
else:
|
|
130
|
+
pbar.desc = 'Generating trajectory {}'.format(info)
|
|
131
|
+
|
|
132
|
+
for id in ids:
|
|
133
|
+
frames = tracks[tracks['track']==id].sort_values(by=['frame'])
|
|
134
|
+
line = LineString(list(zip(frames['ref_x'].values.tolist(), frames['ref_y'].values.tolist())))
|
|
135
|
+
results.append([id, frames['frame'].values, frames['ref_x'].values, frames['ref_y'].values])
|
|
136
|
+
lines.append(line)
|
|
137
|
+
pbar.update()
|
|
138
|
+
pbar.close()
|
|
139
|
+
|
|
140
|
+
df = pd.DataFrame(results, columns=['track', 'frames', 'ref_x', 'ref_y'])
|
|
141
|
+
return gpd.GeoDataFrame(df, geometry=lines)
|
|
142
|
+
|
|
143
|
+
def scan_intersections(self, trajectories_p:gpd.GeoDataFrame, trajectories_y:gpd.GeoDataFrame,
|
|
144
|
+
video_index:int=None, video_tot:int=None):
|
|
145
|
+
|
|
146
|
+
results = []
|
|
147
|
+
points = []
|
|
148
|
+
buffer = self.filter_buffer*self.fps
|
|
149
|
+
|
|
150
|
+
pbar = tqdm(total=len(trajectories_p)*len(trajectories_y), unit=' pair')
|
|
151
|
+
if video_index and video_tot:
|
|
152
|
+
pbar.desc = 'Scan intesections {} of {}'.format(video_index, video_tot)
|
|
153
|
+
else:
|
|
154
|
+
pbar.desc = 'Scan intesections'
|
|
155
|
+
for index1, trj_p in trajectories_p.iterrows():
|
|
156
|
+
for index2, trj_y in trajectories_y.iterrows():
|
|
157
|
+
'''
|
|
158
|
+
if (trj_p['track'] == 511) and (trj_y['track'] == 132590):
|
|
159
|
+
print(trj_p['frames'].min(), trj_p['frames'].max())
|
|
160
|
+
print(trj_y['frames'].min(), trj_y['frames'].max())
|
|
161
|
+
input('...')
|
|
162
|
+
'''
|
|
163
|
+
|
|
164
|
+
if ((trj_p['frames'].min() > (trj_y['frames'].max() + buffer)) or
|
|
165
|
+
(trj_y['frames'].min() > (trj_p['frames'].max() + buffer))):
|
|
166
|
+
pass
|
|
167
|
+
else:
|
|
168
|
+
geo_intersect = intersection(trj_p.geometry, trj_y.geometry)
|
|
169
|
+
if not geo_intersect.is_empty:
|
|
170
|
+
point = self.__recursion(geo_intersect)
|
|
171
|
+
point_xy = np.array([point.x, point.y])
|
|
172
|
+
'''
|
|
173
|
+
if (trj_p['track'] == 2414) & (trj_y['track'] == 386456):
|
|
174
|
+
plt.gca().invert_yaxis()
|
|
175
|
+
plt.plot(*trj_p.geometry.xy, color='red')
|
|
176
|
+
plt.plot(*trj_y.geometry.xy, color='green')
|
|
177
|
+
plt.scatter(*point.xy)
|
|
178
|
+
plt.savefig('/mnt/d/a.jpg')
|
|
179
|
+
|
|
180
|
+
import cv2
|
|
181
|
+
img = cv2.imread('/mnt/d/b.png')
|
|
182
|
+
for x, y in list(zip(trj_p['ref_x'], trj_p['ref_y'])):
|
|
183
|
+
img = cv2.circle(img, (x, y), 1, (0, 0, 255))
|
|
184
|
+
for x, y in list(zip(trj_y['ref_x'], trj_y['ref_y'])):
|
|
185
|
+
img = cv2.circle(img, (x, y), 1, (0, 255, 0))
|
|
186
|
+
img = cv2.circle(img, (int(point.x), int(point.y)), 5, (255, 255, 255), thickness=-1)
|
|
187
|
+
print(int(point.x), int(point.y))
|
|
188
|
+
cv2.imwrite('/mnt/d/c.jpg', img)
|
|
189
|
+
input('...')
|
|
190
|
+
'''
|
|
191
|
+
ref_pxy = np.array(list(zip(trj_p['ref_x'], trj_p['ref_y'])))
|
|
192
|
+
index_p = self.__get_closest_index(ref_pxy, point_xy)
|
|
193
|
+
frame_p = trj_p['frames'][index_p]
|
|
194
|
+
|
|
195
|
+
ref_yxy = np.array(list(zip(trj_y['ref_x'], trj_y['ref_y'])))
|
|
196
|
+
index_y = self.__get_closest_index(ref_yxy, point_xy)
|
|
197
|
+
frame_y = trj_y['frames'][index_y]
|
|
198
|
+
|
|
199
|
+
results.append([trj_p['track'], frame_p, trj_y['track'], frame_y, frame_y-frame_p])
|
|
200
|
+
points.append(point)
|
|
201
|
+
pbar.update()
|
|
202
|
+
|
|
203
|
+
pbar.close()
|
|
204
|
+
|
|
205
|
+
df = pd.DataFrame(results, columns=['track_p', 'frame_p', 'track_y', 'frame_y', 'frame_gap'])
|
|
206
|
+
return gpd.GeoDataFrame(df, geometry=points)
|
|
207
|
+
|
|
208
|
+
def scan_yield_events(self, pairs:gpd.GeoDataFrame, tracks_p:gpd.GeoDataFrame, tracks_y:gpd.GeoDataFrame,
|
|
209
|
+
video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
210
|
+
|
|
211
|
+
pbar = tqdm(total=len(pairs), unit=' pair')
|
|
212
|
+
if video_index and video_tot:
|
|
213
|
+
pbar.desc = 'Scan events {} of {}'.format(video_index, video_tot)
|
|
214
|
+
else:
|
|
215
|
+
pbar.desc = 'Scan events'
|
|
216
|
+
for index, pair in pairs.iterrows():
|
|
217
|
+
|
|
218
|
+
if pair['frame_p'] < pair['frame_y']:
|
|
219
|
+
|
|
220
|
+
selected = tracks_y[(tracks_y['track']==pair['track_y']) & (tracks_y['frame']<=pair['frame_y'])].copy() # find the frames for track_y before reaching conflict point
|
|
221
|
+
selected['dif'] = selected['frame'].apply(lambda f: abs(f - pair['frame_p'])) # calculate the frame difference between each before frame and the conflict frame
|
|
222
|
+
selected = selected[selected['dif']<=self.yield_gap] # the frame difference should <= self.yield_gap
|
|
223
|
+
closest = selected[selected['dif']==selected['dif'].min()] # find the closest frame
|
|
224
|
+
if len(closest)>0:
|
|
225
|
+
closest_point = Point(closest['x'].iloc[0]+closest['w'].iloc[0]/2,
|
|
226
|
+
closest['y'].iloc[0]+closest['h'].iloc[0]) # find the cloest point
|
|
227
|
+
dist = distance(closest_point, pair.geometry) # calculate the distance
|
|
228
|
+
pairs.at[index, 'dist_y'] = dist
|
|
229
|
+
inwaiting = 1 if dist<=self.waiting_dist_y else 0
|
|
230
|
+
|
|
231
|
+
if self.leading_y:
|
|
232
|
+
isleading = 1 if self.__is_leading(pair['track_y'], closest['frame'].iloc[0], closest['x'].iloc[0],
|
|
233
|
+
closest['y'].iloc[0], pair.geometry.x, pair.geometry.y, tracks_y, self.leading_axis_y) else 0
|
|
234
|
+
else:
|
|
235
|
+
isleading = 1
|
|
236
|
+
|
|
237
|
+
if (inwaiting == 1) and (isleading == 1):
|
|
238
|
+
pairs.at[index, 'event'] = 'yield'
|
|
239
|
+
|
|
240
|
+
pairs.at[index, 'closest_frame'] = closest['frame'].iloc[0]
|
|
241
|
+
|
|
242
|
+
elif pair['frame_p'] >= pair['frame_y']:
|
|
243
|
+
selected = tracks_p[(tracks_p['track']==pair['track_p']) & (tracks_p['frame']<=pair['frame_p'])].copy()
|
|
244
|
+
selected['dif'] = selected['frame'].apply(lambda f: abs(f - pair['frame_y']))
|
|
245
|
+
selected = selected[selected['dif']<=self.yield_gap]
|
|
246
|
+
closest = selected[selected['dif']==selected['dif'].min()]
|
|
247
|
+
if len(closest)>0:
|
|
248
|
+
closest_point = Point(closest['x'].iloc[0]+closest['w'].iloc[0]/2,
|
|
249
|
+
closest['y'].iloc[0]+closest['h'].iloc[0])
|
|
250
|
+
dist = distance(closest_point, pair.geometry)
|
|
251
|
+
inwaiting = 1 if dist<=self.waiting_dist_p else 0
|
|
252
|
+
pairs.at[index, 'dist_p'] = dist
|
|
253
|
+
if self.leading_p:
|
|
254
|
+
isleading = 1 if self.__is_leading(pair['track_p'], closest['frame'].iloc[0], closest['x'].iloc[0],
|
|
255
|
+
closest['y'].iloc[0], pair.geometry.x, pair.geometry.y, tracks_p, self.leading_axis_p) else 0
|
|
256
|
+
else:
|
|
257
|
+
isleading = 1
|
|
258
|
+
|
|
259
|
+
if (inwaiting == 1) and (isleading == 1):
|
|
260
|
+
pairs.at[index, 'event'] = 'not_yield'
|
|
261
|
+
|
|
262
|
+
pairs.at[index, 'closest_frame'] = closest['frame'].iloc[0]
|
|
263
|
+
|
|
264
|
+
pbar.update()
|
|
265
|
+
|
|
266
|
+
pbar.close()
|
|
267
|
+
|
|
268
|
+
return self.__export(pairs)
|
|
269
|
+
|
|
270
|
+
def scan_yield_events_byzone(self, pairs:gpd.GeoDataFrame, tracks_p:gpd.GeoDataFrame, tracks_y:gpd.GeoDataFrame,
|
|
271
|
+
video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
272
|
+
|
|
273
|
+
pbar = tqdm(total=len(pairs), unit=' pair')
|
|
274
|
+
if video_index and video_tot:
|
|
275
|
+
pbar.desc = 'Scan events {} of {}'.format(video_index, video_tot)
|
|
276
|
+
else:
|
|
277
|
+
pbar.desc = 'Scan events'
|
|
278
|
+
for index, pair in pairs.iterrows():
|
|
279
|
+
|
|
280
|
+
if pair['frame_p'] < pair['frame_y']:
|
|
281
|
+
|
|
282
|
+
selected = tracks_y[(tracks_y['track']==pair['track_y']) & (tracks_y['frame']<=pair['frame_y'])].copy() # find the frames for track_y before reaching conflict point
|
|
283
|
+
selected['dif'] = selected['frame'].apply(lambda f: abs(f - pair['frame_p'])) # calculate the frame difference between each before frame and the conflict frame
|
|
284
|
+
selected = selected[selected['dif']<=self.yield_gap] # the frame difference should <= self.yield_gap
|
|
285
|
+
closest = selected[selected['dif']==selected['dif'].min()] # find the closest frame
|
|
286
|
+
if len(closest)>0:
|
|
287
|
+
x, y, w, h = closest['x'].iloc[0], closest['y'].iloc[0], closest['w'].iloc[0], closest['h'].iloc[0]
|
|
288
|
+
closest_bbox = Polygon([(x, y), (x + w, y), (x + w, y + h), (x, y + h)])
|
|
289
|
+
|
|
290
|
+
inwaiting = 1 if intersects(closest_bbox, self.y_zone) else 0
|
|
291
|
+
pairs.at[index, 'dist_y'] = -1
|
|
292
|
+
if self.leading_y:
|
|
293
|
+
isleading = 1 if self.__is_leading(pair['track_y'], closest['frame'].iloc[0], closest['x'].iloc[0],
|
|
294
|
+
closest['y'].iloc[0], pair.geometry.x, pair.geometry.y, tracks_y, self.leading_axis_y) else 0
|
|
295
|
+
else:
|
|
296
|
+
isleading = 1
|
|
297
|
+
|
|
298
|
+
if (inwaiting == 1) and (isleading == 1):
|
|
299
|
+
pairs.at[index, 'event'] = 'yield'
|
|
300
|
+
|
|
301
|
+
pairs.at[index, 'closest_frame'] = closest['frame'].iloc[0]
|
|
302
|
+
|
|
303
|
+
elif pair['frame_p'] >= pair['frame_y']:
|
|
304
|
+
selected = tracks_p[(tracks_p['track']==pair['track_p']) & (tracks_p['frame']<=pair['frame_p'])].copy()
|
|
305
|
+
selected['dif'] = selected['frame'].apply(lambda f: abs(f - pair['frame_y']))
|
|
306
|
+
selected = selected[selected['dif']<=self.yield_gap]
|
|
307
|
+
closest = selected[selected['dif']==selected['dif'].min()]
|
|
308
|
+
if len(closest)>0:
|
|
309
|
+
x, y, w, h = closest['x'].iloc[0], closest['y'].iloc[0], closest['w'].iloc[0], closest['h'].iloc[0]
|
|
310
|
+
closest_bbox = Polygon([(x, y), (x + w, y), (x + w, y + h), (x, y + h)])
|
|
311
|
+
|
|
312
|
+
inwaiting = 1 if intersects(closest_bbox, self.p_zone) else 0
|
|
313
|
+
pairs.at[index, 'dist_p'] = -1
|
|
314
|
+
if self.leading_p:
|
|
315
|
+
isleading = 1 if self.__is_leading(pair['track_p'], closest['frame'].iloc[0], closest['x'].iloc[0],
|
|
316
|
+
closest['y'].iloc[0], pair.geometry.x, pair.geometry.y, tracks_p, self.leading_axis_p) else 0
|
|
317
|
+
else:
|
|
318
|
+
isleading = 1
|
|
319
|
+
|
|
320
|
+
if (inwaiting == 1) and (isleading == 1):
|
|
321
|
+
pairs.at[index, 'event'] = 'not_yield'
|
|
322
|
+
|
|
323
|
+
pairs.at[index, 'closest_frame'] = closest['frame'].iloc[0]
|
|
324
|
+
|
|
325
|
+
pbar.update()
|
|
326
|
+
|
|
327
|
+
pbar.close()
|
|
328
|
+
|
|
329
|
+
return self.__export(pairs)
|
|
330
|
+
|
|
331
|
+
|
|
332
|
+
def __export(self, pairs:gpd.GeoDataFrame):
|
|
333
|
+
pairs['int_x'] = pairs.geometry.x
|
|
334
|
+
pairs['int_y'] = pairs.geometry.y
|
|
335
|
+
return pd.DataFrame(pairs.drop(columns=['geometry']))
|
|
336
|
+
|
|
337
|
+
def __recursion(self, intersect):
|
|
338
|
+
if intersect.geom_type == 'Point':
|
|
339
|
+
return Point(intersect.coords[0])
|
|
340
|
+
|
|
341
|
+
elif intersect.geom_type == 'MultiPoint':
|
|
342
|
+
return Point(intersect.geoms[0].x, intersect.geoms[0].y)
|
|
343
|
+
|
|
344
|
+
elif intersect.geom_type == 'LineString':
|
|
345
|
+
return Point(intersect.coords[0])
|
|
346
|
+
|
|
347
|
+
elif intersect.geom_type == 'MultiLineString':
|
|
348
|
+
return Point(intersect.geoms[0].coords[0])
|
|
349
|
+
|
|
350
|
+
else:
|
|
351
|
+
for geom in intersect.geoms:
|
|
352
|
+
return self.__recursion(geom)
|
|
353
|
+
|
|
354
|
+
def __get_closest_index(self, ref:np.array, point:np.array) -> int:
|
|
355
|
+
return np.argmin(np.sqrt(np.sum(np.square(ref - point), axis=1)))
|
|
356
|
+
|
|
357
|
+
def __is_leading(self, track_id:int, frame_close:int, close_x:int, close_y:int, int_x:int, int_y:int,
|
|
358
|
+
tracks:gpd.GeoDataFrame, leading_axis:str):
|
|
359
|
+
|
|
360
|
+
min_x = min(close_x, int_x)
|
|
361
|
+
max_x = max(close_x, int_x)
|
|
362
|
+
min_y = min(close_y, int_y)
|
|
363
|
+
max_y = max(close_y, int_y)
|
|
364
|
+
if leading_axis == 'x':
|
|
365
|
+
leadings = tracks[(tracks['track']!=track_id) & (tracks['frame']==frame_close) &
|
|
366
|
+
(tracks['ref_x']>=min_x) & (tracks['ref_x']<=max_x)]
|
|
367
|
+
elif leading_axis == 'y':
|
|
368
|
+
leadings = tracks[(tracks['track']!=track_id) & (tracks['frame']==frame_close) &
|
|
369
|
+
(tracks['ref_y']>=min_y) & (tracks['ref_y']<=max_y)]
|
|
370
|
+
elif leading_axis == 'xy':
|
|
371
|
+
leadings = tracks[(tracks['track']!=track_id) & (tracks['frame']==frame_close) &
|
|
372
|
+
(tracks['ref_x']>=min_x) & (tracks['ref_x']<=max_x) &
|
|
373
|
+
(tracks['ref_y']>=min_y) & (tracks['ref_y']<=max_y)]
|
|
374
|
+
|
|
375
|
+
if len(leadings) > 0:
|
|
376
|
+
return False
|
|
377
|
+
else:
|
|
378
|
+
return True
|
|
379
|
+
|
|
380
|
+
def __get_waiting_trj_y(self, track_id:int, frame_id_p:int, frame_id_y:int, intersect_point:Point, trajectories:gpd.GeoDataFrame) -> any:
|
|
381
|
+
|
|
382
|
+
result = -1
|
|
383
|
+
if frame_id_p < frame_id_y:
|
|
384
|
+
selected = trajectories[trajectories['track']==track_id]
|
|
385
|
+
df = pd.DataFrame(np.vstack((selected['frames'].tolist(), selected['ref_x'].tolist(), selected['ref_y'].tolist())).T,
|
|
386
|
+
columns=['frame', 'x', 'y'])
|
|
387
|
+
df = df.loc[df['frame']<=frame_id_y]
|
|
388
|
+
df['dif'] = df['frame'].apply(lambda f: abs((f - frame_id_p)))
|
|
389
|
+
closest = df[df['dif']==df['dif'].min()]
|
|
390
|
+
closest_point = Point(closest['x'].ioc[0], closest['y'].ioc[0])
|
|
391
|
+
dist = distance(closest, intersect_point)
|
|
392
|
+
|
|
393
|
+
return result
|
|
394
|
+
|
|
395
|
+
@staticmethod
|
|
396
|
+
def add_field_names(tracks: pd.DataFrame)->pd.DataFrame:
|
|
397
|
+
if len(tracks.columns)==10:
|
|
398
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3','r4']
|
|
399
|
+
tracks['ref_x'] = -1
|
|
400
|
+
tracks['ref_y'] = -1
|
|
401
|
+
elif len(tracks.columns) == 12:
|
|
402
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3','r4',
|
|
403
|
+
'ref_x', 'ref_y']
|
|
404
|
+
else:
|
|
405
|
+
raise Exception('The number of fields is invalid.')
|
|
406
|
+
return tracks
|
|
407
|
+
|
|
408
|
+
@staticmethod
|
|
409
|
+
def draw_event_clips(yields:pd.DataFrame, tracks_p:pd.DataFrame, tracks_y:pd.DataFrame, input_video:str, out_path:str,
|
|
410
|
+
method:str='all', random_number:int=10, event_list:list=None, size:int=1, thick:int=2, padding:int=0,
|
|
411
|
+
show_track:bool=False, show_desc:bool=False, verbose:bool=True,
|
|
412
|
+
video_index:int=None, video_tot:int=None):
|
|
413
|
+
'''
|
|
414
|
+
Parameters:
|
|
415
|
+
- yields: the dataframe of stop events
|
|
416
|
+
- tracks_p: the dataframe of tracks with priority
|
|
417
|
+
- tracks_y: the dataframe of tracks should yield
|
|
418
|
+
- input_video: the raw video file, if None, generate the label files only
|
|
419
|
+
- out_path: the folder for outputing track clips
|
|
420
|
+
- method: 'all' (default) - all tracks, 'specify' - specify events,
|
|
421
|
+
'yield' - yield events, 'not_yield' - non-yield events, 'none' - non interaction events
|
|
422
|
+
- random_number: the number of track ids if method == 'random'
|
|
423
|
+
- event_list: the list of events [(track_p_id, track_y_id)] if method == 'specify'
|
|
424
|
+
- size: font size, default is 1
|
|
425
|
+
- thick: line thinckness, defualt is 2
|
|
426
|
+
- padding: add addtional frames at beggining and ending, default is 0
|
|
427
|
+
- show_track: show track id, default is False
|
|
428
|
+
- show_desc: show event desc, default is Falase
|
|
429
|
+
- verbose: if show progressing bar, default is True
|
|
430
|
+
- video_idex: the index of the video in processing
|
|
431
|
+
- video_tot: the total number of videos
|
|
432
|
+
|
|
433
|
+
Return:
|
|
434
|
+
- A list of dataframes for labels, ['frame','type','coords','color','size','thick','desc']
|
|
435
|
+
'''
|
|
436
|
+
|
|
437
|
+
tracks_p = YieldAnalyzer.add_field_names(tracks_p)
|
|
438
|
+
tracks_y = YieldAnalyzer.add_field_names(tracks_y)
|
|
439
|
+
|
|
440
|
+
tracks_p_grouped = tracks_p.groupby('track')
|
|
441
|
+
tracks_y_grouped = tracks_y.groupby('track')
|
|
442
|
+
|
|
443
|
+
|
|
444
|
+
if method == 'all':
|
|
445
|
+
events = yields
|
|
446
|
+
elif method == 'specify':
|
|
447
|
+
events = []
|
|
448
|
+
for p, y in event_list:
|
|
449
|
+
events.append(yields[(yields['track_p']==p) & (yields['track_y']==y)])
|
|
450
|
+
events = pd.concat(events)
|
|
451
|
+
elif method == 'yield':
|
|
452
|
+
events = yields[yields['event']=='yield'].copy()
|
|
453
|
+
elif method == 'not_yield':
|
|
454
|
+
events = yields[yields['event']=='not_yield'].copy()
|
|
455
|
+
elif method == 'event':
|
|
456
|
+
events = yields[yields['event'].isin(['yield', 'not_yield'])].copy()
|
|
457
|
+
elif method == 'none':
|
|
458
|
+
events = yields[~yields['event'].isin(['yield', 'not_yield'])].copy()
|
|
459
|
+
|
|
460
|
+
pbar = tqdm(total= len(events) , unit='event')
|
|
461
|
+
if video_index and video_tot:
|
|
462
|
+
pbar.set_description_str("Generating labeles for yielding events {} of {}".format(video_index, video_tot))
|
|
463
|
+
else:
|
|
464
|
+
pbar.set_description_str("Generating labels for yielding events")
|
|
465
|
+
|
|
466
|
+
labeler = Labeler()
|
|
467
|
+
for index, event in events.iterrows():
|
|
468
|
+
result = []
|
|
469
|
+
track_p_id = event['track_p']
|
|
470
|
+
track_y_id = event['track_y']
|
|
471
|
+
int_x = int(event['int_x'])
|
|
472
|
+
int_y = int(event['int_y'])
|
|
473
|
+
|
|
474
|
+
if event['event'] == 'yield':
|
|
475
|
+
desc = 'yield'
|
|
476
|
+
color = (0, 255, 0)
|
|
477
|
+
elif event['event'] == 'not_yield':
|
|
478
|
+
desc = 'not yield'
|
|
479
|
+
color = (0, 0, 255)
|
|
480
|
+
else:
|
|
481
|
+
desc = 'no interaction'
|
|
482
|
+
color = (255, 0, 0)
|
|
483
|
+
|
|
484
|
+
frames_p = tracks_p_grouped.get_group(track_p_id)
|
|
485
|
+
frames_y = tracks_y_grouped.get_group(track_y_id)
|
|
486
|
+
frames = pd.concat([frames_p, frames_y])
|
|
487
|
+
for index2, frame in frames.iterrows():
|
|
488
|
+
label_text = ''
|
|
489
|
+
if show_track:
|
|
490
|
+
label_text+='| T:'+str(int(frame['track']))
|
|
491
|
+
|
|
492
|
+
if show_desc:
|
|
493
|
+
label_text+= ' | '+desc
|
|
494
|
+
|
|
495
|
+
result.append([frame['frame'], 'bbox', [(frame['x'], frame['y']), (frame['x']+frame['w'], frame['y']+frame['h'])],
|
|
496
|
+
color, size, thick, label_text])
|
|
497
|
+
result.append([frame['frame'], 'box', [(int_x - 5, int_y - 5), (int_x + 5, int_y + 5)],
|
|
498
|
+
(255, 255, 0), size, thick, ''])
|
|
499
|
+
|
|
500
|
+
df = pd.DataFrame(result, columns=['frame','type','coords','color','size','thick','desc'])
|
|
501
|
+
|
|
502
|
+
if out_path:
|
|
503
|
+
file_name = os.path.join(out_path, str(track_p_id)+'-'+str(track_y_id)+'_label.csv')
|
|
504
|
+
df.to_csv(file_name, index=False)
|
|
505
|
+
|
|
506
|
+
if input_video:
|
|
507
|
+
file_name = os.path.join(out_path, str(track_p_id)+'-'+str(track_y_id)+'_label.mp4')
|
|
508
|
+
min_frame = df['frame'].min() - padding
|
|
509
|
+
max_frame = df['frame'].max() + padding
|
|
510
|
+
labeler.draw(input_video=input_video, output_video=file_name, draws=df,
|
|
511
|
+
start_frame=min_frame, end_frame=max_frame, verbose=False)
|
|
512
|
+
|
|
513
|
+
if verbose:
|
|
514
|
+
pbar.update()
|
|
515
|
+
|
|
516
|
+
pbar.close()
|
|
517
|
+
|
|
518
|
+
|
dnt/analysis/stop.py
CHANGED
|
@@ -27,9 +27,9 @@ class StopAnalyzer():
|
|
|
27
27
|
|
|
28
28
|
tracks = pd.read_csv(track_file, header=None, sep=',')
|
|
29
29
|
|
|
30
|
-
tracks = self.
|
|
31
|
-
tracks = self.
|
|
32
|
-
results = self.
|
|
30
|
+
tracks = self.stop_scan(tracks, video_index, video_tot)
|
|
31
|
+
tracks = self.event_identify(tracks, video_index, video_tot)
|
|
32
|
+
results = self.event_count(tracks, video_index, video_tot)
|
|
33
33
|
|
|
34
34
|
if result_file:
|
|
35
35
|
results.to_csv(result_file, index=False)
|
|
@@ -37,7 +37,7 @@ class StopAnalyzer():
|
|
|
37
37
|
if output_file:
|
|
38
38
|
tracks.to_csv(output_file, header=None, index=False)
|
|
39
39
|
|
|
40
|
-
def
|
|
40
|
+
def stop_scan(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
41
41
|
vehicles = tracks[1].unique()
|
|
42
42
|
|
|
43
43
|
pbar = tqdm(total=len(vehicles), unit=' tracks')
|
|
@@ -47,7 +47,7 @@ class StopAnalyzer():
|
|
|
47
47
|
pbar.set_description_str("Scanning stops ")
|
|
48
48
|
|
|
49
49
|
for vehicle in vehicles:
|
|
50
|
-
track = tracks[tracks[1] == vehicle].sort_values(by=0)
|
|
50
|
+
track = tracks[tracks[1] == vehicle].sort_values(by=0) # sort by frame in ascending
|
|
51
51
|
|
|
52
52
|
for i in range(self.frame_buffer, len(track)):
|
|
53
53
|
|
|
@@ -58,17 +58,22 @@ class StopAnalyzer():
|
|
|
58
58
|
bb1 = [track.iloc[i, 2], track.iloc[i, 3], track.iloc[i, 4], track.iloc[i, 5]]
|
|
59
59
|
tracks.at[index, 6] = StopAnalyzer.iou(bb0, bb1)
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
61
|
+
if len(self.vzones)>0:
|
|
62
|
+
center = Point(track.iloc[i,2]+track.iloc[i,4], track.iloc[i,3]+track.iloc[i,5])
|
|
63
|
+
for j in range(len(self.vzones)):
|
|
64
|
+
if center.within(self.vzones[j]):
|
|
65
|
+
tracks.loc[tracks[1]==vehicle, 7]=j
|
|
66
|
+
break
|
|
66
67
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
if
|
|
71
|
-
|
|
68
|
+
if len(self.hzones)>0:
|
|
69
|
+
bb = box(track.iat[i, 2], track.iat[i, 3], track.iat[i, 2] + track.iat[i, 4], track.iat[i, 3] + track.iat[i, 5])
|
|
70
|
+
for j in range(len(self.hzones)):
|
|
71
|
+
if bb.intersects(self.hzones[j]):
|
|
72
|
+
pass
|
|
73
|
+
#if j > tracks.at[index, 8]:
|
|
74
|
+
#tracks.at[index, 8] = j
|
|
75
|
+
|
|
76
|
+
|
|
72
77
|
if self.verbose:
|
|
73
78
|
pbar.update()
|
|
74
79
|
|
|
@@ -76,7 +81,7 @@ class StopAnalyzer():
|
|
|
76
81
|
|
|
77
82
|
return tracks
|
|
78
83
|
|
|
79
|
-
def
|
|
84
|
+
def event_identify(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None)->pd.DataFrame:
|
|
80
85
|
|
|
81
86
|
pbar = tqdm(total=len(tracks), unit=' frames')
|
|
82
87
|
if video_index and video_tot:
|
|
@@ -112,7 +117,7 @@ class StopAnalyzer():
|
|
|
112
117
|
|
|
113
118
|
return tracks
|
|
114
119
|
|
|
115
|
-
def
|
|
120
|
+
def event_count(self, tracks:pd.DataFrame, video_index:int=None, video_tot:int=None):
|
|
116
121
|
|
|
117
122
|
pbar = tqdm(unit='events')
|
|
118
123
|
results = []
|