dnt 0.2.4__py3-none-any.whl → 0.3.1.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of dnt might be problematic. Click here for more details.
- dnt/__init__.py +3 -2
- dnt/analysis/__init__.py +3 -2
- dnt/analysis/count.py +54 -37
- dnt/analysis/interaction2.py +518 -0
- dnt/analysis/stop.py +22 -17
- dnt/analysis/stop2.py +289 -0
- dnt/analysis/stop3.py +758 -0
- dnt/detect/signal/detector.py +326 -0
- dnt/detect/timestamp.py +105 -0
- dnt/detect/yolov8/detector.py +179 -36
- dnt/detect/yolov8/segmentor.py +60 -2
- dnt/engine/__init__.py +8 -0
- dnt/engine/bbox_interp.py +83 -0
- dnt/engine/bbox_iou.py +20 -0
- dnt/engine/cluster.py +31 -0
- dnt/engine/iob.py +66 -0
- dnt/filter/filter.py +333 -2
- dnt/label/labeler.py +4 -4
- dnt/label/labeler2.py +605 -0
- dnt/shared/__init__.py +2 -1
- dnt/shared/data/coco.names +0 -0
- dnt/shared/data/openimages.names +0 -0
- dnt/shared/data/voc.names +0 -0
- dnt/shared/download.py +12 -0
- dnt/shared/synhcro.py +150 -0
- dnt/shared/util.py +17 -4
- dnt/third_party/fast-reid/__init__.py +1 -0
- dnt/third_party/fast-reid/configs/Base-AGW.yml +19 -0
- dnt/third_party/fast-reid/configs/Base-MGN.yml +12 -0
- dnt/third_party/fast-reid/configs/Base-SBS.yml +63 -0
- dnt/third_party/fast-reid/configs/Base-bagtricks.yml +76 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/DukeMTMC/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MOT20/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R101-ibn.yml +13 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/bagtricks_S50.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/MSMT17/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/AGW_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/bagtricks_vit.yml +88 -0
- dnt/third_party/fast-reid/configs/Market1501/mgn_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R101-ibn.yml +12 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50-ibn.yml +11 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_R50.yml +7 -0
- dnt/third_party/fast-reid/configs/Market1501/sbs_S50.yml +11 -0
- dnt/third_party/fast-reid/configs/VERIWild/bagtricks_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VeRi/sbs_R50-ibn.yml +35 -0
- dnt/third_party/fast-reid/configs/VehicleID/bagtricks_R50-ibn.yml +36 -0
- dnt/third_party/fast-reid/configs/__init__.py +0 -0
- dnt/third_party/fast-reid/fast_reid_interfece.py +175 -0
- dnt/third_party/fast-reid/fastreid/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/config/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/config/config.py +319 -0
- dnt/third_party/fast-reid/fastreid/config/defaults.py +329 -0
- dnt/third_party/fast-reid/fastreid/data/__init__.py +17 -0
- dnt/third_party/fast-reid/fastreid/data/build.py +194 -0
- dnt/third_party/fast-reid/fastreid/data/common.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/data_utils.py +202 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/AirportALERT.py +50 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/__init__.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/bases.py +183 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/caviara.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk03.py +274 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/cuhk_sysu.py +58 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/dukemtmcreid.py +70 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/grid.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/iLIDS.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/lpw.py +49 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/market1501.py +89 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/msmt17.py +114 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pes3d.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/pku.py +44 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prai.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/prid.py +41 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/saivt.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sensereid.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/shinpuhkan.py +48 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/sysu_mm.py +47 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/thermalworld.py +43 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/vehicleid.py +126 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veri.py +69 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/veriwild.py +140 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/viper.py +45 -0
- dnt/third_party/fast-reid/fastreid/data/datasets/wildtracker.py +59 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/data_sampler.py +85 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/imbalance_sampler.py +67 -0
- dnt/third_party/fast-reid/fastreid/data/samplers/triplet_sampler.py +260 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/autoaugment.py +806 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/build.py +100 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/functional.py +180 -0
- dnt/third_party/fast-reid/fastreid/data/transforms/transforms.py +161 -0
- dnt/third_party/fast-reid/fastreid/engine/__init__.py +15 -0
- dnt/third_party/fast-reid/fastreid/engine/defaults.py +490 -0
- dnt/third_party/fast-reid/fastreid/engine/hooks.py +534 -0
- dnt/third_party/fast-reid/fastreid/engine/launch.py +103 -0
- dnt/third_party/fast-reid/fastreid/engine/train_loop.py +357 -0
- dnt/third_party/fast-reid/fastreid/evaluation/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/evaluation/clas_evaluator.py +81 -0
- dnt/third_party/fast-reid/fastreid/evaluation/evaluator.py +176 -0
- dnt/third_party/fast-reid/fastreid/evaluation/query_expansion.py +46 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank.py +200 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/__init__.py +20 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/setup.py +32 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rank_cylib/test_cython.py +106 -0
- dnt/third_party/fast-reid/fastreid/evaluation/reid_evaluation.py +143 -0
- dnt/third_party/fast-reid/fastreid/evaluation/rerank.py +73 -0
- dnt/third_party/fast-reid/fastreid/evaluation/roc.py +90 -0
- dnt/third_party/fast-reid/fastreid/evaluation/testing.py +88 -0
- dnt/third_party/fast-reid/fastreid/layers/__init__.py +19 -0
- dnt/third_party/fast-reid/fastreid/layers/activation.py +59 -0
- dnt/third_party/fast-reid/fastreid/layers/any_softmax.py +80 -0
- dnt/third_party/fast-reid/fastreid/layers/batch_norm.py +205 -0
- dnt/third_party/fast-reid/fastreid/layers/context_block.py +113 -0
- dnt/third_party/fast-reid/fastreid/layers/drop.py +161 -0
- dnt/third_party/fast-reid/fastreid/layers/frn.py +199 -0
- dnt/third_party/fast-reid/fastreid/layers/gather_layer.py +30 -0
- dnt/third_party/fast-reid/fastreid/layers/helpers.py +31 -0
- dnt/third_party/fast-reid/fastreid/layers/non_local.py +54 -0
- dnt/third_party/fast-reid/fastreid/layers/pooling.py +124 -0
- dnt/third_party/fast-reid/fastreid/layers/se_layer.py +25 -0
- dnt/third_party/fast-reid/fastreid/layers/splat.py +109 -0
- dnt/third_party/fast-reid/fastreid/layers/weight_init.py +122 -0
- dnt/third_party/fast-reid/fastreid/modeling/__init__.py +23 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/__init__.py +18 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/build.py +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenet.py +195 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/mobilenetv3.py +283 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/osnet.py +525 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/__init__.py +4 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/config.py +396 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B0_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B1_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B2_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B3_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B4_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet/EN-B5_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/effnet.py +281 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnet.py +596 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-1.6GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-12GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-16GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-3.2GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-32GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-4.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-400MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-6.4GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-600MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-8.0GF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnetx/RegNetX-800MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-1.6GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-12GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-16GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-200MF_dds_8gpu.yaml +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-3.2GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-32GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-4.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-400MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-6.4GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-600MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-8.0GF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/regnet/regnety/RegNetY-800MF_dds_8gpu.yaml +27 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/repvgg.py +309 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnest.py +365 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnet.py +364 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/resnext.py +335 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/shufflenet.py +203 -0
- dnt/third_party/fast-reid/fastreid/modeling/backbones/vision_transformer.py +399 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/__init__.py +11 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/build.py +25 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/clas_head.py +36 -0
- dnt/third_party/fast-reid/fastreid/modeling/heads/embedding_head.py +151 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/__init__.py +12 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/circle_loss.py +71 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/cross_entroy_loss.py +54 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/focal_loss.py +92 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/triplet_loss.py +113 -0
- dnt/third_party/fast-reid/fastreid/modeling/losses/utils.py +48 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/__init__.py +14 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/baseline.py +188 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/build.py +26 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/distiller.py +140 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/mgn.py +394 -0
- dnt/third_party/fast-reid/fastreid/modeling/meta_arch/moco.py +126 -0
- dnt/third_party/fast-reid/fastreid/solver/__init__.py +8 -0
- dnt/third_party/fast-reid/fastreid/solver/build.py +348 -0
- dnt/third_party/fast-reid/fastreid/solver/lr_scheduler.py +66 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/__init__.py +10 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/lamb.py +123 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/radam.py +149 -0
- dnt/third_party/fast-reid/fastreid/solver/optim/swa.py +246 -0
- dnt/third_party/fast-reid/fastreid/utils/__init__.py +6 -0
- dnt/third_party/fast-reid/fastreid/utils/checkpoint.py +503 -0
- dnt/third_party/fast-reid/fastreid/utils/collect_env.py +158 -0
- dnt/third_party/fast-reid/fastreid/utils/comm.py +255 -0
- dnt/third_party/fast-reid/fastreid/utils/compute_dist.py +200 -0
- dnt/third_party/fast-reid/fastreid/utils/env.py +119 -0
- dnt/third_party/fast-reid/fastreid/utils/events.py +461 -0
- dnt/third_party/fast-reid/fastreid/utils/faiss_utils.py +127 -0
- dnt/third_party/fast-reid/fastreid/utils/file_io.py +520 -0
- dnt/third_party/fast-reid/fastreid/utils/history_buffer.py +71 -0
- dnt/third_party/fast-reid/fastreid/utils/logger.py +211 -0
- dnt/third_party/fast-reid/fastreid/utils/params.py +103 -0
- dnt/third_party/fast-reid/fastreid/utils/precision_bn.py +94 -0
- dnt/third_party/fast-reid/fastreid/utils/registry.py +66 -0
- dnt/third_party/fast-reid/fastreid/utils/summary.py +120 -0
- dnt/third_party/fast-reid/fastreid/utils/timer.py +68 -0
- dnt/third_party/fast-reid/fastreid/utils/visualizer.py +278 -0
- dnt/track/__init__.py +2 -0
- dnt/track/botsort/__init__.py +4 -0
- dnt/track/botsort/bot_tracker/__init__.py +3 -0
- dnt/track/botsort/bot_tracker/basetrack.py +60 -0
- dnt/track/botsort/bot_tracker/bot_sort.py +473 -0
- dnt/track/botsort/bot_tracker/gmc.py +316 -0
- dnt/track/botsort/bot_tracker/kalman_filter.py +269 -0
- dnt/track/botsort/bot_tracker/matching.py +194 -0
- dnt/track/botsort/bot_tracker/mc_bot_sort.py +505 -0
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/evaluation.py +14 -4
- dnt/track/{dsort/utils → botsort/bot_tracker/tracking_utils}/io.py +19 -36
- dnt/track/botsort/bot_tracker/tracking_utils/timer.py +37 -0
- dnt/track/botsort/inference.py +96 -0
- dnt/track/config.py +120 -0
- dnt/track/dsort/configs/bagtricks_R50.yml +7 -0
- dnt/track/dsort/configs/deep_sort.yaml +0 -0
- dnt/track/dsort/configs/fastreid.yaml +1 -1
- dnt/track/dsort/deep_sort/deep/checkpoint/ckpt.t7 +0 -0
- dnt/track/dsort/deep_sort/deep/feature_extractor.py +87 -8
- dnt/track/dsort/deep_sort/deep_sort.py +31 -20
- dnt/track/dsort/deep_sort/sort/detection.py +2 -1
- dnt/track/dsort/deep_sort/sort/iou_matching.py +0 -2
- dnt/track/dsort/deep_sort/sort/linear_assignment.py +0 -3
- dnt/track/dsort/deep_sort/sort/nn_matching.py +5 -5
- dnt/track/dsort/deep_sort/sort/preprocessing.py +1 -2
- dnt/track/dsort/deep_sort/sort/track.py +2 -1
- dnt/track/dsort/deep_sort/sort/tracker.py +1 -1
- dnt/track/dsort/dsort.py +43 -33
- dnt/track/re_class.py +117 -0
- dnt/track/sort/sort.py +9 -6
- dnt/track/tracker.py +213 -32
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/METADATA +41 -13
- dnt-0.3.1.7.dist-info/RECORD +315 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/WHEEL +1 -1
- dnt/analysis/yield.py +0 -9
- dnt/track/dsort/deep_sort/deep/evaluate.py +0 -15
- dnt/track/dsort/deep_sort/deep/original_model.py +0 -106
- dnt/track/dsort/deep_sort/deep/test.py +0 -77
- dnt/track/dsort/deep_sort/deep/train.py +0 -189
- dnt/track/dsort/utils/asserts.py +0 -13
- dnt/track/dsort/utils/draw.py +0 -36
- dnt/track/dsort/utils/json_logger.py +0 -383
- dnt/track/dsort/utils/log.py +0 -17
- dnt/track/dsort/utils/parser.py +0 -35
- dnt/track/dsort/utils/tools.py +0 -39
- dnt-0.2.4.dist-info/RECORD +0 -64
- /dnt/{track/dsort/utils → third_party/fast-reid/checkpoint}/__init__.py +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info/licenses}/LICENSE +0 -0
- {dnt-0.2.4.dist-info → dnt-0.3.1.7.dist-info}/top_level.txt +0 -0
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import argparse
|
|
2
|
-
import os
|
|
3
|
-
import time
|
|
4
|
-
|
|
5
|
-
import numpy as np
|
|
6
|
-
import matplotlib.pyplot as plt
|
|
7
|
-
import torch
|
|
8
|
-
import torch.backends.cudnn as cudnn
|
|
9
|
-
import torchvision
|
|
10
|
-
|
|
11
|
-
from model import Net
|
|
12
|
-
|
|
13
|
-
parser = argparse.ArgumentParser(description="Train on market1501")
|
|
14
|
-
parser.add_argument("--data-dir",default='data',type=str)
|
|
15
|
-
parser.add_argument("--no-cuda",action="store_true")
|
|
16
|
-
parser.add_argument("--gpu-id",default=0,type=int)
|
|
17
|
-
parser.add_argument("--lr",default=0.1, type=float)
|
|
18
|
-
parser.add_argument("--interval",'-i',default=20,type=int)
|
|
19
|
-
parser.add_argument('--resume', '-r',action='store_true')
|
|
20
|
-
args = parser.parse_args()
|
|
21
|
-
|
|
22
|
-
# device
|
|
23
|
-
device = "cuda:{}".format(args.gpu_id) if torch.cuda.is_available() and not args.no_cuda else "cpu"
|
|
24
|
-
if torch.cuda.is_available() and not args.no_cuda:
|
|
25
|
-
cudnn.benchmark = True
|
|
26
|
-
|
|
27
|
-
# data loading
|
|
28
|
-
root = args.data_dir
|
|
29
|
-
train_dir = os.path.join(root,"train")
|
|
30
|
-
test_dir = os.path.join(root,"test")
|
|
31
|
-
transform_train = torchvision.transforms.Compose([
|
|
32
|
-
torchvision.transforms.RandomCrop((128,64),padding=4),
|
|
33
|
-
torchvision.transforms.RandomHorizontalFlip(),
|
|
34
|
-
torchvision.transforms.ToTensor(),
|
|
35
|
-
torchvision.transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
|
|
36
|
-
])
|
|
37
|
-
transform_test = torchvision.transforms.Compose([
|
|
38
|
-
torchvision.transforms.Resize((128,64)),
|
|
39
|
-
torchvision.transforms.ToTensor(),
|
|
40
|
-
torchvision.transforms.Normalize([0.485, 0.456, 0.406], [0.229, 0.224, 0.225])
|
|
41
|
-
])
|
|
42
|
-
trainloader = torch.utils.data.DataLoader(
|
|
43
|
-
torchvision.datasets.ImageFolder(train_dir, transform=transform_train),
|
|
44
|
-
batch_size=64,shuffle=True
|
|
45
|
-
)
|
|
46
|
-
testloader = torch.utils.data.DataLoader(
|
|
47
|
-
torchvision.datasets.ImageFolder(test_dir, transform=transform_test),
|
|
48
|
-
batch_size=64,shuffle=True
|
|
49
|
-
)
|
|
50
|
-
num_classes = max(len(trainloader.dataset.classes), len(testloader.dataset.classes))
|
|
51
|
-
|
|
52
|
-
# net definition
|
|
53
|
-
start_epoch = 0
|
|
54
|
-
net = Net(num_classes=num_classes)
|
|
55
|
-
if args.resume:
|
|
56
|
-
assert os.path.isfile("./checkpoint/ckpt.t7"), "Error: no checkpoint file found!"
|
|
57
|
-
print('Loading from checkpoint/ckpt.t7')
|
|
58
|
-
checkpoint = torch.load("./checkpoint/ckpt.t7")
|
|
59
|
-
# import ipdb; ipdb.set_trace()
|
|
60
|
-
net_dict = checkpoint['net_dict']
|
|
61
|
-
net.load_state_dict(net_dict)
|
|
62
|
-
best_acc = checkpoint['acc']
|
|
63
|
-
start_epoch = checkpoint['epoch']
|
|
64
|
-
net.to(device)
|
|
65
|
-
|
|
66
|
-
# loss and optimizer
|
|
67
|
-
criterion = torch.nn.CrossEntropyLoss()
|
|
68
|
-
optimizer = torch.optim.SGD(net.parameters(), args.lr, momentum=0.9, weight_decay=5e-4)
|
|
69
|
-
best_acc = 0.
|
|
70
|
-
|
|
71
|
-
# train function for each epoch
|
|
72
|
-
def train(epoch):
|
|
73
|
-
print("\nEpoch : %d"%(epoch+1))
|
|
74
|
-
net.train()
|
|
75
|
-
training_loss = 0.
|
|
76
|
-
train_loss = 0.
|
|
77
|
-
correct = 0
|
|
78
|
-
total = 0
|
|
79
|
-
interval = args.interval
|
|
80
|
-
start = time.time()
|
|
81
|
-
for idx, (inputs, labels) in enumerate(trainloader):
|
|
82
|
-
# forward
|
|
83
|
-
inputs,labels = inputs.to(device),labels.to(device)
|
|
84
|
-
outputs = net(inputs)
|
|
85
|
-
loss = criterion(outputs, labels)
|
|
86
|
-
|
|
87
|
-
# backward
|
|
88
|
-
optimizer.zero_grad()
|
|
89
|
-
loss.backward()
|
|
90
|
-
optimizer.step()
|
|
91
|
-
|
|
92
|
-
# accumurating
|
|
93
|
-
training_loss += loss.item()
|
|
94
|
-
train_loss += loss.item()
|
|
95
|
-
correct += outputs.max(dim=1)[1].eq(labels).sum().item()
|
|
96
|
-
total += labels.size(0)
|
|
97
|
-
|
|
98
|
-
# print
|
|
99
|
-
if (idx+1)%interval == 0:
|
|
100
|
-
end = time.time()
|
|
101
|
-
print("[progress:{:.1f}%]time:{:.2f}s Loss:{:.5f} Correct:{}/{} Acc:{:.3f}%".format(
|
|
102
|
-
100.*(idx+1)/len(trainloader), end-start, training_loss/interval, correct, total, 100.*correct/total
|
|
103
|
-
))
|
|
104
|
-
training_loss = 0.
|
|
105
|
-
start = time.time()
|
|
106
|
-
|
|
107
|
-
return train_loss/len(trainloader), 1.- correct/total
|
|
108
|
-
|
|
109
|
-
def test(epoch):
|
|
110
|
-
global best_acc
|
|
111
|
-
net.eval()
|
|
112
|
-
test_loss = 0.
|
|
113
|
-
correct = 0
|
|
114
|
-
total = 0
|
|
115
|
-
start = time.time()
|
|
116
|
-
with torch.no_grad():
|
|
117
|
-
for idx, (inputs, labels) in enumerate(testloader):
|
|
118
|
-
inputs, labels = inputs.to(device), labels.to(device)
|
|
119
|
-
outputs = net(inputs)
|
|
120
|
-
loss = criterion(outputs, labels)
|
|
121
|
-
|
|
122
|
-
test_loss += loss.item()
|
|
123
|
-
correct += outputs.max(dim=1)[1].eq(labels).sum().item()
|
|
124
|
-
total += labels.size(0)
|
|
125
|
-
|
|
126
|
-
print("Testing ...")
|
|
127
|
-
end = time.time()
|
|
128
|
-
print("[progress:{:.1f}%]time:{:.2f}s Loss:{:.5f} Correct:{}/{} Acc:{:.3f}%".format(
|
|
129
|
-
100.*(idx+1)/len(testloader), end-start, test_loss/len(testloader), correct, total, 100.*correct/total
|
|
130
|
-
))
|
|
131
|
-
|
|
132
|
-
# saving checkpoint
|
|
133
|
-
acc = 100.*correct/total
|
|
134
|
-
if acc > best_acc:
|
|
135
|
-
best_acc = acc
|
|
136
|
-
print("Saving parameters to checkpoint/ckpt.t7")
|
|
137
|
-
checkpoint = {
|
|
138
|
-
'net_dict':net.state_dict(),
|
|
139
|
-
'acc':acc,
|
|
140
|
-
'epoch':epoch,
|
|
141
|
-
}
|
|
142
|
-
if not os.path.isdir('checkpoint'):
|
|
143
|
-
os.mkdir('checkpoint')
|
|
144
|
-
torch.save(checkpoint, './checkpoint/ckpt.t7')
|
|
145
|
-
|
|
146
|
-
return test_loss/len(testloader), 1.- correct/total
|
|
147
|
-
|
|
148
|
-
# plot figure
|
|
149
|
-
x_epoch = []
|
|
150
|
-
record = {'train_loss':[], 'train_err':[], 'test_loss':[], 'test_err':[]}
|
|
151
|
-
fig = plt.figure()
|
|
152
|
-
ax0 = fig.add_subplot(121, title="loss")
|
|
153
|
-
ax1 = fig.add_subplot(122, title="top1err")
|
|
154
|
-
def draw_curve(epoch, train_loss, train_err, test_loss, test_err):
|
|
155
|
-
global record
|
|
156
|
-
record['train_loss'].append(train_loss)
|
|
157
|
-
record['train_err'].append(train_err)
|
|
158
|
-
record['test_loss'].append(test_loss)
|
|
159
|
-
record['test_err'].append(test_err)
|
|
160
|
-
|
|
161
|
-
x_epoch.append(epoch)
|
|
162
|
-
ax0.plot(x_epoch, record['train_loss'], 'bo-', label='train')
|
|
163
|
-
ax0.plot(x_epoch, record['test_loss'], 'ro-', label='val')
|
|
164
|
-
ax1.plot(x_epoch, record['train_err'], 'bo-', label='train')
|
|
165
|
-
ax1.plot(x_epoch, record['test_err'], 'ro-', label='val')
|
|
166
|
-
if epoch == 0:
|
|
167
|
-
ax0.legend()
|
|
168
|
-
ax1.legend()
|
|
169
|
-
fig.savefig("train.jpg")
|
|
170
|
-
|
|
171
|
-
# lr decay
|
|
172
|
-
def lr_decay():
|
|
173
|
-
global optimizer
|
|
174
|
-
for params in optimizer.param_groups:
|
|
175
|
-
params['lr'] *= 0.1
|
|
176
|
-
lr = params['lr']
|
|
177
|
-
print("Learning rate adjusted to {}".format(lr))
|
|
178
|
-
|
|
179
|
-
def main():
|
|
180
|
-
for epoch in range(start_epoch, start_epoch+40):
|
|
181
|
-
train_loss, train_err = train(epoch)
|
|
182
|
-
test_loss, test_err = test(epoch)
|
|
183
|
-
draw_curve(epoch, train_loss, train_err, test_loss, test_err)
|
|
184
|
-
if (epoch+1)%20==0:
|
|
185
|
-
lr_decay()
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
if __name__ == '__main__':
|
|
189
|
-
main()
|
dnt/track/dsort/utils/asserts.py
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
from os import environ
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def assert_in(file, files_to_check):
|
|
5
|
-
if file not in files_to_check:
|
|
6
|
-
raise AssertionError("{} does not exist in the list".format(str(file)))
|
|
7
|
-
return True
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def assert_in_env(check_list: list):
|
|
11
|
-
for item in check_list:
|
|
12
|
-
assert_in(item, environ.keys())
|
|
13
|
-
return True
|
dnt/track/dsort/utils/draw.py
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import numpy as np
|
|
2
|
-
import cv2
|
|
3
|
-
|
|
4
|
-
palette = (2 ** 11 - 1, 2 ** 15 - 1, 2 ** 20 - 1)
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
def compute_color_for_labels(label):
|
|
8
|
-
"""
|
|
9
|
-
Simple function that adds fixed color depending on the class
|
|
10
|
-
"""
|
|
11
|
-
color = [int((p * (label ** 2 - label + 1)) % 255) for p in palette]
|
|
12
|
-
return tuple(color)
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def draw_boxes(img, bbox, identities=None, offset=(0,0)):
|
|
16
|
-
for i,box in enumerate(bbox):
|
|
17
|
-
x1,y1,x2,y2 = [int(i) for i in box]
|
|
18
|
-
x1 += offset[0]
|
|
19
|
-
x2 += offset[0]
|
|
20
|
-
y1 += offset[1]
|
|
21
|
-
y2 += offset[1]
|
|
22
|
-
# box text and bar
|
|
23
|
-
id = int(identities[i]) if identities is not None else 0
|
|
24
|
-
color = compute_color_for_labels(id)
|
|
25
|
-
label = '{}{:d}'.format("", id)
|
|
26
|
-
t_size = cv2.getTextSize(label, cv2.FONT_HERSHEY_PLAIN, 2 , 2)[0]
|
|
27
|
-
cv2.rectangle(img,(x1, y1),(x2,y2),color,3)
|
|
28
|
-
cv2.rectangle(img,(x1, y1),(x1+t_size[0]+3,y1+t_size[1]+4), color,-1)
|
|
29
|
-
cv2.putText(img,label,(x1,y1+t_size[1]+4), cv2.FONT_HERSHEY_PLAIN, 2, [255,255,255], 2)
|
|
30
|
-
return img
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if __name__ == '__main__':
|
|
35
|
-
for i in range(82):
|
|
36
|
-
print(compute_color_for_labels(i))
|
|
@@ -1,383 +0,0 @@
|
|
|
1
|
-
"""
|
|
2
|
-
References:
|
|
3
|
-
https://medium.com/analytics-vidhya/creating-a-custom-logging-mechanism-for-real-time-object-detection-using-tdd-4ca2cfcd0a2f
|
|
4
|
-
"""
|
|
5
|
-
import json
|
|
6
|
-
from os import makedirs
|
|
7
|
-
from os.path import exists, join
|
|
8
|
-
from datetime import datetime
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
class JsonMeta(object):
|
|
12
|
-
HOURS = 3
|
|
13
|
-
MINUTES = 59
|
|
14
|
-
SECONDS = 59
|
|
15
|
-
PATH_TO_SAVE = 'LOGS'
|
|
16
|
-
DEFAULT_FILE_NAME = 'remaining'
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
class BaseJsonLogger(object):
|
|
20
|
-
"""
|
|
21
|
-
This is the base class that returns __dict__ of its own
|
|
22
|
-
it also returns the dicts of objects in the attributes that are list instances
|
|
23
|
-
|
|
24
|
-
"""
|
|
25
|
-
|
|
26
|
-
def dic(self):
|
|
27
|
-
# returns dicts of objects
|
|
28
|
-
out = {}
|
|
29
|
-
for k, v in self.__dict__.items():
|
|
30
|
-
if hasattr(v, 'dic'):
|
|
31
|
-
out[k] = v.dic()
|
|
32
|
-
elif isinstance(v, list):
|
|
33
|
-
out[k] = self.list(v)
|
|
34
|
-
else:
|
|
35
|
-
out[k] = v
|
|
36
|
-
return out
|
|
37
|
-
|
|
38
|
-
@staticmethod
|
|
39
|
-
def list(values):
|
|
40
|
-
# applies the dic method on items in the list
|
|
41
|
-
return [v.dic() if hasattr(v, 'dic') else v for v in values]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
class Label(BaseJsonLogger):
|
|
45
|
-
"""
|
|
46
|
-
For each bounding box there are various categories with confidences. Label class keeps track of that information.
|
|
47
|
-
"""
|
|
48
|
-
|
|
49
|
-
def __init__(self, category: str, confidence: float):
|
|
50
|
-
self.category = category
|
|
51
|
-
self.confidence = confidence
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
class Bbox(BaseJsonLogger):
|
|
55
|
-
"""
|
|
56
|
-
This module stores the information for each frame and use them in JsonParser
|
|
57
|
-
Attributes:
|
|
58
|
-
labels (list): List of label module.
|
|
59
|
-
top (int):
|
|
60
|
-
left (int):
|
|
61
|
-
width (int):
|
|
62
|
-
height (int):
|
|
63
|
-
|
|
64
|
-
Args:
|
|
65
|
-
bbox_id (float):
|
|
66
|
-
top (int):
|
|
67
|
-
left (int):
|
|
68
|
-
width (int):
|
|
69
|
-
height (int):
|
|
70
|
-
|
|
71
|
-
References:
|
|
72
|
-
Check Label module for better understanding.
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"""
|
|
76
|
-
|
|
77
|
-
def __init__(self, bbox_id, top, left, width, height):
|
|
78
|
-
self.labels = []
|
|
79
|
-
self.bbox_id = bbox_id
|
|
80
|
-
self.top = top
|
|
81
|
-
self.left = left
|
|
82
|
-
self.width = width
|
|
83
|
-
self.height = height
|
|
84
|
-
|
|
85
|
-
def add_label(self, category, confidence):
|
|
86
|
-
# adds category and confidence only if top_k is not exceeded.
|
|
87
|
-
self.labels.append(Label(category, confidence))
|
|
88
|
-
|
|
89
|
-
def labels_full(self, value):
|
|
90
|
-
return len(self.labels) == value
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
class Frame(BaseJsonLogger):
|
|
94
|
-
"""
|
|
95
|
-
This module stores the information for each frame and use them in JsonParser
|
|
96
|
-
Attributes:
|
|
97
|
-
timestamp (float): The elapsed time of captured frame
|
|
98
|
-
frame_id (int): The frame number of the captured video
|
|
99
|
-
bboxes (list of Bbox objects): Stores the list of bbox objects.
|
|
100
|
-
|
|
101
|
-
References:
|
|
102
|
-
Check Bbox class for better information
|
|
103
|
-
|
|
104
|
-
Args:
|
|
105
|
-
timestamp (float):
|
|
106
|
-
frame_id (int):
|
|
107
|
-
|
|
108
|
-
"""
|
|
109
|
-
|
|
110
|
-
def __init__(self, frame_id: int, timestamp: float = None):
|
|
111
|
-
self.frame_id = frame_id
|
|
112
|
-
self.timestamp = timestamp
|
|
113
|
-
self.bboxes = []
|
|
114
|
-
|
|
115
|
-
def add_bbox(self, bbox_id: int, top: int, left: int, width: int, height: int):
|
|
116
|
-
bboxes_ids = [bbox.bbox_id for bbox in self.bboxes]
|
|
117
|
-
if bbox_id not in bboxes_ids:
|
|
118
|
-
self.bboxes.append(Bbox(bbox_id, top, left, width, height))
|
|
119
|
-
else:
|
|
120
|
-
raise ValueError("Frame with id: {} already has a Bbox with id: {}".format(self.frame_id, bbox_id))
|
|
121
|
-
|
|
122
|
-
def add_label_to_bbox(self, bbox_id: int, category: str, confidence: float):
|
|
123
|
-
bboxes = {bbox.id: bbox for bbox in self.bboxes}
|
|
124
|
-
if bbox_id in bboxes.keys():
|
|
125
|
-
res = bboxes.get(bbox_id)
|
|
126
|
-
res.add_label(category, confidence)
|
|
127
|
-
else:
|
|
128
|
-
raise ValueError('the bbox with id: {} does not exists!'.format(bbox_id))
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
class BboxToJsonLogger(BaseJsonLogger):
|
|
132
|
-
"""
|
|
133
|
-
ُ This module is designed to automate the task of logging jsons. An example json is used
|
|
134
|
-
to show the contents of json file shortly
|
|
135
|
-
Example:
|
|
136
|
-
{
|
|
137
|
-
"video_details": {
|
|
138
|
-
"frame_width": 1920,
|
|
139
|
-
"frame_height": 1080,
|
|
140
|
-
"frame_rate": 20,
|
|
141
|
-
"video_name": "/home/gpu/codes/MSD/pedestrian_2/project/public/camera1.avi"
|
|
142
|
-
},
|
|
143
|
-
"frames": [
|
|
144
|
-
{
|
|
145
|
-
"frame_id": 329,
|
|
146
|
-
"timestamp": 3365.1254
|
|
147
|
-
"bboxes": [
|
|
148
|
-
{
|
|
149
|
-
"labels": [
|
|
150
|
-
{
|
|
151
|
-
"category": "pedestrian",
|
|
152
|
-
"confidence": 0.9
|
|
153
|
-
}
|
|
154
|
-
],
|
|
155
|
-
"bbox_id": 0,
|
|
156
|
-
"top": 1257,
|
|
157
|
-
"left": 138,
|
|
158
|
-
"width": 68,
|
|
159
|
-
"height": 109
|
|
160
|
-
}
|
|
161
|
-
]
|
|
162
|
-
}],
|
|
163
|
-
|
|
164
|
-
Attributes:
|
|
165
|
-
frames (dict): It's a dictionary that maps each frame_id to json attributes.
|
|
166
|
-
video_details (dict): information about video file.
|
|
167
|
-
top_k_labels (int): shows the allowed number of labels
|
|
168
|
-
start_time (datetime object): we use it to automate the json output by time.
|
|
169
|
-
|
|
170
|
-
Args:
|
|
171
|
-
top_k_labels (int): shows the allowed number of labels
|
|
172
|
-
|
|
173
|
-
"""
|
|
174
|
-
|
|
175
|
-
def __init__(self, top_k_labels: int = 1):
|
|
176
|
-
self.frames = {}
|
|
177
|
-
self.video_details = self.video_details = dict(frame_width=None, frame_height=None, frame_rate=None,
|
|
178
|
-
video_name=None)
|
|
179
|
-
self.top_k_labels = top_k_labels
|
|
180
|
-
self.start_time = datetime.now()
|
|
181
|
-
|
|
182
|
-
def set_top_k(self, value):
|
|
183
|
-
self.top_k_labels = value
|
|
184
|
-
|
|
185
|
-
def frame_exists(self, frame_id: int) -> bool:
|
|
186
|
-
"""
|
|
187
|
-
Args:
|
|
188
|
-
frame_id (int):
|
|
189
|
-
|
|
190
|
-
Returns:
|
|
191
|
-
bool: true if frame_id is recognized
|
|
192
|
-
"""
|
|
193
|
-
return frame_id in self.frames.keys()
|
|
194
|
-
|
|
195
|
-
def add_frame(self, frame_id: int, timestamp: float = None) -> None:
|
|
196
|
-
"""
|
|
197
|
-
Args:
|
|
198
|
-
frame_id (int):
|
|
199
|
-
timestamp (float): opencv captured frame time property
|
|
200
|
-
|
|
201
|
-
Raises:
|
|
202
|
-
ValueError: if frame_id would not exist in class frames attribute
|
|
203
|
-
|
|
204
|
-
Returns:
|
|
205
|
-
None
|
|
206
|
-
|
|
207
|
-
"""
|
|
208
|
-
if not self.frame_exists(frame_id):
|
|
209
|
-
self.frames[frame_id] = Frame(frame_id, timestamp)
|
|
210
|
-
else:
|
|
211
|
-
raise ValueError("Frame id: {} already exists".format(frame_id))
|
|
212
|
-
|
|
213
|
-
def bbox_exists(self, frame_id: int, bbox_id: int) -> bool:
|
|
214
|
-
"""
|
|
215
|
-
Args:
|
|
216
|
-
frame_id:
|
|
217
|
-
bbox_id:
|
|
218
|
-
|
|
219
|
-
Returns:
|
|
220
|
-
bool: if bbox exists in frame bboxes list
|
|
221
|
-
"""
|
|
222
|
-
bboxes = []
|
|
223
|
-
if self.frame_exists(frame_id=frame_id):
|
|
224
|
-
bboxes = [bbox.bbox_id for bbox in self.frames[frame_id].bboxes]
|
|
225
|
-
return bbox_id in bboxes
|
|
226
|
-
|
|
227
|
-
def find_bbox(self, frame_id: int, bbox_id: int):
|
|
228
|
-
"""
|
|
229
|
-
|
|
230
|
-
Args:
|
|
231
|
-
frame_id:
|
|
232
|
-
bbox_id:
|
|
233
|
-
|
|
234
|
-
Returns:
|
|
235
|
-
bbox_id (int):
|
|
236
|
-
|
|
237
|
-
Raises:
|
|
238
|
-
ValueError: if bbox_id does not exist in the bbox list of specific frame.
|
|
239
|
-
"""
|
|
240
|
-
if not self.bbox_exists(frame_id, bbox_id):
|
|
241
|
-
raise ValueError("frame with id: {} does not contain bbox with id: {}".format(frame_id, bbox_id))
|
|
242
|
-
bboxes = {bbox.bbox_id: bbox for bbox in self.frames[frame_id].bboxes}
|
|
243
|
-
return bboxes.get(bbox_id)
|
|
244
|
-
|
|
245
|
-
def add_bbox_to_frame(self, frame_id: int, bbox_id: int, top: int, left: int, width: int, height: int) -> None:
|
|
246
|
-
"""
|
|
247
|
-
|
|
248
|
-
Args:
|
|
249
|
-
frame_id (int):
|
|
250
|
-
bbox_id (int):
|
|
251
|
-
top (int):
|
|
252
|
-
left (int):
|
|
253
|
-
width (int):
|
|
254
|
-
height (int):
|
|
255
|
-
|
|
256
|
-
Returns:
|
|
257
|
-
None
|
|
258
|
-
|
|
259
|
-
Raises:
|
|
260
|
-
ValueError: if bbox_id already exist in frame information with frame_id
|
|
261
|
-
ValueError: if frame_id does not exist in frames attribute
|
|
262
|
-
"""
|
|
263
|
-
if self.frame_exists(frame_id):
|
|
264
|
-
frame = self.frames[frame_id]
|
|
265
|
-
if not self.bbox_exists(frame_id, bbox_id):
|
|
266
|
-
frame.add_bbox(bbox_id, top, left, width, height)
|
|
267
|
-
else:
|
|
268
|
-
raise ValueError(
|
|
269
|
-
"frame with frame_id: {} already contains the bbox with id: {} ".format(frame_id, bbox_id))
|
|
270
|
-
else:
|
|
271
|
-
raise ValueError("frame with frame_id: {} does not exist".format(frame_id))
|
|
272
|
-
|
|
273
|
-
def add_label_to_bbox(self, frame_id: int, bbox_id: int, category: str, confidence: float):
|
|
274
|
-
"""
|
|
275
|
-
Args:
|
|
276
|
-
frame_id:
|
|
277
|
-
bbox_id:
|
|
278
|
-
category:
|
|
279
|
-
confidence: the confidence value returned from yolo detection
|
|
280
|
-
|
|
281
|
-
Returns:
|
|
282
|
-
None
|
|
283
|
-
|
|
284
|
-
Raises:
|
|
285
|
-
ValueError: if labels quota (top_k_labels) exceeds.
|
|
286
|
-
"""
|
|
287
|
-
bbox = self.find_bbox(frame_id, bbox_id)
|
|
288
|
-
if not bbox.labels_full(self.top_k_labels):
|
|
289
|
-
bbox.add_label(category, confidence)
|
|
290
|
-
else:
|
|
291
|
-
raise ValueError("labels in frame_id: {}, bbox_id: {} is fulled".format(frame_id, bbox_id))
|
|
292
|
-
|
|
293
|
-
def add_video_details(self, frame_width: int = None, frame_height: int = None, frame_rate: int = None,
|
|
294
|
-
video_name: str = None):
|
|
295
|
-
self.video_details['frame_width'] = frame_width
|
|
296
|
-
self.video_details['frame_height'] = frame_height
|
|
297
|
-
self.video_details['frame_rate'] = frame_rate
|
|
298
|
-
self.video_details['video_name'] = video_name
|
|
299
|
-
|
|
300
|
-
def output(self):
|
|
301
|
-
output = {'video_details': self.video_details}
|
|
302
|
-
result = list(self.frames.values())
|
|
303
|
-
output['frames'] = [item.dic() for item in result]
|
|
304
|
-
return output
|
|
305
|
-
|
|
306
|
-
def json_output(self, output_name):
|
|
307
|
-
"""
|
|
308
|
-
Args:
|
|
309
|
-
output_name:
|
|
310
|
-
|
|
311
|
-
Returns:
|
|
312
|
-
None
|
|
313
|
-
|
|
314
|
-
Notes:
|
|
315
|
-
It creates the json output with `output_name` name.
|
|
316
|
-
"""
|
|
317
|
-
if not output_name.endswith('.json'):
|
|
318
|
-
output_name += '.json'
|
|
319
|
-
with open(output_name, 'w') as file:
|
|
320
|
-
json.dump(self.output(), file)
|
|
321
|
-
file.close()
|
|
322
|
-
|
|
323
|
-
def set_start(self):
|
|
324
|
-
self.start_time = datetime.now()
|
|
325
|
-
|
|
326
|
-
def schedule_output_by_time(self, output_dir=JsonMeta.PATH_TO_SAVE, hours: int = 0, minutes: int = 0,
|
|
327
|
-
seconds: int = 60) -> None:
|
|
328
|
-
"""
|
|
329
|
-
Notes:
|
|
330
|
-
Creates folder and then periodically stores the jsons on that address.
|
|
331
|
-
|
|
332
|
-
Args:
|
|
333
|
-
output_dir (str): the directory where output files will be stored
|
|
334
|
-
hours (int):
|
|
335
|
-
minutes (int):
|
|
336
|
-
seconds (int):
|
|
337
|
-
|
|
338
|
-
Returns:
|
|
339
|
-
None
|
|
340
|
-
|
|
341
|
-
"""
|
|
342
|
-
end = datetime.now()
|
|
343
|
-
interval = 0
|
|
344
|
-
interval += abs(min([hours, JsonMeta.HOURS]) * 3600)
|
|
345
|
-
interval += abs(min([minutes, JsonMeta.MINUTES]) * 60)
|
|
346
|
-
interval += abs(min([seconds, JsonMeta.SECONDS]))
|
|
347
|
-
diff = (end - self.start_time).seconds
|
|
348
|
-
|
|
349
|
-
if diff > interval:
|
|
350
|
-
output_name = self.start_time.strftime('%Y-%m-%d %H-%M-%S') + '.json'
|
|
351
|
-
if not exists(output_dir):
|
|
352
|
-
makedirs(output_dir)
|
|
353
|
-
output = join(output_dir, output_name)
|
|
354
|
-
self.json_output(output_name=output)
|
|
355
|
-
self.frames = {}
|
|
356
|
-
self.start_time = datetime.now()
|
|
357
|
-
|
|
358
|
-
def schedule_output_by_frames(self, frames_quota, frame_counter, output_dir=JsonMeta.PATH_TO_SAVE):
|
|
359
|
-
"""
|
|
360
|
-
saves as the number of frames quota increases higher.
|
|
361
|
-
:param frames_quota:
|
|
362
|
-
:param frame_counter:
|
|
363
|
-
:param output_dir:
|
|
364
|
-
:return:
|
|
365
|
-
"""
|
|
366
|
-
pass
|
|
367
|
-
|
|
368
|
-
def flush(self, output_dir):
|
|
369
|
-
"""
|
|
370
|
-
Notes:
|
|
371
|
-
We use this function to output jsons whenever possible.
|
|
372
|
-
like the time that we exit the while loop of opencv.
|
|
373
|
-
|
|
374
|
-
Args:
|
|
375
|
-
output_dir:
|
|
376
|
-
|
|
377
|
-
Returns:
|
|
378
|
-
None
|
|
379
|
-
|
|
380
|
-
"""
|
|
381
|
-
filename = self.start_time.strftime('%Y-%m-%d %H-%M-%S') + '-remaining.json'
|
|
382
|
-
output = join(output_dir, filename)
|
|
383
|
-
self.json_output(output_name=output)
|
dnt/track/dsort/utils/log.py
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import logging
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
def get_logger(name='root'):
|
|
5
|
-
formatter = logging.Formatter(
|
|
6
|
-
# fmt='%(asctime)s [%(levelname)s]: %(filename)s(%(funcName)s:%(lineno)s) >> %(message)s')
|
|
7
|
-
fmt='%(asctime)s [%(levelname)s]: %(message)s', datefmt='%Y-%m-%d %H:%M:%S')
|
|
8
|
-
|
|
9
|
-
handler = logging.StreamHandler()
|
|
10
|
-
handler.setFormatter(formatter)
|
|
11
|
-
|
|
12
|
-
logger = logging.getLogger(name)
|
|
13
|
-
logger.setLevel(logging.INFO)
|
|
14
|
-
logger.addHandler(handler)
|
|
15
|
-
return logger
|
|
16
|
-
|
|
17
|
-
|
dnt/track/dsort/utils/parser.py
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import os
|
|
2
|
-
import yaml
|
|
3
|
-
from easydict import EasyDict as edict
|
|
4
|
-
|
|
5
|
-
class YamlParser(edict):
|
|
6
|
-
"""
|
|
7
|
-
This is yaml parser based on EasyDict.
|
|
8
|
-
"""
|
|
9
|
-
def __init__(self, cfg_dict=None, config_file=None):
|
|
10
|
-
if cfg_dict is None:
|
|
11
|
-
cfg_dict = {}
|
|
12
|
-
|
|
13
|
-
if config_file is not None:
|
|
14
|
-
assert(os.path.isfile(config_file))
|
|
15
|
-
with open(config_file, 'r') as fo:
|
|
16
|
-
cfg_dict.update(yaml.safe_load(fo.read()))
|
|
17
|
-
|
|
18
|
-
super(YamlParser, self).__init__(cfg_dict)
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
def merge_from_file(self, config_file):
|
|
22
|
-
with open(config_file, 'r') as fo:
|
|
23
|
-
self.update(yaml.safe_load(fo.read()))
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
def merge_from_dict(self, config_dict):
|
|
27
|
-
self.update(config_dict)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def get_config(config_file=None):
|
|
31
|
-
return YamlParser(config_file=config_file)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if __name__ == "__main__":
|
|
35
|
-
pass
|