dnt 0.2.4__py3-none-any.whl → 0.3.1.8__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- dnt/__init__.py +3 -2
- dnt/analysis/__init__.py +3 -2
- dnt/analysis/count.py +54 -37
- dnt/analysis/interaction2.py +518 -0
- dnt/analysis/stop.py +22 -17
- dnt/analysis/stop2.py +289 -0
- dnt/analysis/stop3.py +758 -0
- dnt/detect/signal/detector.py +326 -0
- dnt/detect/timestamp.py +105 -0
- dnt/detect/yolov8/detector.py +179 -36
- dnt/detect/yolov8/segmentor.py +60 -2
- dnt/engine/__init__.py +8 -0
- dnt/engine/bbox_interp.py +83 -0
- dnt/engine/bbox_iou.py +20 -0
- dnt/engine/cluster.py +31 -0
- dnt/engine/iob.py +66 -0
- dnt/filter/filter.py +333 -2
- dnt/label/labeler.py +4 -4
- dnt/label/labeler2.py +631 -0
- dnt/shared/__init__.py +2 -1
- dnt/shared/data/coco.names +0 -0
- dnt/shared/data/openimages.names +0 -0
- dnt/shared/data/voc.names +0 -0
- dnt/shared/download.py +12 -0
- dnt/shared/synhcro.py +150 -0
- dnt/shared/util.py +17 -4
- dnt/third_party/fast-reid/__init__.py +1 -0
- dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
- dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
- dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
- dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
- dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
- dnt/third_party/fast-reid/configs/__init__.py +0 -0
- dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
- dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
- dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
- dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
- dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
- dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
- dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
- dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
- dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
- dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
- dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
- dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
- dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
- dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
- dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
- dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
- dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
- dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
- dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
- dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
- dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
- dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
- dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
- dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
- dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
- dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
- dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
- dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
- dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
- dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
- dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
- dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
- dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
- dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
- dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
- dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
- dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
- dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
- dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
- dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
- dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
- dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
- dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
- dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
- dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
- dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
- dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
- dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
- dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
- dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
- dnt/track/__init__.py +2 -0
- dnt/track/botsort/__init__.py +4 -0
- dnt/track/botsort/bot_tracker/__init__.py +3 -0
- dnt/track/botsort/bot_tracker/basetrack.py +60 -0
- dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
- dnt/track/botsort/bot_tracker/gmc.py +316 -0
- dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
- dnt/track/botsort/bot_tracker/matching.py +194 -0
- dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
- dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
- dnt/track/botsort/inference.py +96 -0
- dnt/track/config.py +120 -0
- dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
- dnt/track/dsort/configs/deep_sort.yaml +0 -0
- dnt/track/dsort/configs/fastreid.yaml +1 -1
- dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
- dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
- dnt/track/dsort/deep_sort/deep_sort.py +31 -20
- dnt/track/dsort/deep_sort/sort/detection.py +2 -1
- dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
- dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
- dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
- dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
- dnt/track/dsort/deep_sort/sort/track.py +2 -1
- dnt/track/dsort/deep_sort/sort/tracker.py +1 -1
- dnt/track/dsort/dsort.py +43 -33
- dnt/track/re_class.py +117 -0
- dnt/track/sort/sort.py +9 -6
- dnt/track/tracker.py +213 -32
- dnt-0.3.1.8.dist-info/METADATA +117 -0
- dnt-0.3.1.8.dist-info/RECORD +315 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.8.dist-info}/WHEEL +1 -1
- dnt/analysis/yield.py +0 -9
- dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
- dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
- dnt/track/dsort/deep_sort/deep/test.py +0 -77
- dnt/track/dsort/deep_sort/deep/train.py +0 -189
- dnt/track/dsort/utils/asserts.py +0 -13
- dnt/track/dsort/utils/draw.py +0 -36
- dnt/track/dsort/utils/json_logger.py +0 -383
- dnt/track/dsort/utils/log.py +0 -17
- dnt/track/dsort/utils/parser.py +0 -35
- dnt/track/dsort/utils/tools.py +0 -39
- dnt-0.2.4.dist-info/METADATA +0 -35
- dnt-0.2.4.dist-info/RECORD +0 -64
- /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.8.dist-info/licenses}/LICENSE +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.8.dist-info}/top_level.txt +0 -0
dnt/label/labeler2.py
ADDED
|
@@ -0,0 +1,631 @@
|
|
|
1
|
+
import os, sys
|
|
2
|
+
sys.path.append(os.path.dirname(__file__))
|
|
3
|
+
sys.path.append(os.path.join(os.path.dirname(__file__), '..'))
|
|
4
|
+
|
|
5
|
+
import cv2
|
|
6
|
+
import numpy as np
|
|
7
|
+
import matplotlib.pyplot as plt
|
|
8
|
+
from tqdm import tqdm
|
|
9
|
+
import pandas as pd
|
|
10
|
+
import itertools
|
|
11
|
+
from shared.util import load_classes
|
|
12
|
+
import random
|
|
13
|
+
import subprocess
|
|
14
|
+
|
|
15
|
+
class Labeler:
|
|
16
|
+
def __init__(self,
|
|
17
|
+
method:str='opencv',
|
|
18
|
+
encoder:str='libx264',
|
|
19
|
+
preset:str='medium',
|
|
20
|
+
crf:int=23,
|
|
21
|
+
pix_fmt:str='bgr24',
|
|
22
|
+
compress_message:bool=False,
|
|
23
|
+
nodraw_empty:bool=True):
|
|
24
|
+
'''
|
|
25
|
+
Parameters:\n
|
|
26
|
+
- method: 'opencv' (default) - use opencv to draw labels),
|
|
27
|
+
'ffmpeg' - use ffmpeg to draw labels
|
|
28
|
+
'chrome_safe' - use ffmpeg to draw labels with chrome compatible video format
|
|
29
|
+
- encoder: 'libx264' (default) - use libx264 encoder for ffmpeg,
|
|
30
|
+
'libx265' - use libx265 encoder for ffmpeg
|
|
31
|
+
'h264_nvenc' - use h264_nvenc encoder for ffmpeg
|
|
32
|
+
'hevc_nvenc' - use hevc_nvenc encoder for ffmpeg
|
|
33
|
+
- preset: 'medium' (default) - use medium preset for ffmpeg
|
|
34
|
+
'slow' - use slow preset for ffmpeg
|
|
35
|
+
'fast' - use fast preset for ffmpeg
|
|
36
|
+
- crf: 23 (default) - use 23 crf for ffmpeg, lower is better quality
|
|
37
|
+
- compress_message: False (default) - show compress message in progress bar
|
|
38
|
+
- nodraw_empty: True (default) - not draw empty frames
|
|
39
|
+
'''
|
|
40
|
+
self.method = method
|
|
41
|
+
self.encoder = encoder
|
|
42
|
+
self.preset = preset
|
|
43
|
+
self.crf = crf
|
|
44
|
+
self.pix_fmt = pix_fmt
|
|
45
|
+
self.compress_message=compress_message
|
|
46
|
+
self.nodraw_empty = nodraw_empty
|
|
47
|
+
|
|
48
|
+
def draw(self,
|
|
49
|
+
input_video:str,
|
|
50
|
+
output_video:str,
|
|
51
|
+
draws:pd.DataFrame=None,
|
|
52
|
+
draw_file:str=None,
|
|
53
|
+
start_frame:int=None,
|
|
54
|
+
end_frame:int=None,
|
|
55
|
+
video_index:int=None,
|
|
56
|
+
video_tot:int=None,
|
|
57
|
+
verbose:bool=True):
|
|
58
|
+
'''
|
|
59
|
+
General labeling function\n
|
|
60
|
+
Inputs:\n
|
|
61
|
+
draws: a DataFrame contains labeling information, if None, read label_file
|
|
62
|
+
label_file: a txt file with a header ['frame','type','coords','color','size','thick','desc']
|
|
63
|
+
input_video: raw video
|
|
64
|
+
output_video: labeled video
|
|
65
|
+
start_frame: starting frame
|
|
66
|
+
end_frame: ending frame
|
|
67
|
+
video_index: display video index in batch processing
|
|
68
|
+
video_tot: display total video number in batch processing
|
|
69
|
+
'''
|
|
70
|
+
if draws is not None:
|
|
71
|
+
data = draws
|
|
72
|
+
else:
|
|
73
|
+
data = pd.read_csv(draw_file,
|
|
74
|
+
dtype={'frame':int,
|
|
75
|
+
'type':str,
|
|
76
|
+
'size':float,
|
|
77
|
+
'desc':str,
|
|
78
|
+
'thick':int},
|
|
79
|
+
converters={'coords': lambda x:list(eval(x)), 'color': lambda x:eval(x)})
|
|
80
|
+
|
|
81
|
+
cmap = plt.get_cmap('tab20b')
|
|
82
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
83
|
+
|
|
84
|
+
cap = cv2.VideoCapture(input_video)
|
|
85
|
+
if not cap.isOpened():
|
|
86
|
+
raise IOError("Couldn't open webcam or video")
|
|
87
|
+
|
|
88
|
+
if start_frame is None:
|
|
89
|
+
start_frame = 0
|
|
90
|
+
if end_frame is None:
|
|
91
|
+
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
92
|
+
|
|
93
|
+
tot_frames = end_frame - start_frame + 1
|
|
94
|
+
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
|
95
|
+
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
|
96
|
+
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
97
|
+
|
|
98
|
+
if self.method == 'ffmpeg':
|
|
99
|
+
# FFmpeg command to write H.265 encoded video
|
|
100
|
+
ffmpeg_cmd = [
|
|
101
|
+
"ffmpeg",
|
|
102
|
+
"-y", # Overwrite output file if it exists
|
|
103
|
+
"-f", "rawvideo",
|
|
104
|
+
"-vcodec", "rawvideo",
|
|
105
|
+
"-pix_fmt", self.pix_fmt,
|
|
106
|
+
"-s", f"{width}x{height}",
|
|
107
|
+
"-r", str(fps),
|
|
108
|
+
"-i", "-", # Read input from stdin
|
|
109
|
+
"-c:v", self.encoder, # H.265 codec
|
|
110
|
+
"-preset", self.preset, # Adjust preset as needed (ultrafast, fast, medium, slow, etc.)
|
|
111
|
+
"-crf", str(self.crf), # Constant Rate Factor (higher = more compression, lower = better quality)
|
|
112
|
+
output_video]
|
|
113
|
+
|
|
114
|
+
# Start FFmpeg process
|
|
115
|
+
process = subprocess.Popen(ffmpeg_cmd,
|
|
116
|
+
stdin=subprocess.PIPE,
|
|
117
|
+
stdout=subprocess.DEVNULL,
|
|
118
|
+
stderr=subprocess.DEVNULL)
|
|
119
|
+
elif self.method == 'chrome_safe':
|
|
120
|
+
# FFmpeg command to write H.265 encoded video
|
|
121
|
+
ffmpeg_cmd = [
|
|
122
|
+
"ffmpeg",
|
|
123
|
+
"-y", # Overwrite output file if it exists
|
|
124
|
+
"-f", "rawvideo",
|
|
125
|
+
"-vcodec", "rawvideo",
|
|
126
|
+
"-pix_fmt", "yuv420p",
|
|
127
|
+
"-s", f"{width}x{height}",
|
|
128
|
+
"-r", str(fps),
|
|
129
|
+
"-i", "-", # Read input from stdin
|
|
130
|
+
"-c:v", "libx264", # H.264 codec
|
|
131
|
+
"-profile:v", "high",
|
|
132
|
+
"-level", "4.0", # <- corrected
|
|
133
|
+
"-preset", "medium", # Adjust preset as needed (ultrafast, fast, medium, slow, etc.)
|
|
134
|
+
"-crf", "23", # Constant Rate Factor (higher = more compression, lower = better quality)
|
|
135
|
+
"-movflags", "+faststart",
|
|
136
|
+
"-an",
|
|
137
|
+
output_video]
|
|
138
|
+
|
|
139
|
+
# Start FFmpeg process
|
|
140
|
+
process = subprocess.Popen(ffmpeg_cmd,
|
|
141
|
+
stdin=subprocess.PIPE,
|
|
142
|
+
stdout=subprocess.DEVNULL,
|
|
143
|
+
stderr=subprocess.DEVNULL)
|
|
144
|
+
else:
|
|
145
|
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
|
146
|
+
writer = cv2.VideoWriter(output_video, fourcc, fps, (width, height))
|
|
147
|
+
|
|
148
|
+
if verbose:
|
|
149
|
+
pbar = tqdm(total=tot_frames, unit=" frames")
|
|
150
|
+
if self.compress_message:
|
|
151
|
+
pbar.set_description_str("Labeling")
|
|
152
|
+
else:
|
|
153
|
+
if video_index and video_tot:
|
|
154
|
+
pbar.set_description_str("Labeling {} of {}".format(video_index, video_tot))
|
|
155
|
+
else:
|
|
156
|
+
pbar.set_description_str("Labeling {} ".format(input_video))
|
|
157
|
+
|
|
158
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
|
|
159
|
+
while cap.isOpened():
|
|
160
|
+
pos_frame = int(cap.get(cv2.CAP_PROP_POS_FRAMES))
|
|
161
|
+
ret, frame = cap.read()
|
|
162
|
+
if (not ret) or (pos_frame>end_frame):
|
|
163
|
+
break
|
|
164
|
+
|
|
165
|
+
elements = data.loc[data['frame']==pos_frame]
|
|
166
|
+
|
|
167
|
+
for index, element in elements.iterrows():
|
|
168
|
+
if element['type'] == 'txt':
|
|
169
|
+
label_txt = element['desc']
|
|
170
|
+
color = element['color']
|
|
171
|
+
size = element['size']
|
|
172
|
+
thick = element['thick']
|
|
173
|
+
cv2.putText(frame, label_txt, tuple(map(int, element['coords'][0])), 0, size, color, thick)
|
|
174
|
+
|
|
175
|
+
elif element['type'] == 'line':
|
|
176
|
+
coords = element['coords']
|
|
177
|
+
color = element['color']
|
|
178
|
+
thick = element['thick']
|
|
179
|
+
cv2.line(frame, tuple(map(int, coords[0])), tuple(map(int, coords[1])), color, thick)
|
|
180
|
+
|
|
181
|
+
elif element['type'] == 'box':
|
|
182
|
+
coords = element['coords']
|
|
183
|
+
color = element['color']
|
|
184
|
+
thick = element['thick']
|
|
185
|
+
cv2.rectangle(frame, tuple(map(int, coords[0])), tuple(map(int, coords[1])), color, thick)
|
|
186
|
+
|
|
187
|
+
elif element['type'] == 'bbox':
|
|
188
|
+
coords = element['coords']
|
|
189
|
+
color = element['color']
|
|
190
|
+
thick = element['thick']
|
|
191
|
+
label_txt = element['desc']
|
|
192
|
+
size = element['size']
|
|
193
|
+
|
|
194
|
+
cv2.rectangle(frame, tuple(map(int, coords[0])), tuple(map(int, coords[1])), color, thick)
|
|
195
|
+
cv2.putText(frame, str(label_txt), (int(coords[0][0]), int(coords[0][1]-int(10*size))),
|
|
196
|
+
cv2.FONT_HERSHEY_SIMPLEX, size, color, thick)
|
|
197
|
+
|
|
198
|
+
elif element['type'] == 'circle':
|
|
199
|
+
coords = element['coords']
|
|
200
|
+
color = element['color']
|
|
201
|
+
thick = element['thick']
|
|
202
|
+
label_txt = element['desc']
|
|
203
|
+
radius = int(element['size'])
|
|
204
|
+
|
|
205
|
+
cv2.circle(frame, tuple(map(int, coords[0])), radius=radius, color=color, thickness=thick)
|
|
206
|
+
|
|
207
|
+
elif element['type'] == 'polygon':
|
|
208
|
+
coords = element['coords']
|
|
209
|
+
color = element['color']
|
|
210
|
+
thick = element['thick']
|
|
211
|
+
cv2.polylines(frame, [np.array(coords)], isClosed=True, color=color, thickness=thick)
|
|
212
|
+
|
|
213
|
+
elif element['type'] == 'polylines':
|
|
214
|
+
coords = element['coords']
|
|
215
|
+
color = element['color']
|
|
216
|
+
thick = element['thick']
|
|
217
|
+
cv2.polylines(frame, [np.array(coords)], isClosed=False, color=color, thickness=thick)
|
|
218
|
+
|
|
219
|
+
if self.method == 'ffmpeg':
|
|
220
|
+
process.stdin.write(frame.tobytes())
|
|
221
|
+
else:
|
|
222
|
+
writer.write(frame)
|
|
223
|
+
|
|
224
|
+
if verbose:
|
|
225
|
+
pbar.update()
|
|
226
|
+
|
|
227
|
+
if verbose:
|
|
228
|
+
pbar.close()
|
|
229
|
+
#cv2.destroyAllWindows()
|
|
230
|
+
cap.release()
|
|
231
|
+
if self.method == 'ffmpeg':
|
|
232
|
+
process.stdin.close()
|
|
233
|
+
process.wait()
|
|
234
|
+
else:
|
|
235
|
+
writer.release()
|
|
236
|
+
|
|
237
|
+
def draw_track_clips(self,
|
|
238
|
+
input_video:str,
|
|
239
|
+
output_path:str,
|
|
240
|
+
tracks:pd.DataFrame=None,
|
|
241
|
+
track_file:str = None,
|
|
242
|
+
method:str='all',
|
|
243
|
+
random_number:int=10,
|
|
244
|
+
track_ids:list=None,
|
|
245
|
+
start_frame_offset:int=0,
|
|
246
|
+
end_frame_offset:int=0,
|
|
247
|
+
tail:int=0,
|
|
248
|
+
prefix:bool=False,
|
|
249
|
+
size:int=1,
|
|
250
|
+
thick:int=1,
|
|
251
|
+
video_index:int=None,
|
|
252
|
+
video_tot:int=None,
|
|
253
|
+
verbose:bool=True):
|
|
254
|
+
'''
|
|
255
|
+
Parameters:\n
|
|
256
|
+
input_video: the raw video file
|
|
257
|
+
outputh_path: the folder for outputing track clips
|
|
258
|
+
tracks: the dataframe of tracks
|
|
259
|
+
track_file: the track file if tracks are none
|
|
260
|
+
method: 'all' (default) - all tracks, 'random' - random select tracks, 'specify' - specify track ids
|
|
261
|
+
random_number: the number of track ids if method == 'random'
|
|
262
|
+
track_ids: the list of track ids if method == 'specify'
|
|
263
|
+
start_frame_offset: the offset of start frame, default is 0
|
|
264
|
+
end_frame_offset: the offset of end frame, default is 0
|
|
265
|
+
tail: the length of tail, default is 0
|
|
266
|
+
prefix: if add the video file name as the prefix in output file names, default is False
|
|
267
|
+
size: font size, default is 1
|
|
268
|
+
thick: line thinckness, defualt is 1
|
|
269
|
+
verbose: if show progressing bar, default is True
|
|
270
|
+
'''
|
|
271
|
+
|
|
272
|
+
if tracks is None:
|
|
273
|
+
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})
|
|
274
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3', 'r4']
|
|
275
|
+
|
|
276
|
+
if method == 'random':
|
|
277
|
+
track_ids = tracks['track'].unique().tolist()
|
|
278
|
+
if random_number<=0:
|
|
279
|
+
random_number = 10
|
|
280
|
+
track_ids = random.sample(track_ids, random_number)
|
|
281
|
+
elif method == 'specify':
|
|
282
|
+
if (track_ids is None) or (len(track_ids)==0):
|
|
283
|
+
print('No tracks are provided!')
|
|
284
|
+
return pd.DataFrame()
|
|
285
|
+
else:
|
|
286
|
+
track_ids = tracks['track'].unique().tolist()
|
|
287
|
+
|
|
288
|
+
#pbar = tqdm(total=len(track_ids), desc='Labeling tracks ', unit='clips')
|
|
289
|
+
for id in track_ids:
|
|
290
|
+
selected_tracks = tracks[tracks['track']==id].copy()
|
|
291
|
+
start_frame = max(selected_tracks['frame'].min() - start_frame_offset, 0)
|
|
292
|
+
end_frame = min(selected_tracks['frame'].max() + end_frame_offset,
|
|
293
|
+
cv2.VideoCapture(input_video).get(cv2.CAP_PROP_FRAME_COUNT)-1)
|
|
294
|
+
if prefix:
|
|
295
|
+
out_video = os.path.join(output_path, os.path.splitext(os.path.basename(input_video))[0]+"_"+str(id)+'.mp4')
|
|
296
|
+
else:
|
|
297
|
+
out_video = os.path.join(output_path, str(id)+'.mp4')
|
|
298
|
+
|
|
299
|
+
self.draw_tracks(input_video=input_video,
|
|
300
|
+
output_video=out_video,
|
|
301
|
+
tracks=selected_tracks,
|
|
302
|
+
start_frame=start_frame,
|
|
303
|
+
end_frame=end_frame,
|
|
304
|
+
verbose=verbose,
|
|
305
|
+
tail=tail,
|
|
306
|
+
thick=thick,
|
|
307
|
+
size=size,
|
|
308
|
+
video_index=video_index,
|
|
309
|
+
video_tot=video_tot)
|
|
310
|
+
|
|
311
|
+
#pbar.update()
|
|
312
|
+
#pbar.close()
|
|
313
|
+
|
|
314
|
+
def draw_tracks(self,
|
|
315
|
+
input_video:str,
|
|
316
|
+
output_video:str,
|
|
317
|
+
tracks:pd.DataFrame=None,
|
|
318
|
+
track_file:str=None,
|
|
319
|
+
label_file:str=None,
|
|
320
|
+
color=None,
|
|
321
|
+
tail:int=0,
|
|
322
|
+
thick:int=2,
|
|
323
|
+
size:int=1,
|
|
324
|
+
class_name=False,
|
|
325
|
+
start_frame:int=None,
|
|
326
|
+
end_frame:int=None,
|
|
327
|
+
video_index:int=None,
|
|
328
|
+
video_tot:int=None,
|
|
329
|
+
verbose:bool=True):
|
|
330
|
+
|
|
331
|
+
if tracks is None:
|
|
332
|
+
tracks = pd.read_csv(track_file,
|
|
333
|
+
header=None,
|
|
334
|
+
dtype={0:int, 1:int, 2:int, 3:int, 4:int, 5:int, 6:float, 7:int, 8:int, 9:int})
|
|
335
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3', 'r4']
|
|
336
|
+
|
|
337
|
+
cmap = plt.get_cmap('tab20b')
|
|
338
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
339
|
+
|
|
340
|
+
cap = cv2.VideoCapture(input_video)
|
|
341
|
+
if not cap.isOpened():
|
|
342
|
+
raise IOError("Couldn't open webcam or video")
|
|
343
|
+
|
|
344
|
+
if start_frame is None:
|
|
345
|
+
start_frame = 0
|
|
346
|
+
if end_frame is None:
|
|
347
|
+
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
348
|
+
|
|
349
|
+
selected_tracks = tracks.loc[(tracks['frame']>=start_frame) & (tracks['frame']<=end_frame)].copy()
|
|
350
|
+
|
|
351
|
+
pbar_desc = ""
|
|
352
|
+
if self.compress_message:
|
|
353
|
+
pbar_desc = "Generating labels"
|
|
354
|
+
else:
|
|
355
|
+
if video_index and video_tot:
|
|
356
|
+
pbar_desc = "Generating labels {} of {}".format(video_index, video_tot)
|
|
357
|
+
else:
|
|
358
|
+
pbar_desc = "Generating labels {} ".format(input_video)
|
|
359
|
+
|
|
360
|
+
pbar = tqdm(total=len(selected_tracks), unit=" frames", desc=pbar_desc)
|
|
361
|
+
results = []
|
|
362
|
+
for _, track in selected_tracks.iterrows():
|
|
363
|
+
|
|
364
|
+
if color is None:
|
|
365
|
+
final_color = colors[int(track['track']) % len(colors)]
|
|
366
|
+
final_color = [i * 255 for i in final_color]
|
|
367
|
+
else:
|
|
368
|
+
final_color = color
|
|
369
|
+
|
|
370
|
+
if class_name == True:
|
|
371
|
+
label_str = str(int(track['track'])) + ' ' + str(int(track['cls']))
|
|
372
|
+
else:
|
|
373
|
+
label_str = str(int(track['track']))
|
|
374
|
+
results.append([track['frame'], 'bbox', [(track['x'], track['y']), (track['x'] + track['w'], track['y'] + track['h'])],
|
|
375
|
+
final_color, size, thick, label_str])
|
|
376
|
+
if tail>0:
|
|
377
|
+
frames = [*range(int(track['frame'])-tail, int(track['frame']))]
|
|
378
|
+
pre_boxes = tracks.loc[(tracks['frame'].isin(frames)) & (tracks['track']==track['track'])].values.tolist()
|
|
379
|
+
|
|
380
|
+
if len(pre_boxes)>0:
|
|
381
|
+
for pre_box in pre_boxes:
|
|
382
|
+
xc = int(pre_box[2]) + int(pre_box[4]/2)
|
|
383
|
+
yc = int(pre_box[3]) + int(pre_box[5]/2)
|
|
384
|
+
results.append([track['frame'], 'circle', [(xc, yc)],
|
|
385
|
+
final_color, 0, -1, ''])
|
|
386
|
+
|
|
387
|
+
if verbose:
|
|
388
|
+
pbar.update()
|
|
389
|
+
|
|
390
|
+
if verbose:
|
|
391
|
+
pbar.close()
|
|
392
|
+
|
|
393
|
+
results.sort()
|
|
394
|
+
results = list(results for results,_ in itertools.groupby(results))
|
|
395
|
+
df = pd.DataFrame(results, columns=['frame','type','coords','color','size','thick','desc'])
|
|
396
|
+
df.sort_values(by='frame', inplace=True)
|
|
397
|
+
|
|
398
|
+
if output_video:
|
|
399
|
+
self.draw(input_video = input_video, output_video = output_video,
|
|
400
|
+
draws = df, start_frame = start_frame, end_frame = end_frame,
|
|
401
|
+
video_index = video_index, video_tot = video_tot, verbose=verbose)
|
|
402
|
+
|
|
403
|
+
if label_file:
|
|
404
|
+
df.to_csv(label_file, index=False)
|
|
405
|
+
|
|
406
|
+
return df
|
|
407
|
+
|
|
408
|
+
def draw_dets(self, input_video:str, output_video:str,
|
|
409
|
+
dets:pd.DataFrame = None, det_file:str = None, label_file:str=None,
|
|
410
|
+
color = None, class_name = False,
|
|
411
|
+
start_frame:int=None, end_frame:int=None,
|
|
412
|
+
video_index:int=None, video_tot:int=None):
|
|
413
|
+
|
|
414
|
+
if dets is None:
|
|
415
|
+
dets = pd.read_csv(det_file, header=None)
|
|
416
|
+
|
|
417
|
+
names = load_classes()
|
|
418
|
+
|
|
419
|
+
cmap = plt.get_cmap('tab20b')
|
|
420
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
421
|
+
|
|
422
|
+
cap = cv2.VideoCapture(input_video)
|
|
423
|
+
if not cap.isOpened():
|
|
424
|
+
raise IOError("Couldn't open webcam or video")
|
|
425
|
+
|
|
426
|
+
if start_frame is None:
|
|
427
|
+
start_frame = 0
|
|
428
|
+
if end_frame is None:
|
|
429
|
+
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
430
|
+
|
|
431
|
+
tot_frames = end_frame - start_frame + 1
|
|
432
|
+
selected_dets = dets.loc[(dets[0]>=start_frame) & (dets[0]<=end_frame)].copy()
|
|
433
|
+
|
|
434
|
+
pbar = tqdm(total=len(selected_dets), unit=" dets")
|
|
435
|
+
if self.compress_message:
|
|
436
|
+
pbar.set_description_str("Generating labels")
|
|
437
|
+
else:
|
|
438
|
+
if video_index and video_tot:
|
|
439
|
+
pbar.set_description_str("Generating labels {} of {}".format(video_index, video_tot))
|
|
440
|
+
else:
|
|
441
|
+
pbar.set_description_str("Generating labels {} ".format(input_video))
|
|
442
|
+
|
|
443
|
+
results = []
|
|
444
|
+
for index, det in selected_dets.iterrows():
|
|
445
|
+
|
|
446
|
+
if color is None:
|
|
447
|
+
final_color = colors[int(det[7]) % len(colors)]
|
|
448
|
+
final_color = [i * 255 for i in final_color]
|
|
449
|
+
else:
|
|
450
|
+
final_color = color
|
|
451
|
+
|
|
452
|
+
if class_name == True:
|
|
453
|
+
desc = names[int(det[7])]
|
|
454
|
+
else:
|
|
455
|
+
desc = str(int(det[7]))
|
|
456
|
+
|
|
457
|
+
results.append([det[0], 'bbox', [(det[2], det[3]), (det[2]+det[4], det[3]+det[5])],
|
|
458
|
+
final_color, 0.8, 1, desc])
|
|
459
|
+
pbar.update()
|
|
460
|
+
|
|
461
|
+
results.sort()
|
|
462
|
+
results = list(results for results,_ in itertools.groupby(results))
|
|
463
|
+
df = pd.DataFrame(results, columns=['frame','type','coords','color','size','thick','desc'])
|
|
464
|
+
df.sort_values(by='frame', inplace=True)
|
|
465
|
+
|
|
466
|
+
if output_video:
|
|
467
|
+
self.draw(input_video = input_video, output_video = output_video,
|
|
468
|
+
draws = df, start_frame = start_frame, end_frame = end_frame,
|
|
469
|
+
video_index = video_index, video_tot = video_tot)
|
|
470
|
+
|
|
471
|
+
if label_file:
|
|
472
|
+
df.to_csv(label_file, index=False)
|
|
473
|
+
|
|
474
|
+
return df
|
|
475
|
+
|
|
476
|
+
def clip(self, input_video:str, output_video:str, start_frame:int=None, end_frame:int=None):
|
|
477
|
+
cap = cv2.VideoCapture(input_video)
|
|
478
|
+
if not cap.isOpened():
|
|
479
|
+
raise IOError("Couldn't open webcam or video")
|
|
480
|
+
|
|
481
|
+
if start_frame is None:
|
|
482
|
+
start_frame = 0
|
|
483
|
+
if end_frame is None:
|
|
484
|
+
end_frame = int(cap.get(cv2.CAP_PROP_FRAME_COUNT))-1
|
|
485
|
+
|
|
486
|
+
tot_frames = end_frame - start_frame + 1
|
|
487
|
+
fps = int(cap.get(cv2.CAP_PROP_FPS))
|
|
488
|
+
width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
|
|
489
|
+
height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
|
|
490
|
+
fourcc = cv2.VideoWriter_fourcc(*'mp4v')
|
|
491
|
+
writer = cv2.VideoWriter(output_video, fourcc, fps, (width, height))
|
|
492
|
+
|
|
493
|
+
pbar = tqdm(total=tot_frames, unit=" frames")
|
|
494
|
+
if self.compress_message:
|
|
495
|
+
pbar.set_description_str("Cutting")
|
|
496
|
+
else:
|
|
497
|
+
pbar.set_description_str("Cutting {} ".format(input_video))
|
|
498
|
+
|
|
499
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, start_frame)
|
|
500
|
+
while cap.isOpened():
|
|
501
|
+
pos_frame = int(cap.get(cv2.CAP_PROP_POS_FRAMES))
|
|
502
|
+
ret, frame = cap.read()
|
|
503
|
+
if (not ret) or (pos_frame>end_frame):
|
|
504
|
+
break
|
|
505
|
+
|
|
506
|
+
writer.write(frame)
|
|
507
|
+
key = cv2.waitKey(1) & 0xFF
|
|
508
|
+
if key == ord("q"):
|
|
509
|
+
break
|
|
510
|
+
|
|
511
|
+
pbar.update()
|
|
512
|
+
|
|
513
|
+
cv2.destroyAllWindows()
|
|
514
|
+
cap.release()
|
|
515
|
+
writer.release()
|
|
516
|
+
|
|
517
|
+
@staticmethod
|
|
518
|
+
def export_frames(input_video:str, frames:list[int], output_path:str, prefix:str=None):
|
|
519
|
+
|
|
520
|
+
cap = cv2.VideoCapture(input_video)
|
|
521
|
+
if not cap.isOpened():
|
|
522
|
+
raise IOError("Couldn't open webcam or video")
|
|
523
|
+
|
|
524
|
+
pbar = tqdm(total=len(frames), unit=" frames")
|
|
525
|
+
pbar.set_description_str("Extracting frame")
|
|
526
|
+
|
|
527
|
+
for frame in frames:
|
|
528
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, frame)
|
|
529
|
+
ret, frame_read = cap.read()
|
|
530
|
+
|
|
531
|
+
if prefix is None:
|
|
532
|
+
frame_file = os.path.join(output_path, str(frame)+'.jpg')
|
|
533
|
+
else:
|
|
534
|
+
frame_file = os.path.join(output_path, prefix+'-'+str(frame)+'.jpg')
|
|
535
|
+
|
|
536
|
+
if ret:
|
|
537
|
+
cv2.imwrite(frame_file, frame_read)
|
|
538
|
+
else:
|
|
539
|
+
break
|
|
540
|
+
|
|
541
|
+
pbar.update()
|
|
542
|
+
|
|
543
|
+
pbar.close()
|
|
544
|
+
cap.release()
|
|
545
|
+
|
|
546
|
+
print("Writing frames to {}".format(output_path))
|
|
547
|
+
|
|
548
|
+
@staticmethod
|
|
549
|
+
def export_track_frames(input_video:str, tracks:pd.DataFrame, output_path:str, bbox = True, prefix:str=None, thick:int=2):
|
|
550
|
+
|
|
551
|
+
if (tracks is None) or (len(tracks.columns)<10):
|
|
552
|
+
raise Exception("Invalid tracks!")
|
|
553
|
+
tracks.columns = ['frame', 'track', 'x', 'y', 'w', 'h', 'score', 'cls', 'r3', 'r4']
|
|
554
|
+
ids = tracks['track'].unique()
|
|
555
|
+
|
|
556
|
+
cap = cv2.VideoCapture(input_video)
|
|
557
|
+
if not cap.isOpened():
|
|
558
|
+
raise IOError("Couldn't open webcam or video")
|
|
559
|
+
|
|
560
|
+
cmap = plt.get_cmap('tab20b')
|
|
561
|
+
colors = [cmap(i)[:3] for i in np.linspace(0, 1, 20)]
|
|
562
|
+
|
|
563
|
+
pbar = tqdm(total=len(ids), unit=' frame')
|
|
564
|
+
for id in ids:
|
|
565
|
+
pbar.desc = "Extracting track: "+str(id)
|
|
566
|
+
selected = tracks[tracks['track']==id]
|
|
567
|
+
if len(selected) > 0:
|
|
568
|
+
for index, track in selected.iterrows():
|
|
569
|
+
frame = track['frame']
|
|
570
|
+
cap.set(cv2.CAP_PROP_POS_FRAMES, frame)
|
|
571
|
+
ret, img = cap.read()
|
|
572
|
+
|
|
573
|
+
if ret:
|
|
574
|
+
if bbox == True:
|
|
575
|
+
x1 = track['x']
|
|
576
|
+
y1 = track['y']
|
|
577
|
+
x2 = track['x'] + track['w']
|
|
578
|
+
y2 = track['y'] + track['h']
|
|
579
|
+
final_color = colors[int(id) % len(colors)]
|
|
580
|
+
final_color = [i * 255 for i in final_color]
|
|
581
|
+
cv2.rectangle(img, (int(x1), int(y1) ), (int(x2), int(y2)), final_color, thick)
|
|
582
|
+
|
|
583
|
+
if prefix is None:
|
|
584
|
+
frame_file = os.path.join(output_path, str(id)+'_'+str(frame)+'.jpg')
|
|
585
|
+
else:
|
|
586
|
+
frame_file = os.path.join(output_path, prefix+'-'+str(id)+'_'+str(frame)+'.jpg')
|
|
587
|
+
|
|
588
|
+
cv2.imwrite(frame_file, img)
|
|
589
|
+
else:
|
|
590
|
+
break
|
|
591
|
+
|
|
592
|
+
pbar.update()
|
|
593
|
+
|
|
594
|
+
pbar.close()
|
|
595
|
+
cap.release()
|
|
596
|
+
|
|
597
|
+
print("Writing frames to {}".format(output_path))
|
|
598
|
+
|
|
599
|
+
@staticmethod
|
|
600
|
+
def time2frame(input_video:str, time:float):
|
|
601
|
+
cap = cv2.VideoCapture(input_video)
|
|
602
|
+
if not cap.isOpened():
|
|
603
|
+
raise IOError("Couldn't open webcam or video")
|
|
604
|
+
|
|
605
|
+
video_fps = int(cap.get(cv2.CAP_PROP_FPS)) #original fps
|
|
606
|
+
frame = int(video_fps * time)
|
|
607
|
+
return frame
|
|
608
|
+
|
|
609
|
+
class LabelGenerator():
|
|
610
|
+
def __init__(self) -> None:
|
|
611
|
+
self.draws = []
|
|
612
|
+
|
|
613
|
+
|
|
614
|
+
if __name__=='__main__':
|
|
615
|
+
|
|
616
|
+
video_file = "/mnt/d/videos/sample/traffic.mp4"
|
|
617
|
+
iou_file = "/mnt/d/videos/sample/dets/traffic_iou.txt"
|
|
618
|
+
track_file = "/mnt/d/videos/sample/tracks/traffic_track.txt"
|
|
619
|
+
label_video = "/mnt/d/videos/sample/labels/traffic_track-ffmpeg.mp4"
|
|
620
|
+
label_file = "/mnt/d/videos/sample/labels/traffic_track.txt"
|
|
621
|
+
|
|
622
|
+
labeler = Labeler(method='ffmpeg',
|
|
623
|
+
encoder='hevc_nvenc',
|
|
624
|
+
preset='medium',
|
|
625
|
+
crf=23,
|
|
626
|
+
compress_message=True)
|
|
627
|
+
labeler.draw_tracks(input_video=video_file,
|
|
628
|
+
output_video=label_video,
|
|
629
|
+
track_file=track_file)
|
|
630
|
+
|
|
631
|
+
|
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}")
|