dnt 0.2.4__py3-none-any.whl → 0.3.1.3__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dnt might be problematic. Click here for more details.
- dnt/__init__.py +3 -2
- dnt/analysis/__init__.py +3 -2
- dnt/analysis/interaction.py +503 -0
- dnt/analysis/stop.py +22 -17
- dnt/analysis/stop2.py +289 -0
- dnt/analysis/stop3.py +754 -0
- dnt/detect/signal/detector.py +317 -0
- dnt/detect/yolov8/detector.py +116 -16
- dnt/engine/__init__.py +8 -0
- dnt/engine/bbox_interp.py +83 -0
- dnt/engine/bbox_iou.py +20 -0
- dnt/engine/cluster.py +31 -0
- dnt/engine/iob.py +66 -0
- dnt/filter/filter.py +321 -1
- dnt/label/labeler.py +4 -4
- dnt/label/labeler2.py +502 -0
- dnt/shared/__init__.py +2 -1
- dnt/shared/data/coco.names +0 -0
- dnt/shared/data/openimages.names +0 -0
- dnt/shared/data/voc.names +0 -0
- dnt/shared/download.py +12 -0
- dnt/shared/synhcro.py +150 -0
- dnt/shared/util.py +17 -4
- dnt/third_party/fast-reid/__init__.py +1 -0
- dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
- dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
- dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
- dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
- dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
- dnt/third_party/fast-reid/configs/__init__.py +0 -0
- dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
- dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
- dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
- dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
- dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
- dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
- dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
- dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
- dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
- dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
- dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
- dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
- dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
- dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
- dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
- dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
- dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
- dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
- dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
- dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
- dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
- dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
- dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
- dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
- dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
- dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
- dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
- dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
- dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
- dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
- dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
- dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
- dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
- dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
- dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
- dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
- dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
- dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
- dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
- dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
- dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
- dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
- dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
- dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
- dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
- dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
- dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
- dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
- dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
- dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
- dnt/track/__init__.py +2 -0
- dnt/track/botsort/__init__.py +4 -0
- dnt/track/botsort/bot_tracker/__init__.py +3 -0
- dnt/track/botsort/bot_tracker/basetrack.py +60 -0
- dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
- dnt/track/botsort/bot_tracker/gmc.py +316 -0
- dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
- dnt/track/botsort/bot_tracker/matching.py +194 -0
- dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
- dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
- dnt/track/botsort/inference.py +96 -0
- dnt/track/config.py +120 -0
- dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
- dnt/track/dsort/configs/deep_sort.yaml +0 -0
- dnt/track/dsort/configs/fastreid.yaml +1 -1
- dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
- dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
- dnt/track/dsort/deep_sort/deep_sort.py +28 -18
- dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
- dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
- dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
- dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
- dnt/track/dsort/dsort.py +21 -28
- dnt/track/re_class.py +94 -0
- dnt/track/sort/sort.py +5 -1
- dnt/track/tracker.py +207 -30
- {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/METADATA +30 -10
- dnt-0.3.1.3.dist-info/RECORD +314 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/WHEEL +1 -1
- dnt/analysis/yield.py +0 -9
- dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
- dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
- dnt/track/dsort/deep_sort/deep/test.py +0 -77
- dnt/track/dsort/deep_sort/deep/train.py +0 -189
- dnt/track/dsort/utils/asserts.py +0 -13
- dnt/track/dsort/utils/draw.py +0 -36
- dnt/track/dsort/utils/json_logger.py +0 -383
- dnt/track/dsort/utils/log.py +0 -17
- dnt/track/dsort/utils/parser.py +0 -35
- dnt/track/dsort/utils/tools.py +0 -39
- dnt-0.2.4.dist-info/RECORD +0 -64
- /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/LICENSE +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.3.dist-info}/top_level.txt +0 -0
dnt/label/labeler2.py
ADDED
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
import os, sys
|
|
2
|
+
sys.path.append(os.path.dirname(__file__))
|
|
3
|
+
|
|
4
|
+
import cv2
|
|
5
|
+
import numpy as np
|
|
6
|
+
import matplotlib.pyplot as plt
|
|
7
|
+
from tqdm import tqdm
|
|
8
|
+
import pandas as pd
|
|
9
|
+
import itertools
|
|
10
|
+
from ..shared.util import load_classes
|
|
11
|
+
import random
|
|
12
|
+
|
|
13
|
+
class Labeler:
|
|
14
|
+
def __init__(self, method:str='opencv', compress_message:bool=False, nodraw_empty:bool=True):
|
|
15
|
+
|
|
16
|
+
self.method = method
|
|
17
|
+
self.compress_message=compress_message
|
|
18
|
+
self.nodraw_empty = nodraw_empty
|
|
19
|
+
|
|
20
|
+
def draw(self, input_video:str, output_video:str,
|
|
21
|
+
draws:pd.DataFrame = None, draw_file:str = None,
|
|
22
|
+
start_frame:int=None, end_frame:int=None,
|
|
23
|
+
video_index:int=None, video_tot:int=None, verbose:bool=True):
|
|
24
|
+
'''
|
|
25
|
+
General labeling function
|
|
26
|
+
Inputs:
|
|
27
|
+
draws: a DataFrame contains labeling information, if None, read label_file
|
|
28
|
+
label_file: a txt file with a header ['frame','type','coords','color','size','thick','desc']
|
|
29
|
+
input_video: raw video
|
|
30
|
+
output_video: labeled video
|
|
31
|
+
start_frame:
|
|
32
|
+
end_frame:
|
|
33
|
+
video_index: display video index in batch processing
|
|
34
|
+
video_tot: display total video number in batch processing
|
|
35
|
+
'''
|
|
36
|
+
if draws is not None:
|
|
37
|
+
data = draws
|
|
38
|
+
else:
|
|
39
|
+
data = pd.read_csv(draw_file, dtype={'frame':int, 'type':str, 'size':float, 'desc':str, 'thick':int},
|
|
40
|
+
converters={'coords': lambda x:list(eval(x)), 'color': lambda x:eval(x)})
|
|
41
|
+
|
|
42
|
+
cmap = plt.get_cmap('tab20b')
|
|
43
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
44
|
+
|
|
45
|
+
cap = cv2.VideoCapture(input_video)
|
|
46
|
+
if not cap.isOpened():
|
|
47
|
+
raise IOError("Couldn't open webcam or video")
|
|
48
|
+
|
|
49
|
+
if start_frame is None:
|
|
50
|
+
start_frame = 0
|
|
51
|
+
if end_frame is None:
|
|
52
|
+
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
53
|
+
|
|
54
|
+
tot_frames = end_frame - start_frame + 1
|
|
55
|
+
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
|
56
|
+
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
|
57
|
+
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
58
|
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
|
59
|
+
writer = cv2.VideoWriter(output_video, fourcc, fps, (width, height))
|
|
60
|
+
|
|
61
|
+
if verbose:
|
|
62
|
+
pbar = tqdm(total=tot_frames, unit=" frames")
|
|
63
|
+
if self.compress_message:
|
|
64
|
+
pbar.set_description_str("Labeling")
|
|
65
|
+
else:
|
|
66
|
+
if video_index and video_tot:
|
|
67
|
+
pbar.set_description_str("Labeling {} of {}".format(video_index, video_tot))
|
|
68
|
+
else:
|
|
69
|
+
pbar.set_description_str("Labeling {} ".format(input_video))
|
|
70
|
+
|
|
71
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
|
|
72
|
+
while cap.isOpened():
|
|
73
|
+
pos_frame = int(cap.get(cv2.CAP_PROP_POS_FRAMES))
|
|
74
|
+
ret, frame = cap.read()
|
|
75
|
+
if (not ret) or (pos_frame>end_frame):
|
|
76
|
+
break
|
|
77
|
+
|
|
78
|
+
elements = data.loc[data['frame']==pos_frame]
|
|
79
|
+
|
|
80
|
+
for index, element in elements.iterrows():
|
|
81
|
+
if element['type'] == 'txt':
|
|
82
|
+
label_txt = element['desc']
|
|
83
|
+
color = element['color']
|
|
84
|
+
size = element['size']
|
|
85
|
+
thick = element['thick']
|
|
86
|
+
cv2.putText(frame, label_txt, tuple(map(int, element['coords'][0])), 0, size, color, thick)
|
|
87
|
+
|
|
88
|
+
elif element['type'] == 'line':
|
|
89
|
+
coords = element['coords']
|
|
90
|
+
color = element['color']
|
|
91
|
+
thick = element['thick']
|
|
92
|
+
cv2.line(frame, tuple(map(int, coords[0])), tuple(map(int, coords[1])), color, thick)
|
|
93
|
+
|
|
94
|
+
elif element['type'] == 'box':
|
|
95
|
+
coords = element['coords']
|
|
96
|
+
color = element['color']
|
|
97
|
+
thick = element['thick']
|
|
98
|
+
cv2.rectangle(frame, tuple(map(int, coords[0])), tuple(map(int, coords[1])), color, thick)
|
|
99
|
+
|
|
100
|
+
elif element['type'] == 'bbox':
|
|
101
|
+
coords = element['coords']
|
|
102
|
+
color = element['color']
|
|
103
|
+
thick = element['thick']
|
|
104
|
+
label_txt = element['desc']
|
|
105
|
+
size = element['size']
|
|
106
|
+
|
|
107
|
+
cv2.rectangle(frame, tuple(map(int, coords[0])), tuple(map(int, coords[1])), color, thick)
|
|
108
|
+
cv2.putText(frame, str(label_txt), (int(coords[0][0]), int(coords[0][1]-int(10*size))),
|
|
109
|
+
cv2.FONT_HERSHEY_SIMPLEX, size, color, thick)
|
|
110
|
+
|
|
111
|
+
elif element['type'] == 'circle':
|
|
112
|
+
coords = element['coords']
|
|
113
|
+
color = element['color']
|
|
114
|
+
thick = element['thick']
|
|
115
|
+
label_txt = element['desc']
|
|
116
|
+
radius = int(element['size'])
|
|
117
|
+
|
|
118
|
+
cv2.circle(frame, tuple(map(int, coords[0])), radius=radius, color=color, thickness=thick)
|
|
119
|
+
|
|
120
|
+
elif element['type'] == 'polygon':
|
|
121
|
+
coords = element['coords']
|
|
122
|
+
color = element['color']
|
|
123
|
+
thick = element['thick']
|
|
124
|
+
cv2.polylines(frame, [np.array(coords)], isClosed=True, color=color, thickness=thick)
|
|
125
|
+
|
|
126
|
+
elif element['type'] == 'polylines':
|
|
127
|
+
coords = element['coords']
|
|
128
|
+
color = element['color']
|
|
129
|
+
thick = element['thick']
|
|
130
|
+
cv2.polylines(frame, [np.array(coords)], isClosed=False, color=color, thickness=thick)
|
|
131
|
+
|
|
132
|
+
writer.write(frame)
|
|
133
|
+
#key = cv2.waitKey(1) & 0xFF
|
|
134
|
+
#if key == ord("q"):
|
|
135
|
+
# break
|
|
136
|
+
|
|
137
|
+
if verbose:
|
|
138
|
+
pbar.update()
|
|
139
|
+
|
|
140
|
+
if verbose:
|
|
141
|
+
pbar.close()
|
|
142
|
+
#cv2.destroyAllWindows()
|
|
143
|
+
cap.release()
|
|
144
|
+
writer.release()
|
|
145
|
+
|
|
146
|
+
def draw_track_clips(self, input_video:str, output_path:str,
|
|
147
|
+
tracks:pd.DataFrame = None, track_file:str = None,
|
|
148
|
+
method:str='all', random_number:int=10, track_ids:list=None,
|
|
149
|
+
start_frame_offset:int=0, end_frame_offset:int=0,
|
|
150
|
+
tail:int=0, prefix:bool=False,
|
|
151
|
+
size:int=1, thick:int=1,
|
|
152
|
+
verbose:bool=True):
|
|
153
|
+
'''
|
|
154
|
+
Parameters:
|
|
155
|
+
input_video: the raw video file
|
|
156
|
+
outputh_path: the folder for outputing track clips
|
|
157
|
+
tracks: the dataframe of tracks
|
|
158
|
+
track_file: the track file if tracks are none
|
|
159
|
+
method: 'all' (default) - all tracks, 'random' - random select tracks, 'specify' - specify track ids
|
|
160
|
+
random_number: the number of track ids if method == 'random'
|
|
161
|
+
track_ids: the list of track ids if method == 'specify'
|
|
162
|
+
start_frame_offset: the offset of start frame, default is 0
|
|
163
|
+
end_frame_offset: the offset of end frame, default is 0
|
|
164
|
+
tail: the length of tail, default is 0
|
|
165
|
+
prefix: if add the video file name as the prefix in output file names, default is False
|
|
166
|
+
size: font size, default is 1
|
|
167
|
+
thick: line thinckness, defualt is 1
|
|
168
|
+
verbose: if show progressing bar, default is True
|
|
169
|
+
'''
|
|
170
|
+
|
|
171
|
+
if tracks is None:
|
|
172
|
+
tracks = pd.read_csv(track_file, header=None, dtype={0:int, 1:int, 2:int, 3:int, 4:int, 5:int, 6:float, 7:int, 8:int, 9:int})
|
|
173
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3', 'r4']
|
|
174
|
+
|
|
175
|
+
if method == 'random':
|
|
176
|
+
track_ids = tracks['track'].unique().tolist()
|
|
177
|
+
if random_number<=0:
|
|
178
|
+
random_number = 10
|
|
179
|
+
track_ids = random.sample(track_ids, random_number)
|
|
180
|
+
elif method == 'specify':
|
|
181
|
+
if (track_ids is None) or (len(track_ids)==0):
|
|
182
|
+
print('No tracks are provided!')
|
|
183
|
+
return pd.DataFrame()
|
|
184
|
+
else:
|
|
185
|
+
track_ids = tracks['track'].unique().tolist()
|
|
186
|
+
|
|
187
|
+
pbar = tqdm(total=len(track_ids), desc='Labeling tracks ', unit='videos')
|
|
188
|
+
for id in track_ids:
|
|
189
|
+
selected_tracks = tracks[tracks['track']==id].copy()
|
|
190
|
+
start_frame = max(selected_tracks['frame'].min() - start_frame_offset, 0)
|
|
191
|
+
end_frame = min(selected_tracks['frame'].max() + end_frame_offset,
|
|
192
|
+
cv2.VideoCapture(input_video).get(cv2.CAP_PROP_FRAME_COUNT)-1)
|
|
193
|
+
if prefix:
|
|
194
|
+
out_video = os.path.join(output_path, os.path.splitext(os.path.basename(input_video))[0]+"_"+str(id)+'.mp4')
|
|
195
|
+
else:
|
|
196
|
+
out_video = os.path.join(output_path, str(id)+'.mp4')
|
|
197
|
+
|
|
198
|
+
self.draw_tracks(input_video=input_video, output_video=out_video, tracks=selected_tracks,
|
|
199
|
+
start_frame=start_frame, end_frame=end_frame, verbose=False, tail=tail, thick=thick, size=size)
|
|
200
|
+
pbar.update()
|
|
201
|
+
pbar.close()
|
|
202
|
+
|
|
203
|
+
def draw_tracks(self, input_video:str, output_video:str,
|
|
204
|
+
tracks:pd.DataFrame = None, track_file:str = None, label_file:str=None,
|
|
205
|
+
color = None, tail:int=0, thick:int=2, size:int=1,
|
|
206
|
+
class_name = False,
|
|
207
|
+
start_frame:int=None, end_frame:int=None,
|
|
208
|
+
video_index:int=None, video_tot:int=None, verbose:bool=True):
|
|
209
|
+
|
|
210
|
+
if tracks is None:
|
|
211
|
+
tracks = pd.read_csv(track_file, header=None, dtype={0:int, 1:int, 2:int, 3:int, 4:int, 5:int, 6:float, 7:int, 8:int, 9:int})
|
|
212
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3', 'r4']
|
|
213
|
+
|
|
214
|
+
cmap = plt.get_cmap('tab20b')
|
|
215
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
216
|
+
|
|
217
|
+
cap = cv2.VideoCapture(input_video)
|
|
218
|
+
if not cap.isOpened():
|
|
219
|
+
raise IOError("Couldn't open webcam or video")
|
|
220
|
+
|
|
221
|
+
if start_frame is None:
|
|
222
|
+
start_frame = 0
|
|
223
|
+
if end_frame is None:
|
|
224
|
+
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
225
|
+
|
|
226
|
+
tot_frames = end_frame - start_frame + 1
|
|
227
|
+
|
|
228
|
+
if verbose:
|
|
229
|
+
pbar = tqdm(total=tot_frames, unit=" frames")
|
|
230
|
+
if self.compress_message:
|
|
231
|
+
pbar.set_description_str("Generating labels")
|
|
232
|
+
else:
|
|
233
|
+
if video_index and video_tot:
|
|
234
|
+
pbar.set_description_str("Generating labels {} of {}".format(video_index, video_tot))
|
|
235
|
+
else:
|
|
236
|
+
pbar.set_description_str("Generating labels {} ".format(input_video))
|
|
237
|
+
|
|
238
|
+
selected_tracks = tracks.loc[(tracks['frame']>=start_frame) & (tracks['frame']<=end_frame)].copy()
|
|
239
|
+
|
|
240
|
+
results = []
|
|
241
|
+
for index, track in selected_tracks.iterrows():
|
|
242
|
+
|
|
243
|
+
if color is None:
|
|
244
|
+
final_color = colors[int(track['track']) % len(colors)]
|
|
245
|
+
final_color = [i * 255 for i in final_color]
|
|
246
|
+
else:
|
|
247
|
+
final_color = color
|
|
248
|
+
|
|
249
|
+
if class_name == True:
|
|
250
|
+
label_str = str(int(track['track'])) + ' ' + str(int(track['cls']))
|
|
251
|
+
else:
|
|
252
|
+
label_str = str(int(track['track']))
|
|
253
|
+
results.append([track['frame'], 'bbox', [(track['x'], track['y']), (track['x'] + track['w'], track['y'] + track['h'])],
|
|
254
|
+
final_color, size, thick, label_str])
|
|
255
|
+
if tail>0:
|
|
256
|
+
frames = [*range(int(track['frame'])-tail, int(track['frame']))]
|
|
257
|
+
pre_boxes = tracks.loc[(tracks['frame'].isin(frames)) & (tracks['track']==track['track'])].values.tolist()
|
|
258
|
+
|
|
259
|
+
if len(pre_boxes)>0:
|
|
260
|
+
for pre_box in pre_boxes:
|
|
261
|
+
xc = int(pre_box[2]) + int(pre_box[4]/2)
|
|
262
|
+
yc = int(pre_box[3]) + int(pre_box[5]/2)
|
|
263
|
+
results.append([track['frame'], 'circle', [(xc, yc)],
|
|
264
|
+
final_color, 0, -1, ''])
|
|
265
|
+
|
|
266
|
+
if verbose:
|
|
267
|
+
pbar.update()
|
|
268
|
+
|
|
269
|
+
if verbose:
|
|
270
|
+
pbar.close()
|
|
271
|
+
|
|
272
|
+
results.sort()
|
|
273
|
+
results = list(results for results,_ in itertools.groupby(results))
|
|
274
|
+
df = pd.DataFrame(results, columns=['frame','type','coords','color','size','thick','desc'])
|
|
275
|
+
df.sort_values(by='frame', inplace=True)
|
|
276
|
+
|
|
277
|
+
if output_video:
|
|
278
|
+
self.draw(input_video = input_video, output_video = output_video,
|
|
279
|
+
draws = df, start_frame = start_frame, end_frame = end_frame,
|
|
280
|
+
video_index = video_index, video_tot = video_tot, verbose=verbose)
|
|
281
|
+
|
|
282
|
+
if label_file:
|
|
283
|
+
df.to_csv(label_file, index=False)
|
|
284
|
+
|
|
285
|
+
return df
|
|
286
|
+
|
|
287
|
+
def draw_dets(self, input_video:str, output_video:str,
|
|
288
|
+
dets:pd.DataFrame = None, det_file:str = None, label_file:str=None,
|
|
289
|
+
color = None, class_name = False,
|
|
290
|
+
start_frame:int=None, end_frame:int=None,
|
|
291
|
+
video_index:int=None, video_tot:int=None):
|
|
292
|
+
|
|
293
|
+
if dets is None:
|
|
294
|
+
dets = pd.read_csv(det_file, header=None)
|
|
295
|
+
|
|
296
|
+
names = load_classes()
|
|
297
|
+
|
|
298
|
+
cmap = plt.get_cmap('tab20b')
|
|
299
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
300
|
+
|
|
301
|
+
cap = cv2.VideoCapture(input_video)
|
|
302
|
+
if not cap.isOpened():
|
|
303
|
+
raise IOError("Couldn't open webcam or video")
|
|
304
|
+
|
|
305
|
+
if start_frame is None:
|
|
306
|
+
start_frame = 0
|
|
307
|
+
if end_frame is None:
|
|
308
|
+
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
309
|
+
|
|
310
|
+
tot_frames = end_frame - start_frame + 1
|
|
311
|
+
|
|
312
|
+
pbar = tqdm(total=len(dets), unit=" dets")
|
|
313
|
+
if self.compress_message:
|
|
314
|
+
pbar.set_description_str("Generating labels")
|
|
315
|
+
else:
|
|
316
|
+
if video_index and video_tot:
|
|
317
|
+
pbar.set_description_str("Generating labels {} of {}".format(video_index, video_tot))
|
|
318
|
+
else:
|
|
319
|
+
pbar.set_description_str("Generating labels {} ".format(input_video))
|
|
320
|
+
|
|
321
|
+
selected_dets = dets.loc[(dets[0]>=start_frame) & (dets[0]<=end_frame)].copy()
|
|
322
|
+
|
|
323
|
+
results = []
|
|
324
|
+
for index, det in selected_dets.iterrows():
|
|
325
|
+
|
|
326
|
+
if color is None:
|
|
327
|
+
final_color = colors[int(det[7]) % len(colors)]
|
|
328
|
+
final_color = [i * 255 for i in final_color]
|
|
329
|
+
else:
|
|
330
|
+
final_color = color
|
|
331
|
+
|
|
332
|
+
if class_name == True:
|
|
333
|
+
desc = names[int(det[7])]
|
|
334
|
+
else:
|
|
335
|
+
desc = str(int(det[7]))
|
|
336
|
+
|
|
337
|
+
results.append([det[0], 'bbox', [(det[2], det[3]), (det[2]+det[4], det[3]+det[5])],
|
|
338
|
+
final_color, 0.8, 1, desc])
|
|
339
|
+
pbar.update()
|
|
340
|
+
|
|
341
|
+
results.sort()
|
|
342
|
+
results = list(results for results,_ in itertools.groupby(results))
|
|
343
|
+
df = pd.DataFrame(results, columns=['frame','type','coords','color','size','thick','desc'])
|
|
344
|
+
df.sort_values(by='frame', inplace=True)
|
|
345
|
+
|
|
346
|
+
if output_video:
|
|
347
|
+
self.draw(input_video = input_video, output_video = output_video,
|
|
348
|
+
draws = df, start_frame = start_frame, end_frame = end_frame,
|
|
349
|
+
video_index = video_index, video_tot = video_tot)
|
|
350
|
+
|
|
351
|
+
if label_file:
|
|
352
|
+
df.to_csv(label_file, index=False)
|
|
353
|
+
|
|
354
|
+
return df
|
|
355
|
+
|
|
356
|
+
def clip(self, input_video:str, output_video:str, start_frame:int=None, end_frame:int=None):
|
|
357
|
+
cap = cv2.VideoCapture(input_video)
|
|
358
|
+
if not cap.isOpened():
|
|
359
|
+
raise IOError("Couldn't open webcam or video")
|
|
360
|
+
|
|
361
|
+
if start_frame is None:
|
|
362
|
+
start_frame = 0
|
|
363
|
+
if end_frame is None:
|
|
364
|
+
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
365
|
+
|
|
366
|
+
tot_frames = end_frame - start_frame + 1
|
|
367
|
+
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
|
368
|
+
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
|
369
|
+
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
370
|
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
|
371
|
+
writer = cv2.VideoWriter(output_video, fourcc, fps, (width, height))
|
|
372
|
+
|
|
373
|
+
pbar = tqdm(total=tot_frames, unit=" frames")
|
|
374
|
+
if self.compress_message:
|
|
375
|
+
pbar.set_description_str("Cutting")
|
|
376
|
+
else:
|
|
377
|
+
pbar.set_description_str("Cutting {} ".format(input_video))
|
|
378
|
+
|
|
379
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
|
|
380
|
+
while cap.isOpened():
|
|
381
|
+
pos_frame = int(cap.get(cv2.CAP_PROP_POS_FRAMES))
|
|
382
|
+
ret, frame = cap.read()
|
|
383
|
+
if (not ret) or (pos_frame>end_frame):
|
|
384
|
+
break
|
|
385
|
+
|
|
386
|
+
writer.write(frame)
|
|
387
|
+
key = cv2.waitKey(1) & 0xFF
|
|
388
|
+
if key == ord("q"):
|
|
389
|
+
break
|
|
390
|
+
|
|
391
|
+
pbar.update()
|
|
392
|
+
|
|
393
|
+
cv2.destroyAllWindows()
|
|
394
|
+
cap.release()
|
|
395
|
+
writer.release()
|
|
396
|
+
|
|
397
|
+
@staticmethod
|
|
398
|
+
def export_frames(input_video:str, frames:list[int], output_path:str, prefix:str=None):
|
|
399
|
+
|
|
400
|
+
cap = cv2.VideoCapture(input_video)
|
|
401
|
+
if not cap.isOpened():
|
|
402
|
+
raise IOError("Couldn't open webcam or video")
|
|
403
|
+
|
|
404
|
+
pbar = tqdm(total=len(frames), unit=" frames")
|
|
405
|
+
pbar.set_description_str("Extracting frame")
|
|
406
|
+
|
|
407
|
+
for frame in frames:
|
|
408
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, frame)
|
|
409
|
+
ret, frame_read = cap.read()
|
|
410
|
+
|
|
411
|
+
if prefix is None:
|
|
412
|
+
frame_file = os.path.join(output_path, str(frame)+'.jpg')
|
|
413
|
+
else:
|
|
414
|
+
frame_file = os.path.join(output_path, prefix+'-'+str(frame)+'.jpg')
|
|
415
|
+
|
|
416
|
+
if ret:
|
|
417
|
+
cv2.imwrite(frame_file, frame_read)
|
|
418
|
+
else:
|
|
419
|
+
break
|
|
420
|
+
|
|
421
|
+
pbar.update()
|
|
422
|
+
|
|
423
|
+
pbar.close()
|
|
424
|
+
cap.release()
|
|
425
|
+
|
|
426
|
+
print("Writing frames to {}".format(output_path))
|
|
427
|
+
|
|
428
|
+
@staticmethod
|
|
429
|
+
def export_track_frames(input_video:str, tracks:pd.DataFrame, output_path:str, bbox = True, prefix:str=None, thick:int=2):
|
|
430
|
+
|
|
431
|
+
if (tracks is None) or (len(tracks.columns)<10):
|
|
432
|
+
raise Exception("Invalid tracks!")
|
|
433
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3', 'r4']
|
|
434
|
+
ids = tracks['track'].unique()
|
|
435
|
+
|
|
436
|
+
cap = cv2.VideoCapture(input_video)
|
|
437
|
+
if not cap.isOpened():
|
|
438
|
+
raise IOError("Couldn't open webcam or video")
|
|
439
|
+
|
|
440
|
+
cmap = plt.get_cmap('tab20b')
|
|
441
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
442
|
+
|
|
443
|
+
pbar = tqdm(total=len(ids), unit=' frame')
|
|
444
|
+
for id in ids:
|
|
445
|
+
pbar.desc = "Extracting track: "+str(id)
|
|
446
|
+
selected = tracks[tracks['track']==id]
|
|
447
|
+
if len(selected) > 0:
|
|
448
|
+
for index, track in selected.iterrows():
|
|
449
|
+
frame = track['frame']
|
|
450
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, frame)
|
|
451
|
+
ret, img = cap.read()
|
|
452
|
+
|
|
453
|
+
if ret:
|
|
454
|
+
if bbox == True:
|
|
455
|
+
x1 = track['x']
|
|
456
|
+
y1 = track['y']
|
|
457
|
+
x2 = track['x'] + track['w']
|
|
458
|
+
y2 = track['y'] + track['h']
|
|
459
|
+
final_color = colors[int(id) % len(colors)]
|
|
460
|
+
final_color = [i * 255 for i in final_color]
|
|
461
|
+
cv2.rectangle(img, (int(x1), int(y1) ), (int(x2), int(y2)), final_color, thick)
|
|
462
|
+
|
|
463
|
+
if prefix is None:
|
|
464
|
+
frame_file = os.path.join(output_path, str(id)+'_'+str(frame)+'.jpg')
|
|
465
|
+
else:
|
|
466
|
+
frame_file = os.path.join(output_path, prefix+'-'+str(id)+'_'+str(frame)+'.jpg')
|
|
467
|
+
|
|
468
|
+
cv2.imwrite(frame_file, img)
|
|
469
|
+
else:
|
|
470
|
+
break
|
|
471
|
+
|
|
472
|
+
pbar.update()
|
|
473
|
+
|
|
474
|
+
pbar.close()
|
|
475
|
+
cap.release()
|
|
476
|
+
|
|
477
|
+
print("Writing frames to {}".format(output_path))
|
|
478
|
+
|
|
479
|
+
@staticmethod
|
|
480
|
+
def time2frame(input_video:str, time:float):
|
|
481
|
+
cap = cv2.VideoCapture(input_video)
|
|
482
|
+
if not cap.isOpened():
|
|
483
|
+
raise IOError("Couldn't open webcam or video")
|
|
484
|
+
|
|
485
|
+
video_fps = int(cap.get(cv2.CAP_PROP_FPS)) #original fps
|
|
486
|
+
frame = int(video_fps * time)
|
|
487
|
+
return frame
|
|
488
|
+
|
|
489
|
+
class LabelGenerator():
|
|
490
|
+
def __init__(self) -> None:
|
|
491
|
+
self.draws = []
|
|
492
|
+
|
|
493
|
+
|
|
494
|
+
if __name__=='__main__':
|
|
495
|
+
video_file = "/mnt/d/videos/hfst/Standard_SCU7WH_2022-09-16_0630.02.001.mp4"
|
|
496
|
+
iou_file = "/mnt/d/videos/hfst/Standard_SCU7WH_2022-09-16_0630.02.001_iou.txt"
|
|
497
|
+
track_file = "/mnt/d/videos/hfst/tracks/Standard_SCU7WH_2022-09-16_0630.02.001_track.txt"
|
|
498
|
+
label_video = "/mnt/d/videos/hfst/labels/Standard_SCU7WH_2022-09-16_0630.02.001_track.mp4"
|
|
499
|
+
label_file = "/mnt/d/videos/hfst/tracks/Standard_SCU7WH_2022-09-16_0630.02.001_label.txt"
|
|
500
|
+
|
|
501
|
+
labeler = Labeler(video_file, zoom_factor=0.5, nodraw_empty=True, label_fields=[6])
|
|
502
|
+
labeler.draw(label_file, video_file, label_video)
|
dnt/shared/__init__.py
CHANGED
dnt/shared/data/coco.names
CHANGED
|
File without changes
|
dnt/shared/data/openimages.names
CHANGED
|
File without changes
|
dnt/shared/data/voc.names
CHANGED
|
File without changes
|
dnt/shared/download.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import requests
|
|
2
|
+
|
|
3
|
+
def download_file(url, destination, verbose=True):
|
|
4
|
+
response = requests.get(url, stream=True)
|
|
5
|
+
response.raise_for_status() # Check if the request was successful
|
|
6
|
+
|
|
7
|
+
with open(destination, 'wb') as file:
|
|
8
|
+
for chunk in response.iter_content(chunk_size=8192):
|
|
9
|
+
file.write(chunk)
|
|
10
|
+
|
|
11
|
+
if verbose:
|
|
12
|
+
print(f"Downloaded {url} to {destination}")
|
dnt/shared/synhcro.py
ADDED
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import pandas as pd
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from pytz import timezone
|
|
4
|
+
from dnt.detect import Detector
|
|
5
|
+
from tqdm import tqdm
|
|
6
|
+
import os
|
|
7
|
+
|
|
8
|
+
class Synchronizer():
|
|
9
|
+
def __init__(self, videos:list[str], ref_frame:int, ref_time:int, ref_timezone:str='US/Eastern', offsets:list[int]=None) -> None:
|
|
10
|
+
self.videos = videos
|
|
11
|
+
self.ref_frame = ref_frame
|
|
12
|
+
self.ref_time = ref_time
|
|
13
|
+
self.ref_timezone = timezone(ref_timezone)
|
|
14
|
+
self.offsets = offsets
|
|
15
|
+
|
|
16
|
+
def process(self, output_path:str=None, local:bool=False, message:bool=False)->pd.DataFrame:
|
|
17
|
+
'''
|
|
18
|
+
Add unix time stamp to each frame
|
|
19
|
+
Inputs:
|
|
20
|
+
output_path - Output folder for output files, if None, will not produce files
|
|
21
|
+
local - if generate local time string
|
|
22
|
+
Returns:
|
|
23
|
+
a Dataframe contains frame and timestamps ['frame', 'unix_time', 'video', 'local_time'(if local is True)]
|
|
24
|
+
'''
|
|
25
|
+
ref_frame = self.ref_frame
|
|
26
|
+
ref_time = self.ref_time
|
|
27
|
+
offsets = [0] * len(videos)
|
|
28
|
+
if self.offsets:
|
|
29
|
+
offsets = self.offsets
|
|
30
|
+
|
|
31
|
+
results = []
|
|
32
|
+
cnt = 0
|
|
33
|
+
for video in self.videos:
|
|
34
|
+
|
|
35
|
+
if fps <= 0:
|
|
36
|
+
raise Exception("fps is invalid.")
|
|
37
|
+
self.milliseconds_per_frame = 1/self.fps * 1000
|
|
38
|
+
|
|
39
|
+
df = Synchronizer.add_unix_time(video, ref_frame, ref_time, video_index=cnt+1, video_tot=len(self.videos), message=message)
|
|
40
|
+
|
|
41
|
+
if local:
|
|
42
|
+
df['local_time'] = df['unix_time'].apply(lambda x: Synchronizer.convert_unix_local(x))
|
|
43
|
+
results.append(df)
|
|
44
|
+
|
|
45
|
+
if output_path:
|
|
46
|
+
basename = os.path.basename(video).split('.')[0]
|
|
47
|
+
time_file = os.path.join(output_path, basename+'_time.csv')
|
|
48
|
+
df.to_csv(time_file, index=False)
|
|
49
|
+
|
|
50
|
+
cnt+=1
|
|
51
|
+
if cnt<len(videos):
|
|
52
|
+
fps = Detector.get_fps(video)
|
|
53
|
+
if fps <= 0:
|
|
54
|
+
raise Exception('fps is invalid for {}'.format(video))
|
|
55
|
+
milliseconds_per_frame = 1/fps * 1000
|
|
56
|
+
ref_frame = 0
|
|
57
|
+
ref_time = df['unix_time'].max() + offsets[cnt] * milliseconds_per_frame
|
|
58
|
+
|
|
59
|
+
return pd.concat(results)
|
|
60
|
+
|
|
61
|
+
@staticmethod
|
|
62
|
+
def add_unix_time_to_frame(frame:int, ref_frame:int, ref_time:int, ref_timezone:str='US/Eastern',
|
|
63
|
+
fps:int=30, verbos=True, local=False) -> int:
|
|
64
|
+
if fps <= 0:
|
|
65
|
+
raise Exception("fps is invalid.")
|
|
66
|
+
milliseconds_per_frame = 1/fps * 1000
|
|
67
|
+
|
|
68
|
+
dif_frame = frame - ref_frame
|
|
69
|
+
return round(ref_time + dif_frame * milliseconds_per_frame)
|
|
70
|
+
|
|
71
|
+
@staticmethod
|
|
72
|
+
def add_unix_time_to_frames(frames:pd.DataFrame, ref_frame:int, ref_time:int, ref_timezone:str='US/Eastern',
|
|
73
|
+
fps:int=30, verbos=True, local=False) -> None:
|
|
74
|
+
|
|
75
|
+
if fps <= 0:
|
|
76
|
+
raise Exception("fps is invalid.")
|
|
77
|
+
milliseconds_per_frame = 1/fps * 1000
|
|
78
|
+
|
|
79
|
+
pbar = tqdm(total=frames, desc='Adding timestamp')
|
|
80
|
+
for index, frame in frames.iterrows():
|
|
81
|
+
dif_frame = frame['frame'] - ref_frame
|
|
82
|
+
frame_time = round(ref_time + dif_frame * milliseconds_per_frame)
|
|
83
|
+
frames.at[index, 'unix_time'] = frame_time
|
|
84
|
+
if local:
|
|
85
|
+
frames.at[index, 'local_time'] = Synchronizer.convert_unix_local(frame_time)
|
|
86
|
+
|
|
87
|
+
if verbos:
|
|
88
|
+
pbar.update()
|
|
89
|
+
|
|
90
|
+
return frames
|
|
91
|
+
|
|
92
|
+
@staticmethod
|
|
93
|
+
def add_unix_time(video, ref_frame, ref_time, video_index:int=None, video_tot=None, message:bool=False)->pd.DataFrame:
|
|
94
|
+
'''
|
|
95
|
+
Add unit timestamp to each frame
|
|
96
|
+
Inputs:
|
|
97
|
+
video - video file name
|
|
98
|
+
ref_frame - the reference frame
|
|
99
|
+
ref_time - the unix time for the reference frame
|
|
100
|
+
video_index - the index of video
|
|
101
|
+
video_tot - the total number of videos
|
|
102
|
+
'''
|
|
103
|
+
fps = Detector.get_fps(video)
|
|
104
|
+
if fps <= 0:
|
|
105
|
+
raise Exception("fps is invalid for {}".format(video))
|
|
106
|
+
milliseconds_per_frame = 1/fps * 1000
|
|
107
|
+
frames = Detector.get_frames(video)
|
|
108
|
+
|
|
109
|
+
if message:
|
|
110
|
+
if video_index and video_tot:
|
|
111
|
+
pbar = tqdm(total=frames, desc='Adding unix time: {} of {}'.format(video_index, video_tot))
|
|
112
|
+
else:
|
|
113
|
+
pbar = tqdm(total=frames, desc='Adding unix time: {}'.format(video))
|
|
114
|
+
|
|
115
|
+
results = []
|
|
116
|
+
for frame in range(frames):
|
|
117
|
+
dif_frame = frame - ref_frame
|
|
118
|
+
frame_time = round(ref_time + dif_frame * milliseconds_per_frame)
|
|
119
|
+
results.append([frame, frame_time, video])
|
|
120
|
+
|
|
121
|
+
if message:
|
|
122
|
+
pbar.update()
|
|
123
|
+
|
|
124
|
+
df = pd.DataFrame(results, columns=['frame', 'unix_time', 'video'])
|
|
125
|
+
return df
|
|
126
|
+
|
|
127
|
+
@staticmethod
|
|
128
|
+
def convert_unix_local(unix_time:int, ref_timezone:str='US/Eastern')->str:
|
|
129
|
+
tz = timezone(ref_timezone)
|
|
130
|
+
return str(datetime.fromtimestamp(unix_time/1000, tz).__str__())
|
|
131
|
+
|
|
132
|
+
if __name__ == '__main__':
|
|
133
|
+
videos = ['/mnt/d/videos/ped2stage/1026_2/videos/gh011293.mp4',
|
|
134
|
+
'/mnt/d/videos/ped2stage/1026_2/videos/gh021293.mp4',
|
|
135
|
+
'/mnt/d/videos/ped2stage/1026_2/videos/gh031293.mp4',
|
|
136
|
+
'/mnt/d/videos/ped2stage/1026_2/videos/gh041293.mp4']
|
|
137
|
+
|
|
138
|
+
ref_frame = 2
|
|
139
|
+
ref_time = 1698331984441
|
|
140
|
+
|
|
141
|
+
synchronizer = Synchronizer(videos, ref_frame, ref_time)
|
|
142
|
+
df = synchronizer.process('/mnt/d/videos/ped2stage/time_synchro', local=True, message=True)
|
|
143
|
+
df.to_csv('/mnt/d/videos/ped2stage/time_synchro/text2.csv', index=False)
|
|
144
|
+
|
|
145
|
+
'''
|
|
146
|
+
results = Synchronizer.add_unix_time(input_video, ref_frame, ref_time)
|
|
147
|
+
results['local_time'] = results['unix_time'].apply(lambda x: Synchronizer.convert_unix_local(x))
|
|
148
|
+
|
|
149
|
+
results.to_csv('/mnt/d/videos/ped2stage/time_synchro/text.csv', index=False)
|
|
150
|
+
'''
|