dnt 0.2.4__py3-none-any.whl → 0.3.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dnt might be problematic. Click here for more details.
- dnt/__init__.py +3 -2
- dnt/analysis/__init__.py +3 -2
- dnt/analysis/count.py +54 -37
- dnt/analysis/interaction2.py +518 -0
- dnt/analysis/stop.py +22 -17
- dnt/analysis/stop2.py +289 -0
- dnt/analysis/stop3.py +758 -0
- dnt/detect/signal/detector.py +326 -0
- dnt/detect/timestamp.py +105 -0
- dnt/detect/yolov8/detector.py +179 -36
- dnt/detect/yolov8/segmentor.py +60 -2
- dnt/engine/__init__.py +8 -0
- dnt/engine/bbox_interp.py +83 -0
- dnt/engine/bbox_iou.py +20 -0
- dnt/engine/cluster.py +31 -0
- dnt/engine/iob.py +66 -0
- dnt/filter/filter.py +333 -2
- dnt/label/labeler.py +4 -4
- dnt/label/labeler2.py +605 -0
- dnt/shared/__init__.py +2 -1
- dnt/shared/data/coco.names +0 -0
- dnt/shared/data/openimages.names +0 -0
- dnt/shared/data/voc.names +0 -0
- dnt/shared/download.py +12 -0
- dnt/shared/synhcro.py +150 -0
- dnt/shared/util.py +17 -4
- dnt/third_party/fast-reid/__init__.py +1 -0
- dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
- dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
- dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
- dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
- dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
- dnt/third_party/fast-reid/configs/__init__.py +0 -0
- dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
- dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
- dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
- dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
- dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
- dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
- dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
- dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
- dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
- dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
- dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
- dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
- dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
- dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
- dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
- dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
- dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
- dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
- dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
- dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
- dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
- dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
- dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
- dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
- dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
- dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
- dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
- dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
- dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
- dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
- dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
- dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
- dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
- dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
- dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
- dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
- dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
- dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
- dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
- dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
- dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
- dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
- dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
- dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
- dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
- dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
- dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
- dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
- dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
- dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
- dnt/track/__init__.py +2 -0
- dnt/track/botsort/__init__.py +4 -0
- dnt/track/botsort/bot_tracker/__init__.py +3 -0
- dnt/track/botsort/bot_tracker/basetrack.py +60 -0
- dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
- dnt/track/botsort/bot_tracker/gmc.py +316 -0
- dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
- dnt/track/botsort/bot_tracker/matching.py +194 -0
- dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
- dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
- dnt/track/botsort/inference.py +96 -0
- dnt/track/config.py +120 -0
- dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
- dnt/track/dsort/configs/deep_sort.yaml +0 -0
- dnt/track/dsort/configs/fastreid.yaml +1 -1
- dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
- dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
- dnt/track/dsort/deep_sort/deep_sort.py +31 -20
- dnt/track/dsort/deep_sort/sort/detection.py +2 -1
- dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
- dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
- dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
- dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
- dnt/track/dsort/deep_sort/sort/track.py +2 -1
- dnt/track/dsort/deep_sort/sort/tracker.py +1 -1
- dnt/track/dsort/dsort.py +43 -33
- dnt/track/re_class.py +117 -0
- dnt/track/sort/sort.py +9 -6
- dnt/track/tracker.py +213 -32
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/METADATA +41 -13
- dnt-0.3.1.7.dist-info/RECORD +315 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/WHEEL +1 -1
- dnt/analysis/yield.py +0 -9
- dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
- dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
- dnt/track/dsort/deep_sort/deep/test.py +0 -77
- dnt/track/dsort/deep_sort/deep/train.py +0 -189
- dnt/track/dsort/utils/asserts.py +0 -13
- dnt/track/dsort/utils/draw.py +0 -36
- dnt/track/dsort/utils/json_logger.py +0 -383
- dnt/track/dsort/utils/log.py +0 -17
- dnt/track/dsort/utils/parser.py +0 -35
- dnt/track/dsort/utils/tools.py +0 -39
- dnt-0.2.4.dist-info/RECORD +0 -64
- /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info/licenses}/LICENSE +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/top_level.txt +0 -0
dnt/detect/yolov8/detector.py
CHANGED
|
@@ -1,31 +1,109 @@
|
|
|
1
|
-
|
|
1
|
+
'''
|
|
2
|
+
This module is a wrapper for ultralytics YOLOV8 and RTDETR models.
|
|
3
|
+
'''
|
|
4
|
+
from ultralytics import YOLO, RTDETR
|
|
2
5
|
import cv2
|
|
3
6
|
import pandas as pd
|
|
4
7
|
from tqdm import tqdm
|
|
5
8
|
import random, os
|
|
6
9
|
from pathlib import Path
|
|
10
|
+
import torch
|
|
7
11
|
|
|
8
12
|
class Detector:
|
|
9
|
-
def __init__(self,
|
|
13
|
+
def __init__(self,
|
|
14
|
+
model:str='yolo',
|
|
15
|
+
weights:str='x',
|
|
16
|
+
conf:float=0.25,
|
|
17
|
+
nms:float=0.7,
|
|
18
|
+
max_det:int=300,
|
|
19
|
+
device:str='auto',
|
|
20
|
+
half:bool=False):
|
|
10
21
|
'''
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
22
|
+
Initialize the Detector class.
|
|
23
|
+
Parameters:
|
|
24
|
+
model: 'yolo' (default), 'rtdetr'
|
|
25
|
+
weights: 'x' - extra-large (default), 'l' - large, 'm' - mdium, 's' - small, 'n' - nano, '.pt' - custom model weights
|
|
26
|
+
conf: 0.25 (default) - confidence threshold
|
|
27
|
+
nms: 0.7 (default) - non-max suppression threshold
|
|
28
|
+
max_det: 300 (default) - maximum number of detections per image
|
|
29
|
+
device: 'auto' (default), 'cuda', 'cpu', 'mps'
|
|
30
|
+
half: False (default), True
|
|
16
31
|
'''
|
|
17
|
-
# Load
|
|
32
|
+
# Load model
|
|
18
33
|
cwd = Path(__file__).parent.absolute()
|
|
19
|
-
|
|
20
|
-
|
|
34
|
+
if model == 'yolo':
|
|
35
|
+
if weights in ['x', 'l', 'm', 's', 'n']:
|
|
36
|
+
model_path = os.path.join(cwd, 'models/yolov8'+weights+'.pt')
|
|
37
|
+
elif ".pt" in weights:
|
|
38
|
+
model_path = os.path.join(cwd, 'models/'+weights)
|
|
39
|
+
elif model == 'yolo11':
|
|
40
|
+
if weights in ['x', 'l', 'm', 's', 'n']:
|
|
41
|
+
model_path = os.path.join(cwd, 'models/yolo11'+weights+'.pt')
|
|
42
|
+
elif ".pt" in weights:
|
|
43
|
+
model_path = os.path.join(cwd, 'models/'+weights)
|
|
44
|
+
|
|
45
|
+
elif model == 'rtdetr':
|
|
46
|
+
if weights in ['x', 'l']:
|
|
47
|
+
model_path = os.path.join(cwd, 'models/rtdetr-'+weights+'.pt')
|
|
48
|
+
elif ".pt" in weights:
|
|
49
|
+
model_path = os.path.join(cwd, 'models/'+weights)
|
|
50
|
+
else:
|
|
51
|
+
model_path = os.path.join(cwd, 'models/rtdetr-x.pt')
|
|
52
|
+
#elif model == 'nas':
|
|
53
|
+
# if weights in ['l', 'm', 's']:
|
|
54
|
+
# model_path = os.path.join(cwd, 'models/yolo_nas_'+weights+'.pt')
|
|
55
|
+
# elif ".pt" in weights:
|
|
56
|
+
# model_path = os.path.join(cwd, 'models/'+weights)
|
|
57
|
+
# else:
|
|
58
|
+
# model_path = os.path.join(cwd, 'models/yolo_nas_l.pt')
|
|
59
|
+
else:
|
|
60
|
+
raise Exception('Invalid detection model type!')
|
|
61
|
+
|
|
62
|
+
if model == 'yolo' or model == 'yolo11':
|
|
63
|
+
self.model = YOLO(model_path)
|
|
64
|
+
elif model == 'rtdetr':
|
|
65
|
+
self.model = RTDETR(model_path)
|
|
66
|
+
#elif model == 'nas':
|
|
67
|
+
# self.model = NAS(model_path)
|
|
68
|
+
else:
|
|
69
|
+
raise Exception('Invalid model weights!')
|
|
70
|
+
|
|
21
71
|
self.conf = conf
|
|
22
72
|
self.nms = nms
|
|
23
73
|
self.max_det = max_det
|
|
24
74
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
75
|
+
if device == 'auto':
|
|
76
|
+
self.device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
|
|
77
|
+
elif device == 'cuda' and torch.cuda.is_available():
|
|
78
|
+
self.device = 'cuda'
|
|
79
|
+
elif device == 'mps' and torch.backends.mps.is_available():
|
|
80
|
+
self.device = 'mps'
|
|
81
|
+
else:
|
|
82
|
+
self.device = 'cpu'
|
|
83
|
+
|
|
84
|
+
self.half = half
|
|
85
|
+
|
|
86
|
+
def detect(self,
|
|
87
|
+
input_video:str,
|
|
88
|
+
iou_file:str=None,
|
|
89
|
+
video_index:int=None,
|
|
90
|
+
video_tot:int=None,
|
|
91
|
+
start_frame:int=None,
|
|
92
|
+
end_frame:int=None,
|
|
93
|
+
verbose:bool=True) -> pd.DataFrame:
|
|
94
|
+
'''
|
|
95
|
+
Detect objects in a video file.
|
|
96
|
+
Parameters:
|
|
97
|
+
input_video: path to the input video file
|
|
98
|
+
iou_file: path to the output file
|
|
99
|
+
video_index: index of the video in the batch
|
|
100
|
+
video_tot: total number of videos in the batch
|
|
101
|
+
start_frame: start frame number
|
|
102
|
+
end_frame: end frame number
|
|
103
|
+
verbose: True (default), False
|
|
104
|
+
Returns:
|
|
105
|
+
df: pandas DataFrame containing the detection results
|
|
106
|
+
'''
|
|
29
107
|
# open input video
|
|
30
108
|
cap = cv2.VideoCapture(input_video)
|
|
31
109
|
if not cap.isOpened():
|
|
@@ -35,16 +113,14 @@ class Detector:
|
|
|
35
113
|
results = []
|
|
36
114
|
|
|
37
115
|
video_fps = int(cap.get(cv2.CAP_PROP_FPS)) #original fps
|
|
38
|
-
if
|
|
39
|
-
start_frame
|
|
40
|
-
if start_frame > int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1:
|
|
116
|
+
if start_frame:
|
|
117
|
+
if (start_frame > int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1) or (start_frame < 0):
|
|
41
118
|
start_frame = 0
|
|
42
119
|
else:
|
|
43
120
|
start_frame = 0
|
|
44
121
|
|
|
45
|
-
if
|
|
46
|
-
end_frame
|
|
47
|
-
if end_frame > int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1:
|
|
122
|
+
if end_frame:
|
|
123
|
+
if (end_frame > int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1) or (end_frame < 0):
|
|
48
124
|
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
49
125
|
else:
|
|
50
126
|
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
@@ -52,12 +128,13 @@ class Detector:
|
|
|
52
128
|
if start_frame>=end_frame:
|
|
53
129
|
raise Exception('The given start time exceeds the end time!')
|
|
54
130
|
|
|
55
|
-
frame_total = end_frame - start_frame
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
131
|
+
frame_total = end_frame - start_frame
|
|
132
|
+
if verbose:
|
|
133
|
+
pbar = tqdm(total=frame_total, unit=" frames")
|
|
134
|
+
if video_index and video_tot:
|
|
135
|
+
pbar.set_description_str("Detecting {} of {}".format(video_index, video_tot))
|
|
136
|
+
else:
|
|
137
|
+
pbar.set_description_str("Detecting ")
|
|
61
138
|
|
|
62
139
|
cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
|
|
63
140
|
while cap.isOpened():
|
|
@@ -66,7 +143,8 @@ class Detector:
|
|
|
66
143
|
if (not ret) or (pos_frame>end_frame):
|
|
67
144
|
break
|
|
68
145
|
|
|
69
|
-
detects = self.model.predict(frame, verbose=False, conf=self.conf, iou=self.nms, max_det=self.max_det
|
|
146
|
+
detects = self.model.predict(frame, verbose=False, conf=self.conf, iou=self.nms, max_det=self.max_det,
|
|
147
|
+
device=self.device, half=self.half)
|
|
70
148
|
if len(detects)>0:
|
|
71
149
|
detect = detects[0]
|
|
72
150
|
|
|
@@ -78,13 +156,16 @@ class Detector:
|
|
|
78
156
|
result.insert(1, 'res', -1)
|
|
79
157
|
results.append(result)
|
|
80
158
|
|
|
81
|
-
|
|
159
|
+
if verbose:
|
|
160
|
+
pbar.update()
|
|
82
161
|
|
|
83
|
-
|
|
162
|
+
if verbose:
|
|
163
|
+
pbar.close()
|
|
84
164
|
cap.release()
|
|
85
|
-
cv2.destroyAllWindows()
|
|
165
|
+
#cv2.destroyAllWindows()
|
|
86
166
|
|
|
87
|
-
df = pd.concat(results)
|
|
167
|
+
df = pd.concat(d for d in results if not d.empty) # remove empty dataframes
|
|
168
|
+
#df = pd.concat(results)
|
|
88
169
|
df['x'] = round(df['x'], 1)
|
|
89
170
|
df['y'] = round(df['y'], 1)
|
|
90
171
|
df['w'] = round(df['x2']-df['x'], 0)
|
|
@@ -99,9 +180,61 @@ class Detector:
|
|
|
99
180
|
|
|
100
181
|
return df
|
|
101
182
|
|
|
183
|
+
def detect_frames(self, input_video:str, frames:list[int], verbose:bool=False)->pd.DataFrame:
|
|
184
|
+
# open input video
|
|
185
|
+
cap = cv2.VideoCapture(input_video)
|
|
186
|
+
if not cap.isOpened():
|
|
187
|
+
print('Failed to open the video!')
|
|
188
|
+
|
|
189
|
+
random.seed(3) # deterministic bbox colors
|
|
190
|
+
results = []
|
|
191
|
+
|
|
192
|
+
if verbose:
|
|
193
|
+
pbar = tqdm(total=len(frames), unit=" frames")
|
|
194
|
+
for pos_frame in frames:
|
|
195
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, pos_frame)
|
|
196
|
+
ret, frame = cap.read()
|
|
197
|
+
if not ret:
|
|
198
|
+
break
|
|
199
|
+
|
|
200
|
+
detects = self.model.predict(frame, verbose=False, conf=self.conf, iou=self.nms, max_det=self.max_det,
|
|
201
|
+
device=self.device, half=self.half)
|
|
202
|
+
if len(detects)>0:
|
|
203
|
+
detect = detects[0]
|
|
204
|
+
|
|
205
|
+
xyxy = pd.DataFrame(detect.boxes.xyxy.tolist(), columns=['x', 'y', 'x2', 'y2'])
|
|
206
|
+
cls = pd.DataFrame(detect.boxes.cls.tolist(), columns=['class'])
|
|
207
|
+
conf = pd.DataFrame(detect.boxes.conf.tolist(), columns = ['conf'])
|
|
208
|
+
result = pd.concat([xyxy, conf, cls], axis=1)
|
|
209
|
+
result.insert(0, 'frame', pos_frame)
|
|
210
|
+
result.insert(1, 'res', -1)
|
|
211
|
+
results.append(result)
|
|
212
|
+
|
|
213
|
+
if verbose:
|
|
214
|
+
pbar.update()
|
|
215
|
+
|
|
216
|
+
if verbose:
|
|
217
|
+
pbar.close()
|
|
218
|
+
cap.release()
|
|
219
|
+
|
|
220
|
+
if len(results) == 0:
|
|
221
|
+
return pd.DataFrame(columns=['frame', 'res', 'x', 'y', 'w', 'h', 'conf', 'class'])
|
|
222
|
+
|
|
223
|
+
df = pd.concat(d for d in results if not d.empty) # remove empty dataframes
|
|
224
|
+
#df = pd.concat(results)
|
|
225
|
+
df['x'] = round(df['x'], 1)
|
|
226
|
+
df['y'] = round(df['y'], 1)
|
|
227
|
+
df['w'] = round(df['x2']-df['x'], 0)
|
|
228
|
+
df['h'] = round(df['y2']-df['y'], 0)
|
|
229
|
+
df['class'] = round(df['class'], 0)
|
|
230
|
+
df['conf'] = round(df['conf'], 2)
|
|
231
|
+
df = df[['frame', 'res', 'x', 'y', 'w', 'h', 'conf', 'class']].reset_index(drop=True)
|
|
232
|
+
|
|
233
|
+
return df
|
|
234
|
+
|
|
102
235
|
def detect_v8(self, input_video:str, iou_file:str=None, save:bool=False, verbose:bool=False, show:bool=False):
|
|
103
236
|
detects = self.model.predict(input_video,
|
|
104
|
-
verbose=verbose, stream=True, save=save, show=show)
|
|
237
|
+
verbose=verbose, stream=True, save=save, show=show, device=self.device, half=self.half)
|
|
105
238
|
|
|
106
239
|
if iou_file:
|
|
107
240
|
results = []
|
|
@@ -163,14 +296,24 @@ class Detector:
|
|
|
163
296
|
return results
|
|
164
297
|
|
|
165
298
|
@staticmethod
|
|
166
|
-
def get_fps(
|
|
167
|
-
cap = cv2.VideoCapture(
|
|
299
|
+
def get_fps(video:str)->float:
|
|
300
|
+
cap = cv2.VideoCapture(video)
|
|
168
301
|
if not cap.isOpened():
|
|
169
302
|
print('Failed to open the video!')
|
|
170
303
|
fps = cap.get(cv2.CAP_PROP_FPS)
|
|
171
304
|
return fps
|
|
305
|
+
|
|
306
|
+
@staticmethod
|
|
307
|
+
def get_frames(video:str)->int:
|
|
308
|
+
cap = cv2.VideoCapture(video)
|
|
309
|
+
if not cap.isOpened():
|
|
310
|
+
print('Failed to open the video!')
|
|
311
|
+
frames = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))
|
|
312
|
+
return frames
|
|
172
313
|
|
|
173
314
|
if __name__=='__main__':
|
|
174
315
|
|
|
175
|
-
detector = Detector()
|
|
176
|
-
detector.detect('/mnt/
|
|
316
|
+
detector = Detector(model='yolo11')
|
|
317
|
+
result = detector.detect('/mnt/d/videos/sample/traffic.mp4', verbose=True)
|
|
318
|
+
|
|
319
|
+
print(result)
|
dnt/detect/yolov8/segmentor.py
CHANGED
|
@@ -4,15 +4,18 @@ import pandas as pd
|
|
|
4
4
|
from tqdm import tqdm
|
|
5
5
|
import random, os, json
|
|
6
6
|
from pathlib import Path
|
|
7
|
+
import torch
|
|
8
|
+
from shapely.geometry import Polygon as Pol
|
|
7
9
|
|
|
8
10
|
class Segmentor:
|
|
9
|
-
def __init__(self, model:str='
|
|
11
|
+
def __init__(self, model:str='yolov8m-seg.pt', conf:float=0.25, nms:float=0.7, max_det:int=300, device:str='auto', half:bool=False):
|
|
10
12
|
'''
|
|
11
13
|
yolo: x - yolov8x-seg.pt
|
|
12
14
|
l - yolov8l-seg.pt
|
|
13
15
|
m - yolov8m-seg.pt
|
|
14
16
|
s - yolov8s-seg.pt
|
|
15
17
|
n - yolov8n-seg.pt
|
|
18
|
+
|
|
16
19
|
'''
|
|
17
20
|
# Load YOLOV8 model
|
|
18
21
|
cwd = Path(__file__).parent.absolute()
|
|
@@ -21,6 +24,17 @@ class Segmentor:
|
|
|
21
24
|
self.conf = conf
|
|
22
25
|
self.nms = nms
|
|
23
26
|
self.max_det = max_det
|
|
27
|
+
|
|
28
|
+
if device == 'auto':
|
|
29
|
+
self.device = 'cuda' if torch.cuda.is_available() else 'mps' if torch.backends.mps.is_available() else 'cpu'
|
|
30
|
+
elif device == 'cuda' and torch.cuda.is_available():
|
|
31
|
+
self.device = 'cuda'
|
|
32
|
+
elif device == 'mps' and torch.backends.mps.is_available():
|
|
33
|
+
self.device = 'mps'
|
|
34
|
+
else:
|
|
35
|
+
self.device = 'cpu'
|
|
36
|
+
|
|
37
|
+
self.half = half
|
|
24
38
|
self.half = half
|
|
25
39
|
|
|
26
40
|
def segment(self, input_video:str, mask_file:str=None,
|
|
@@ -106,8 +120,52 @@ class Segmentor:
|
|
|
106
120
|
video_index=None, video_tot=None,
|
|
107
121
|
start_frame=frame, end_frame=frame,
|
|
108
122
|
verbose=False)
|
|
123
|
+
|
|
124
|
+
def segment_zone(self, input_video:str, frame:int=None, zone:list=None) -> list:
|
|
125
|
+
'''
|
|
126
|
+
Segment the video in a specific zone
|
|
127
|
+
input_video: Path to video
|
|
128
|
+
frame: Frame number to segment
|
|
129
|
+
zone: Polygon zone to segment
|
|
130
|
+
Return:
|
|
131
|
+
List of segmented objects in the zone
|
|
132
|
+
'''
|
|
133
|
+
|
|
134
|
+
# open input video
|
|
135
|
+
cap = cv2.VideoCapture(input_video)
|
|
136
|
+
if not cap.isOpened():
|
|
137
|
+
print('Failed to open the video!')
|
|
109
138
|
|
|
139
|
+
if frame <0 or frame > int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1:
|
|
140
|
+
raise Exception('The given frame is out of range!')
|
|
141
|
+
|
|
142
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, frame)
|
|
143
|
+
ret, frame = cap.read()
|
|
144
|
+
if ret:
|
|
145
|
+
x1, y1, x2, y2 = zone
|
|
146
|
+
cropped_frame = frame[y1:y2, x1:x2]
|
|
147
|
+
detects = self.model.predict(cropped_frame, verbose=False, conf=self.conf, iou=self.nms, max_det=self.max_det, half=self.half)
|
|
148
|
+
if len(detects)>0:
|
|
149
|
+
if detects[0].masks is not None:
|
|
150
|
+
xy = list(map(lambda x: x.tolist(), detects[0].masks.xy))
|
|
151
|
+
print(xy)
|
|
152
|
+
input('.')
|
|
153
|
+
cap.release()
|
|
154
|
+
|
|
155
|
+
|
|
110
156
|
if __name__=="__main__":
|
|
111
157
|
|
|
112
158
|
segmentor = Segmentor()
|
|
113
|
-
segmentor.segment('/mnt/d/videos/samples/traffic_short.mp4', '/mnt/d/videos/samples/traffic_short_mask.json', start_frame=1, end_frame=1)
|
|
159
|
+
#segmentor.segment('/mnt/d/videos/samples/traffic_short.mp4', '/mnt/d/videos/samples/traffic_short_mask.json', start_frame=1, end_frame=1)
|
|
160
|
+
input_video = '/mnt/d/videos/hyde/after_2024-08-15_nw.mp4'
|
|
161
|
+
tracks = pd.read_csv('/mnt/d/videos/hyde/tracks/after_2024-08-15_nw_track_veh_rt.txt')
|
|
162
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'r1', 'r2', 'r3', 'r4']
|
|
163
|
+
dets = tracks[tracks['track'] == 678]
|
|
164
|
+
dets.sort_values(by='frame', inplace=True)
|
|
165
|
+
|
|
166
|
+
for index, det in dets.iterrows():
|
|
167
|
+
zone = (int(det['x']), int(det['y']), int(det['x'] + det['w']), int(det['y'] + det['h']))
|
|
168
|
+
frame = int(det['frame'])
|
|
169
|
+
|
|
170
|
+
segmentor.segment_zone(input_video, frame, zone) # Segment the specific zone
|
|
171
|
+
print(f"Segmented frame {frame}")
|
dnt/engine/__init__.py
ADDED
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
# bbox_interpolation.pyx
|
|
2
|
+
|
|
3
|
+
import numpy as np
|
|
4
|
+
from scipy.interpolate import CubicSpline, interp1d
|
|
5
|
+
|
|
6
|
+
# Define the function signature
|
|
7
|
+
def interpolate_bbox(boxes:np.ndarray, frames:np.ndarray, target_frame:int, method='cubic')->np.ndarray:
|
|
8
|
+
"""
|
|
9
|
+
Interpolates bounding boxes using cubic splines.
|
|
10
|
+
|
|
11
|
+
Parameters:
|
|
12
|
+
- boxes: a (n, 4) array of bounding box coordinates (x, y, width, height).
|
|
13
|
+
- frames: a (n,) array of frame indices corresponding to the bounding boxes.
|
|
14
|
+
- target_frame: the frame index at which to interpolate the bounding box.
|
|
15
|
+
- method: the spline function, default is 'cubic', 'nearest', 'linear'
|
|
16
|
+
Returns:
|
|
17
|
+
- A 1d array (x, y, width, height) representing the interpolated bounding box.
|
|
18
|
+
"""
|
|
19
|
+
n = boxes.shape[0]
|
|
20
|
+
|
|
21
|
+
if n != frames.shape[0]:
|
|
22
|
+
raise ValueError("Length of boxes and frames must be equal.")
|
|
23
|
+
|
|
24
|
+
if n == 0:
|
|
25
|
+
raise ValueError("Input arrays must not be empty.")
|
|
26
|
+
|
|
27
|
+
if target_frame < frames[0] or target_frame > frames[-1]:
|
|
28
|
+
raise ValueError("Target frame is out of bounds.")
|
|
29
|
+
|
|
30
|
+
# Unpack the boxes into separate arrays for x, y, width, and height
|
|
31
|
+
x = boxes[:, 0]
|
|
32
|
+
y = boxes[:, 1]
|
|
33
|
+
w = boxes[:, 2]
|
|
34
|
+
h = boxes[:, 3]
|
|
35
|
+
|
|
36
|
+
# Create the cubic splines for each parameter
|
|
37
|
+
if method == 'cubic':
|
|
38
|
+
spline_x = CubicSpline(frames, x)
|
|
39
|
+
spline_y = CubicSpline(frames, y)
|
|
40
|
+
spline_w = CubicSpline(frames, w)
|
|
41
|
+
spline_h = CubicSpline(frames, h)
|
|
42
|
+
elif method == 'nearest':
|
|
43
|
+
spline_x = interp1d(frames, x, kind='nearest')
|
|
44
|
+
spline_y = interp1d(frames, y, kind='nearest')
|
|
45
|
+
spline_w = interp1d(frames, w, kind='nearest')
|
|
46
|
+
spline_h = interp1d(frames, h, kind='nearest')
|
|
47
|
+
else:
|
|
48
|
+
spline_x = interp1d(frames, x, kind='linear')
|
|
49
|
+
spline_y = interp1d(frames, y, kind='linear')
|
|
50
|
+
spline_w = interp1d(frames, w, kind='linear')
|
|
51
|
+
spline_h = interp1d(frames, h, kind='linear')
|
|
52
|
+
|
|
53
|
+
# Evaluate the splines at the target frame
|
|
54
|
+
x_t = int(spline_x(target_frame))
|
|
55
|
+
y_t = int(spline_y(target_frame))
|
|
56
|
+
w_t = int(spline_w(target_frame))
|
|
57
|
+
h_t = int(spline_h(target_frame))
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
return np.array([x_t, y_t, w_t, h_t])
|
|
61
|
+
|
|
62
|
+
def interpolate_bboxes(boxes:np.ndarray, frames:np.ndarray, target_frames:np.ndarray, method='cubic')->np.ndarray:
|
|
63
|
+
"""
|
|
64
|
+
Interpolates bounding boxes using cubic splines.
|
|
65
|
+
|
|
66
|
+
Parameters:
|
|
67
|
+
- boxes: a (n, 4) array of bounding box coordinates (x, y, width, height).
|
|
68
|
+
- frames: a (n,) array of frame indices corresponding to the bounding boxes.
|
|
69
|
+
- target_frames: the frame indexes at which to interpolate the bounding boxes.
|
|
70
|
+
- method: the spline function, default is 'cubic', 'nearest', 'linear'
|
|
71
|
+
|
|
72
|
+
Returns:
|
|
73
|
+
- List of tuple (x, y, width, height) representing the interpolated bounding boxes.
|
|
74
|
+
"""
|
|
75
|
+
|
|
76
|
+
n_frames = target_frames.shape[0]
|
|
77
|
+
results = []
|
|
78
|
+
|
|
79
|
+
for i in range(n_frames):
|
|
80
|
+
target_frame = target_frames[i]
|
|
81
|
+
results.append(interpolate_bbox(boxes, frames, target_frame, method))
|
|
82
|
+
|
|
83
|
+
return np.vstack(results)
|
dnt/engine/bbox_iou.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
from cython_bbox import bbox_overlaps
|
|
2
|
+
import numpy as np
|
|
3
|
+
|
|
4
|
+
def ious(atlbrs, btlbrs):
|
|
5
|
+
"""
|
|
6
|
+
Compute cost based on IoU
|
|
7
|
+
:type atlbrs: list[tlbr] | np.ndarray
|
|
8
|
+
:type atlbrs: list[tlbr] | np.ndarray
|
|
9
|
+
|
|
10
|
+
:rtype ious np.ndarray
|
|
11
|
+
"""
|
|
12
|
+
ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=np.float64)
|
|
13
|
+
if ious.size == 0:
|
|
14
|
+
return ious
|
|
15
|
+
|
|
16
|
+
ious = bbox_overlaps(
|
|
17
|
+
np.ascontiguousarray(atlbrs, dtype=np.float64),
|
|
18
|
+
np.ascontiguousarray(btlbrs, dtype=np.float64))
|
|
19
|
+
|
|
20
|
+
return ious
|
dnt/engine/cluster.py
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
def cluster_by_gap(arr:np.ndarray, gap:int)->list:
|
|
4
|
+
'''
|
|
5
|
+
Parameters:
|
|
6
|
+
- arr: a 1d array for clustering
|
|
7
|
+
- gap: the threshold to break (> gap)
|
|
8
|
+
|
|
9
|
+
Returns:
|
|
10
|
+
- list of clustered numbers (lists)
|
|
11
|
+
'''
|
|
12
|
+
# Sort the array to process it in order
|
|
13
|
+
arr.sort()
|
|
14
|
+
clusters = []
|
|
15
|
+
current_cluster = [arr[0]]
|
|
16
|
+
|
|
17
|
+
# Iterate through the sorted list
|
|
18
|
+
for i in range(1, len(arr)):
|
|
19
|
+
if arr[i] - arr[i-1] <= gap:
|
|
20
|
+
# If the gap condition is met, add to the current cluster
|
|
21
|
+
current_cluster.append(arr[i])
|
|
22
|
+
else:
|
|
23
|
+
# If the gap condition is not met, start a new cluster
|
|
24
|
+
clusters.append(current_cluster)
|
|
25
|
+
current_cluster = [arr[i]]
|
|
26
|
+
|
|
27
|
+
# Add the last cluster
|
|
28
|
+
clusters.append(current_cluster)
|
|
29
|
+
|
|
30
|
+
return clusters
|
|
31
|
+
|
dnt/engine/iob.py
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import numpy as np
|
|
2
|
+
|
|
3
|
+
def iob(box_a:np.ndarray, box_b:np.ndarray)->tuple:
|
|
4
|
+
"""
|
|
5
|
+
Calculate the Intersection over Box (IoB) between two bounding boxes.
|
|
6
|
+
|
|
7
|
+
Parameters:
|
|
8
|
+
box_a -- numpy arrays of shape (4,) containing [l, t, w, h]
|
|
9
|
+
box_b -- numpy arrays of shape (4,) containing [l, t, w, h], target bounding box
|
|
10
|
+
|
|
11
|
+
Returns:
|
|
12
|
+
iob, iob -- float, the IoB values for box_a and box_b
|
|
13
|
+
"""
|
|
14
|
+
# Determine the (x, y)-coordinates of the intersection rectangle
|
|
15
|
+
x_l = max(box_a[0], box_b[0])
|
|
16
|
+
y_t = max(box_a[1], box_b[1])
|
|
17
|
+
x_r = min(box_a[0]+box_a[2], box_b[0]+box_b[2])
|
|
18
|
+
y_b = min(box_a[1]+box_a[3], box_b[1]+box_b[3])
|
|
19
|
+
|
|
20
|
+
# Compute the area of intersection rectangle
|
|
21
|
+
inter_width = max(0, x_r - x_l)
|
|
22
|
+
inter_height = max(0, y_b - y_t)
|
|
23
|
+
inter_area = inter_width * inter_height
|
|
24
|
+
|
|
25
|
+
# Compute the area of both the prediction and ground-truth rectangles
|
|
26
|
+
box_a_area = box_a[2] * box_a[3]
|
|
27
|
+
box_b_area = box_b[2] * box_b[3]
|
|
28
|
+
|
|
29
|
+
# Compute the intersection over union by taking the intersection area and dividing it by the sum of prediction + ground-truth areas - the intersection area
|
|
30
|
+
iob_a = inter_area / box_a_area if box_a_area != 0 else 0.0
|
|
31
|
+
iob_b = inter_area / box_b_area if box_b_area != 0 else 0.0
|
|
32
|
+
|
|
33
|
+
return iob_a, iob_b
|
|
34
|
+
|
|
35
|
+
def iobs(alrbs:np.ndarray, blrbs:np.ndarray)->np.ndarray:
|
|
36
|
+
"""
|
|
37
|
+
Calculate the IoU matrix for multiple bounding boxes.
|
|
38
|
+
|
|
39
|
+
Parameters:
|
|
40
|
+
boxes -- numpy array of shape (N, 4), where N is the number of boxes, and each row is [x1, y1, x2, y2]
|
|
41
|
+
|
|
42
|
+
Returns:
|
|
43
|
+
iou_matrix -- numpy array of shape (N, N), where iou_matrix[i, j] is the IoU between boxes[i] and boxes[j]
|
|
44
|
+
"""
|
|
45
|
+
num_a = alrbs.shape[0]
|
|
46
|
+
num_b = blrbs.shape[0]
|
|
47
|
+
iobs_a = np.zeros((num_a, num_b))
|
|
48
|
+
iobs_b = np.zeros((num_a, num_b))
|
|
49
|
+
|
|
50
|
+
for i in range(num_a):
|
|
51
|
+
for j in range(num_b):
|
|
52
|
+
iobs_a[i, j], iobs_b[i, j] = iob(alrbs[i,:], blrbs[j,:])
|
|
53
|
+
|
|
54
|
+
return iobs_a, iobs_b
|
|
55
|
+
|
|
56
|
+
if __name__ == '__main__':
|
|
57
|
+
# Example usage
|
|
58
|
+
boxes = np.array([
|
|
59
|
+
[0, 0, 1, 1],
|
|
60
|
+
[0.5, 0.5, 1.5, 1.5],
|
|
61
|
+
[1, 1, 2, 2]
|
|
62
|
+
])
|
|
63
|
+
|
|
64
|
+
matrix_a, matrix_b = iobs(boxes, boxes)
|
|
65
|
+
print(matrix_a)
|
|
66
|
+
print(matrix_b)
|