Showing preview only (2,466K chars total). Download the full file or copy to clipboard to get everything.
Repository: Zhongdao/UniTrack
Branch: main
Commit: a83e782f5c56
Files: 379
Total size: 2.3 MB
Directory structure:
gitextract_942_umbq/
├── .gitignore
├── LICENSE
├── README.md
├── config/
│ ├── crw_resnet18_s3.yaml
│ ├── crw_resnet18_s3_womotion.yaml
│ ├── imagenet_resnet18_s3.yaml
│ └── imagenet_resnet18_s3_womotion.yaml
├── core/
│ ├── association/
│ │ ├── __init__.py
│ │ └── matching.py
│ ├── motion/
│ │ └── kalman_filter.py
│ └── propagation/
│ ├── __init__.py
│ ├── propagate_box.py
│ ├── propagate_mask.py
│ └── propagate_pose.py
├── data/
│ ├── jhmdb.py
│ ├── kinetics.py
│ ├── video.py
│ └── vos.py
├── demo/
│ ├── mot_demo.py
│ └── sot_demo.py
├── detector/
│ └── YOLOX/
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── datasets/
│ │ └── README.md
│ ├── demo/
│ │ ├── ONNXRuntime/
│ │ │ ├── README.md
│ │ │ └── onnx_inference.py
│ │ ├── OpenVINO/
│ │ │ ├── README.md
│ │ │ ├── cpp/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── README.md
│ │ │ │ └── yolox_openvino.cpp
│ │ │ └── python/
│ │ │ ├── README.md
│ │ │ └── openvino_inference.py
│ │ ├── TensorRT/
│ │ │ ├── cpp/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── README.md
│ │ │ │ ├── logging.h
│ │ │ │ └── yolox.cpp
│ │ │ └── python/
│ │ │ └── README.md
│ │ └── ncnn/
│ │ ├── android/
│ │ │ ├── README.md
│ │ │ ├── app/
│ │ │ │ ├── build.gradle
│ │ │ │ └── src/
│ │ │ │ └── main/
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── assets/
│ │ │ │ │ └── yolox.param
│ │ │ │ ├── java/
│ │ │ │ │ └── com/
│ │ │ │ │ └── megvii/
│ │ │ │ │ └── yoloXncnn/
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ ├── YOLOXncnn.java
│ │ │ │ │ └── yoloXncnn.java
│ │ │ │ ├── jni/
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ └── yoloXncnn_jni.cpp
│ │ │ │ └── res/
│ │ │ │ ├── layout/
│ │ │ │ │ └── main.xml
│ │ │ │ └── values/
│ │ │ │ └── strings.xml
│ │ │ ├── build.gradle
│ │ │ ├── gradle/
│ │ │ │ └── wrapper/
│ │ │ │ ├── gradle-wrapper.jar
│ │ │ │ └── gradle-wrapper.properties
│ │ │ ├── gradlew
│ │ │ ├── gradlew.bat
│ │ │ └── settings.gradle
│ │ └── cpp/
│ │ ├── README.md
│ │ └── yolox.cpp
│ ├── demo.py
│ ├── docs/
│ │ └── train_custom_data.md
│ ├── exps/
│ │ ├── default/
│ │ │ ├── nano.py
│ │ │ ├── yolov3.py
│ │ │ ├── yolox_l.py
│ │ │ ├── yolox_m.py
│ │ │ ├── yolox_s.py
│ │ │ ├── yolox_tiny.py
│ │ │ └── yolox_x.py
│ │ └── example/
│ │ └── yolox_voc/
│ │ └── yolox_voc_s.py
│ ├── requirements.txt
│ ├── setup.cfg
│ ├── setup.py
│ ├── tools/
│ │ ├── __init__.py
│ │ ├── demo.py
│ │ ├── eval.py
│ │ ├── export_onnx.py
│ │ ├── train.py
│ │ └── trt.py
│ └── yolox/
│ ├── __init__.py
│ ├── core/
│ │ ├── __init__.py
│ │ ├── launch.py
│ │ └── trainer.py
│ ├── data/
│ │ ├── __init__.py
│ │ ├── data_augment.py
│ │ ├── data_prefetcher.py
│ │ ├── dataloading.py
│ │ ├── datasets/
│ │ │ ├── __init__.py
│ │ │ ├── coco.py
│ │ │ ├── coco_classes.py
│ │ │ ├── datasets_wrapper.py
│ │ │ ├── mosaicdetection.py
│ │ │ ├── voc.py
│ │ │ └── voc_classes.py
│ │ └── samplers.py
│ ├── evaluators/
│ │ ├── __init__.py
│ │ ├── coco_evaluator.py
│ │ ├── voc_eval.py
│ │ └── voc_evaluator.py
│ ├── exp/
│ │ ├── __init__.py
│ │ ├── base_exp.py
│ │ ├── build.py
│ │ └── yolox_base.py
│ ├── layers/
│ │ ├── __init__.py
│ │ ├── csrc/
│ │ │ ├── cocoeval/
│ │ │ │ ├── cocoeval.cpp
│ │ │ │ └── cocoeval.h
│ │ │ └── vision.cpp
│ │ └── fast_coco_eval_api.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── darknet.py
│ │ ├── losses.py
│ │ ├── network_blocks.py
│ │ ├── yolo_fpn.py
│ │ ├── yolo_head.py
│ │ ├── yolo_pafpn.py
│ │ └── yolox.py
│ └── utils/
│ ├── __init__.py
│ ├── allreduce_norm.py
│ ├── boxes.py
│ ├── checkpoint.py
│ ├── demo_utils.py
│ ├── dist.py
│ ├── ema.py
│ ├── logger.py
│ ├── lr_scheduler.py
│ ├── metric.py
│ ├── model_utils.py
│ ├── setup_env.py
│ └── visualize.py
├── docs/
│ ├── DATA.md
│ ├── INSTALL.md
│ ├── MODELZOO.md
│ ├── RESULTS.md
│ └── RUN.md
├── eval/
│ ├── convert_davis.py
│ ├── davis_dummy.txt
│ ├── eval_mot.py
│ ├── eval_pck.py
│ ├── mots/
│ │ ├── Evaluator.py
│ │ ├── LICENSE
│ │ ├── MOTSVisualization.py
│ │ ├── MOTS_metrics.py
│ │ ├── Metrics.py
│ │ ├── README.md
│ │ ├── Visualize.py
│ │ ├── __init__.py
│ │ ├── evalMOTS.py
│ │ ├── mots_common/
│ │ │ ├── images_to_txt.py
│ │ │ └── io.py
│ │ └── requirements.txt
│ ├── palette.py
│ ├── poseval/
│ │ ├── .gitignore
│ │ ├── .gitmodules
│ │ ├── .pylintrc
│ │ ├── README.md
│ │ ├── evaluate.py
│ │ ├── license.txt
│ │ ├── matlab/
│ │ │ ├── external/
│ │ │ │ └── jsonlab/
│ │ │ │ ├── AUTHORS.txt
│ │ │ │ ├── ChangeLog.txt
│ │ │ │ ├── LICENSE_BSD.txt
│ │ │ │ ├── README.txt
│ │ │ │ ├── examples/
│ │ │ │ │ ├── demo_jsonlab_basic.m
│ │ │ │ │ ├── demo_ubjson_basic.m
│ │ │ │ │ ├── example1.json
│ │ │ │ │ ├── example2.json
│ │ │ │ │ ├── example3.json
│ │ │ │ │ ├── example4.json
│ │ │ │ │ ├── jsonlab_basictest.matlab
│ │ │ │ │ ├── jsonlab_selftest.m
│ │ │ │ │ ├── jsonlab_selftest.matlab
│ │ │ │ │ └── jsonlab_speedtest.m
│ │ │ │ ├── jsonopt.m
│ │ │ │ ├── loadjson.m
│ │ │ │ ├── loadubjson.m
│ │ │ │ ├── mergestruct.m
│ │ │ │ ├── savejson.m
│ │ │ │ ├── saveubjson.m
│ │ │ │ ├── struct2jdata.m
│ │ │ │ └── varargin2struct.m
│ │ │ ├── mat2json.m
│ │ │ └── startup.m
│ │ └── poseval/
│ │ ├── __init__.py
│ │ ├── convert.py
│ │ ├── eval_helpers.py
│ │ ├── evaluateAP.py
│ │ ├── evaluatePCKh.py
│ │ ├── evaluateTracking.py
│ │ └── posetrack18_id2fname.py
│ └── trackeval/
│ ├── __init__.py
│ ├── _timing.py
│ ├── datasets/
│ │ ├── __init__.py
│ │ ├── _base_dataset.py
│ │ ├── bdd100k.py
│ │ ├── davis.py
│ │ ├── kitti_2d_box.py
│ │ ├── kitti_mots.py
│ │ ├── mot_challenge_2d_box.py
│ │ ├── mots_challenge.py
│ │ ├── tao.py
│ │ └── youtube_vis.py
│ ├── eval.py
│ ├── metrics/
│ │ ├── __init__.py
│ │ ├── _base_metric.py
│ │ ├── clear.py
│ │ ├── count.py
│ │ ├── hota.py
│ │ ├── identity.py
│ │ ├── j_and_f.py
│ │ ├── track_map.py
│ │ └── vace.py
│ ├── plotting.py
│ └── utils.py
├── eval.sh
├── model/
│ ├── __init__.py
│ ├── functional.py
│ ├── hrnet.py
│ ├── model.py
│ ├── random_feat_generator.py
│ └── resnet.py
├── requirements.txt
├── setup.py
├── test/
│ ├── test_mot.py
│ ├── test_mots.py
│ ├── test_poseprop.py
│ ├── test_posetrack.py
│ ├── test_sot_cfnet.py
│ ├── test_sot_siamfc.py
│ ├── test_vis.py
│ └── test_vos.py
├── tools/
│ ├── gen_mot16_fairmot.py
│ ├── gen_mot16_gt.py
│ ├── gen_mot16_label17.py
│ ├── gen_mot19_det.py
│ ├── gen_mots_costa.py
│ └── gen_mots_gt.py
├── tracker/
│ ├── mot/
│ │ ├── basetrack.py
│ │ ├── box.py
│ │ ├── mask.py
│ │ ├── multitracker.py
│ │ └── pose.py
│ └── sot/
│ └── lib/
│ ├── core/
│ │ ├── config.py
│ │ ├── config_ocean.py
│ │ ├── config_oceanplus.py
│ │ ├── config_siamdw.py
│ │ ├── eval_davis.py
│ │ ├── eval_got10k.py
│ │ ├── eval_lasot.py
│ │ ├── eval_otb.py
│ │ ├── eval_visdrone.py
│ │ ├── extract_tune_logs.py
│ │ └── function.py
│ ├── dataset/
│ │ ├── crop/
│ │ │ ├── DAVIS/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── RGBT210/
│ │ │ │ ├── RGBT210_genjson.py
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── RGBT234/
│ │ │ │ ├── RGBT234_genjson.py
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── coco/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── det/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── got10k/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ ├── parser_got10k.py
│ │ │ │ └── readme.md
│ │ │ ├── lasot/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ ├── parser_lasot.py
│ │ │ │ └── readme.md
│ │ │ ├── vid/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ ├── parse_vid.py
│ │ │ │ └── readme.md
│ │ │ └── visdrone/
│ │ │ ├── gen_json.py
│ │ │ ├── par_crop.py
│ │ │ ├── parser_visdrone.py
│ │ │ └── readme.md
│ │ ├── ocean.py
│ │ └── siamfc.py
│ ├── eval_toolkit/
│ │ ├── bin/
│ │ │ ├── _init_paths.py
│ │ │ └── eval.py
│ │ ├── pysot/
│ │ │ ├── __init__.py
│ │ │ ├── datasets/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── dataset.py
│ │ │ │ ├── got10k.py
│ │ │ │ ├── lasot.py
│ │ │ │ ├── nfs.py
│ │ │ │ ├── otb.py
│ │ │ │ ├── trackingnet.py
│ │ │ │ ├── uav.py
│ │ │ │ ├── video.py
│ │ │ │ └── vot.py
│ │ │ ├── evaluation/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── ar_benchmark.py
│ │ │ │ ├── eao_benchmark.py
│ │ │ │ ├── f1_benchmark.py
│ │ │ │ └── ope_benchmark.py
│ │ │ ├── utils/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── c_region.pxd
│ │ │ │ ├── misc.py
│ │ │ │ ├── region.c
│ │ │ │ ├── region.pyx
│ │ │ │ ├── setup.py
│ │ │ │ ├── src/
│ │ │ │ │ ├── buffer.h
│ │ │ │ │ ├── region.c
│ │ │ │ │ └── region.h
│ │ │ │ └── statistics.py
│ │ │ └── visualization/
│ │ │ ├── __init__.py
│ │ │ ├── draw_eao.py
│ │ │ ├── draw_f1.py
│ │ │ ├── draw_success_precision.py
│ │ │ └── draw_utils.py
│ │ └── requirements.txt
│ ├── models/
│ │ ├── __init__.py
│ │ ├── backbones.py
│ │ ├── cfnet.py
│ │ ├── connect.py
│ │ ├── modules.py
│ │ ├── online/
│ │ │ ├── __init__.py
│ │ │ ├── backbone/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── resnet.py
│ │ │ │ └── resnet18_vggm.py
│ │ │ ├── bbreg/
│ │ │ │ ├── __init__.py
│ │ │ │ └── iou_net.py
│ │ │ ├── classifier/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── features.py
│ │ │ │ ├── initializer.py
│ │ │ │ ├── linear_filter.py
│ │ │ │ └── optimizer.py
│ │ │ └── layers/
│ │ │ ├── __init__.py
│ │ │ ├── activation.py
│ │ │ ├── blocks.py
│ │ │ ├── distance.py
│ │ │ ├── filter.py
│ │ │ ├── normalization.py
│ │ │ └── transform.py
│ │ └── siamfc.py
│ ├── online/
│ │ ├── __init__.py
│ │ ├── augmentation.py
│ │ ├── base_actor.py
│ │ ├── base_trainer.py
│ │ ├── complex.py
│ │ ├── dcf.py
│ │ ├── extractor.py
│ │ ├── fourier.py
│ │ ├── loading.py
│ │ ├── ltr_trainer.py
│ │ ├── model_constructor.py
│ │ ├── operation.py
│ │ ├── optim.py
│ │ ├── optimization.py
│ │ ├── preprocessing.py
│ │ ├── tensordict.py
│ │ ├── tensorlist.py
│ │ └── tracking.py
│ ├── tracker/
│ │ ├── ocean.py
│ │ ├── oceanplus.py
│ │ ├── online.py
│ │ └── siamfc.py
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── cutout.py
│ │ ├── extract_tpejson_fc.py
│ │ ├── extract_tpejson_ocean.py
│ │ ├── extract_tpelog.py
│ │ ├── extract_tpelog_fc.py
│ │ ├── utils.py
│ │ └── watch_tpe.sh
│ └── version.py
└── utils/
├── __init__.py
├── box.py
├── io.py
├── log.py
├── mask.py
├── meter.py
├── palette.py
└── visualize.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
docs/test_video.mp4
test/test_tao.py
config/tao*
tracker/mot/tao.py
eval/error_log.txt
config/got10k*
config/lasot*
config/tc128*
config/tlp*
config/trackingnet*
config/vfs*
config/ssib*
weights/
results/
out/
vis/
*.ipynb
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
*.py,cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
db.sqlite3-journal
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
__pypackages__/
# Celery stuff
celerybeat-schedule
celerybeat.pid
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
================================================
FILE: LICENSE
================================================
MIT License
Copyright (c) 2021 ZhongdaoWang
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
================================================
FILE: README.md
================================================
<p align="center"> <img src="docs/logo.png" width="500"/>
--------------------------------------------------------------------------------
**[NeurIPS 2021] Do different tracking tasks require different appearance model?**
**[[ArXiv](https://arxiv.org/abs/2107.02156)]** **[[Project Page](https://zhongdao.github.io/UniTrack)]**
UniTrack is a simple and Unified framework for addressing multiple tracking tasks.
Being a fundamental problem in computer vision, tracking has been fragmented into a multitude of different experimental setups. As a consequence, the literature has fragmented too, and now the novel approaches proposed by the community are usually specialized to fit only one specific setup. To understand to what extent this specialization is actually necessary, we present UniTrack, a solution to address multiple different tracking tasks within the same framework. All tasks share the same [appearance model](#appearance-model). UniTrack
- Does **NOT** need training on a specific tracking task.
- Shows [competitive performance](docs/RESULTS.md) on six out of seven tracking tasks considered.
- Can be easily adapted to even [more tasks](##Demo).
- Can be used as an evaluation platform to [test pre-trained self-supervised models](docs/MODELZOO.md).
## Demo
**Multi-Object Tracking demo for 80 COCO classes ([YOLOX](https://github.com/Megvii-BaseDetection/YOLOX) + UniTrack)**
<img src="docs/unitrack_yolox.gif" width="480"/>
In this demo we run the YOLOX detector and perform MOT for the 80 COCO classes. Try the demo by:
```python
python demo/mot_demo.py --classes cls1 cls2 ... clsN
```
where cls1 to clsN represent the indices of classes you would like to detect and track. See [here](https://gist.github.com/AruniRC/7b3dadd004da04c80198557db5da4bda) for the index list. By default all 80 classes are detected and tracked.
**Single-Object Tracking demo for custom videos**
```python
python demo/sot_demo.py --config ./config/imagenet_resnet18_s3.yaml --input /path/to/your/video
```
In this demo, you are asked to annotate the target to be tracked, by drawing a rectangle in the first frame of the video. Then the algorithm tracks the target in following timesteps without object detection.
## Tasks & Framework

### Tasks
We classify existing tracking tasks along four axes: (1) Single or multiple targets; (2) Users specify targets or automatic detectors specify targets; (3) Observation formats (bounding box/mask/pose); (2) Class-agnostic or class-specific (i.e. human/vehicles). We mainly experiment on 5 tasks: **SOT, VOS, MOT, MOTS, and PoseTrack**. Task setups are summarized in the above figure.
### Appearance model
An appearance model is the only learnable component in UniTrack. It should provide universal visual representation, and is usually pre-trained on large-scale dataset in supervised or unsupervised manners. Typical examples include ImageNet pre-trained ResNets (supervised), and recent self-supervised models such as MoCo and SimCLR (unsupervised).
### Propagation and Association
*Propagation* and *Association* are the two core primitives used in UniTrack to address a wide variety of tracking tasks (currently 7, but more can be added), Both use the features extracted by the pre-trained appearance model. For propagation, we adopt exiting methods such as [cross correlation](https://www.robots.ox.ac.uk/~luca/siamese-fc.html), [DCF](https://openaccess.thecvf.com/content_cvpr_2017/html/Valmadre_End-To-End_Representation_Learning_CVPR_2017_paper.html), and [mask propation](https://github.com/ajabri/videowalk). For association we employ a simple algorithm as in [JDE](https://github.com/Zhongdao/Towards-Realtime-MOT) and develop a novel reconstruction-based similairty metric that allows to compare objects across shapes and sizes.
## Getting started
1. Installation: Please check out [docs/INSTALL.md](docs/INSTALL.md)
2. Data preparation: Please check out [docs/DATA.md](docs/DATA.md)
3. Appearance model preparation: Please check out [docs/MODELZOO.md](docs/MODELZOO.md)
4. Run evaluation on all datasets: Please check out [docs/RUN.md](docs/RUN.md)
## Results
Below we show results of UniTrack with a simple **ImageNet Pre-trained ResNet-18** as the appearance model. More results can be found in [RESULTS.md](docs/RESULTS.md).
**Single Object Tracking (SOT) on OTB-2015**
<img src="docs/sot1.gif" width="320"/> <img src="docs/sot2.gif" width="320"/>
**Video Object Segmentation (VOS) on DAVIS-2017 *val* split**
<img src="docs/vos1.gif" width="320"/> <img src="docs/vos2.gif" width="320"/>
**Multiple Object Tracking (MOT) on MOT-16 [*test* set *private detector* track](https://motchallenge.net/method/MOT=3856&chl=5)** (Detections from FairMOT)
<img src="docs/MOT1.gif" width="320"/> <img src="docs/MOT2.gif" width="320"/>
**Multiple Object Tracking and Segmentation (MOTS) on MOTS challenge [*test* set](https://motchallenge.net/method/MOTS=109&chl=17)** (Detections from COSTA_st)
<img src="docs/MOTS1.gif" width="320"/> <img src="docs/MOTS2.gif" width="320"/>
**Pose Tracking on PoseTrack-2018 *val* split** (Detections from LightTrack)
<img src="docs/posetrack1.gif" width="320"/> <img src="docs/posetrack2.gif" width="320"/>
## Acknowledgement
A part of code is borrowed from
[VideoWalk](https://github.com/ajabri/videowalk) by Allan A. Jabri
[SOT code](https://github.com/JudasDie/SOTS) by Zhipeng Zhang
## Citation
```bibtex
@article{wang2021different,
author = {Wang, Zhongdao and Zhao, Hengshuang and Li, Ya-Li and Wang, Shengjin and Torr, Philip and Bertinetto, Luca},
title = {Do different tracking tasks require different appearance models?},
journal = {Thirty-Fifth Conference on Neural Infromation Processing Systems},
year = {2021},
}
```
================================================
FILE: config/crw_resnet18_s3.yaml
================================================
common:
exp_name: crw_resnet18_s3
# Model related
model_type: crw
remove_layers: ['layer4']
im_mean: [0.4914, 0.4822, 0.4465]
im_std: [0.2023, 0.1994, 0.2010]
nopadding: False
head_depth: -1
resume: 'weights/crw.pth'
# Misc
down_factor: 8
infer2D: True
workers: 4
gpu_id: 0
device: cuda
sot:
dataset: 'OTB2015'
dataroot: '/home/wangzd/datasets/GOT/OTB100/'
epoch_test: False
vos:
davisroot: '/home/wangzd/datasets/uvc/DAVIS/'
split: 'val'
temperature: 0.05
topk: 10
radius: 12
videoLen: 5
cropSize: -1
head_depth: -1
no_l2: False
long_mem: [0]
infer2D: False
norm_mask: False
mot:
obid: 'FairMOT'
mot_root: '/home/wangzd/datasets/MOT/MOT16'
feat_size: [4,10]
save_videos: True
save_images: False
test_mot16: False
track_buffer: 30
min_box_area: 200
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
dup_iou_thres: 0.15
confirm_iou_thres: 0.7
img_size: [1088, 608]
prop_flag: False
use_kalman: True
asso_with_motion: True
motion_lambda: 0.98
motion_gated: True
mots:
obid: 'COSTA'
mots_root: '/home/wangzd/datasets/GOT/MOTS'
save_videos: False
save_images: True
test: False
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
prop_flag: False
max_mask_area: 200
dup_iou_thres: 0.15
confirm_iou_thres: 0.7
first_stage_thres: 0.7
feat_size: [4,10]
use_kalman: True
asso_with_motion: True
motion_lambda: 0.98
motion_gated: False
posetrack:
obid: 'lighttrack_MSRA152'
data_root: '/home/wangzd/datasets/GOT/Posetrack2018'
split: 'val'
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
frame_rate: 6
save_videos: False
save_images: True
prop_flag: False
feat_size: [4,10]
max_mask_area: 400
dup_iou_thres: 0.2
confirm_iou_thres: 0.6
first_stage_thres: 0.7
use_kalman: True
asso_with_motion: True
motion_lambda: 0.9999
motion_gated: False
only_position: True
================================================
FILE: config/crw_resnet18_s3_womotion.yaml
================================================
common:
exp_name: crw_resnet18_s3_womotion
# Model related
model_type: crw
remove_layers: ['layer4']
im_mean: [0.4914, 0.4822, 0.4465]
im_std: [0.2023, 0.1994, 0.2010]
nopadding: False
head_depth: -1
resume: 'weights/crw.pth'
# Misc
down_factor: 8
infer2D: True
workers: 4
gpu_id: 0
device: cuda
sot:
dataset: 'OTB2015'
dataroot: '/home/wangzd/datasets/GOT/OTB100/'
epoch_test: False
vos:
davisroot: '/home/wangzd/datasets/uvc/DAVIS/'
split: 'val'
temperature: 0.05
topk: 10
radius: 12
videoLen: 5
cropSize: -1
head_depth: -1
no_l2: False
long_mem: [0]
infer2D: False
norm_mask: False
mot:
obid: 'FairMOT'
mot_root: '/home/wangzd/datasets/MOT/MOT16'
feat_size: [4,10]
save_videos: True
save_images: False
test_mot16: False
track_buffer: 30
min_box_area: 200
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
dup_iou_thres: 0.15
confirm_iou_thres: 0.7
img_size: [1088, 608]
prop_flag: False
use_kalman: True
asso_with_motion: False
motion_lambda: 1
motion_gated: False
mots:
obid: 'COSTA'
mots_root: '/home/wangzd/datasets/GOT/MOTS'
save_videos: False
save_images: True
test: False
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
prop_flag: False
max_mask_area: 200
dup_iou_thres: 0.15
confirm_iou_thres: 0.7
first_stage_thres: 0.7
feat_size: [4,10]
use_kalman: True
asso_with_motion: False
motion_lambda: 1
motion_gated: False
posetrack:
obid: 'lighttrack_MSRA152'
data_root: '/home/wangzd/datasets/GOT/Posetrack2018'
split: 'val'
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
frame_rate: 6
save_videos: False
save_images: True
prop_flag: False
feat_size: [4,10]
max_mask_area: 400
dup_iou_thres: 0.2
confirm_iou_thres: 0.6
first_stage_thres: 0.7
use_kalman: True
asso_with_motion: False
motion_lambda: 1
motion_gated: False
only_position: True
================================================
FILE: config/imagenet_resnet18_s3.yaml
================================================
common:
exp_name: imagenet_resnet18_s3
# Model related
model_type: imagenet18
remove_layers: ['layer4']
im_mean: [0.485, 0.456, 0.406]
im_std: [0.229, 0.224, 0.225]
nopadding: False
resume: None
# Misc
down_factor: 8
infer2D: True
workers: 4
gpu_id: 0
device: cuda
sot:
dataset: 'OTB2015'
dataroot: '/home/wangzd/datasets/GOT/OTB100/'
epoch_test: False
vos:
davisroot: '/home/wangzd/datasets/uvc/DAVIS/'
split: 'val'
temperature: 0.05
topk: 10
radius: 12
videoLen: 5
cropSize: -1
head_depth: -1
no_l2: False
long_mem: [0]
infer2D: False
norm_mask: False
mot:
obid: 'FairMOT'
mot_root: '/home/wangzd/datasets/MOT/MOT16'
feat_size: [4,10]
save_videos: True
save_images: False
test_mot16: False
track_buffer: 30
min_box_area: 200
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
dup_iou_thres: 0.15
confirm_iou_thres: 0.7
img_size: [1088, 608]
prop_flag: False
use_kalman: True
asso_with_motion: True
motion_lambda: 0.98
motion_gated: True
mots:
obid: 'COSTA'
mots_root: '/home/wangzd/datasets/GOT/MOTS'
save_videos: False
save_images: True
test: False
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
prop_flag: False
max_mask_area: 200
dup_iou_thres: 0.15
confirm_iou_thres: 0.7
first_stage_thres: 0.7
feat_size: [4,10]
use_kalman: True
asso_with_motion: True
motion_lambda: 0.98
motion_gated: False
posetrack:
obid: 'lighttrack_MSRA152'
data_root: '/home/wangzd/datasets/GOT/Posetrack2018'
split: 'val'
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
frame_rate: 6
save_videos: False
save_images: True
prop_flag: False
feat_size: [4,10]
max_mask_area: 400
dup_iou_thres: 0.2
confirm_iou_thres: 0.6
first_stage_thres: 0.7
use_kalman: True
asso_with_motion: True
motion_lambda: 0.9999
motion_gated: False
only_position: True
================================================
FILE: config/imagenet_resnet18_s3_womotion.yaml
================================================
common:
exp_name: imagenet_resnet18_s3_womotion
# Model related
model_type: imagenet18
remove_layers: ['layer4']
im_mean: [0.485, 0.456, 0.406]
im_std: [0.229, 0.224, 0.225]
nopadding: False
resume: None
# Misc
down_factor: 8
infer2D: True
workers: 4
gpu_id: 0
device: cuda
sot:
dataset: 'OTB2015'
dataroot: '/home/wangzd/datasets/GOT/OTB100/'
epoch_test: False
vos:
davisroot: '/home/wangzd/datasets/uvc/DAVIS/'
split: 'val'
temperature: 0.05
topk: 10
radius: 12
videoLen: 5
cropSize: -1
head_depth: -1
no_l2: False
long_mem: [0]
infer2D: False
norm_mask: False
mot:
obid: 'FairMOT'
mot_root: '/home/wangzd/datasets/MOT/MOT16'
feat_size: [4,10]
save_videos: True
save_images: False
test_mot16: False
track_buffer: 30
min_box_area: 200
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
dup_iou_thres: 0.15
confirm_iou_thres: 0.7
img_size: [1088, 608]
prop_flag: False
use_kalman: True
asso_with_motion: False
motion_lambda: 1
motion_gated: False
mots:
obid: 'COSTA'
mots_root: '/home/wangzd/datasets/GOT/MOTS'
save_videos: False
save_images: True
test: False
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
prop_flag: False
max_mask_area: 200
dup_iou_thres: 0.15
confirm_iou_thres: 0.7
first_stage_thres: 0.7
feat_size: [4,10]
use_kalman: True
asso_with_motion: False
motion_lambda: 1
motion_gated: False
posetrack:
obid: 'lighttrack_MSRA152'
data_root: '/home/wangzd/datasets/GOT/Posetrack2018'
split: 'val'
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
frame_rate: 6
save_videos: False
save_images: True
prop_flag: False
feat_size: [4,10]
max_mask_area: 400
dup_iou_thres: 0.2
confirm_iou_thres: 0.6
first_stage_thres: 0.7
use_kalman: True
asso_with_motion: False
motion_lambda: 1
motion_gated: False
only_position: True
vis:
obid: 'MaskTrackRCNN'
data_root: '/home/wangzd/datasets/GOT/YoutubeVIS/'
split: 'val'
track_buffer: 30
nms_thres: 0.4
conf_thres: 0.5
iou_thres: 0.5
frame_rate: 6
save_videos: False
save_images: True
prop_flag: False
feat_size: [12,12]
max_mask_area: 1000
dup_iou_thres: 0.2
confirm_iou_thres: 0.6
first_stage_thres: 0.9
use_kalman: True
asso_with_motion: False
motion_lambda: 1
motion_gated: False
================================================
FILE: core/association/__init__.py
================================================
================================================
FILE: core/association/matching.py
================================================
import pdb
import cv2
import torch
import torch.nn.functional as F
import numpy as np
import scipy
from scipy.spatial.distance import cdist
import lap
from cython_bbox import bbox_overlaps as bbox_ious
from core.motion import kalman_filter
import time
def merge_matches(m1, m2, shape):
O,P,Q = shape
m1 = np.asarray(m1)
m2 = np.asarray(m2)
M1 = scipy.sparse.coo_matrix((np.ones(len(m1)), (m1[:, 0], m1[:, 1])), shape=(O, P))
M2 = scipy.sparse.coo_matrix((np.ones(len(m2)), (m2[:, 0], m2[:, 1])), shape=(P, Q))
mask = M1*M2
match = mask.nonzero()
match = list(zip(match[0], match[1]))
unmatched_O = tuple(set(range(O)) - set([i for i, j in match]))
unmatched_Q = tuple(set(range(Q)) - set([j for i, j in match]))
return match, unmatched_O, unmatched_Q
def linear_assignment(cost_matrix, thresh):
if cost_matrix.size == 0:
return np.empty((0, 2), dtype=int), tuple(range(cost_matrix.shape[0])), tuple(range(cost_matrix.shape[1]))
matches, unmatched_a, unmatched_b = [], [], []
cost, x, y = lap.lapjv(cost_matrix, extend_cost=True, cost_limit=thresh)
for ix, mx in enumerate(x):
if mx >= 0:
matches.append([ix, mx])
unmatched_a = np.where(x < 0)[0]
unmatched_b = np.where(y < 0)[0]
matches = np.asarray(matches)
return matches, unmatched_a, unmatched_b
def ious(atlbrs, btlbrs):
"""
Compute cost based on IoU
:type atlbrs: list[tlbr] | np.ndarray
:type atlbrs: list[tlbr] | np.ndarray
:rtype ious np.ndarray
"""
ious = np.zeros((len(atlbrs), len(btlbrs)), dtype=np.float)
if ious.size == 0:
return ious
ious = bbox_ious(
np.ascontiguousarray(atlbrs, dtype=np.float),
np.ascontiguousarray(btlbrs, dtype=np.float)
)
return ious
def iou_distance(atracks, btracks):
"""
Compute cost based on IoU
:type atracks: list[STrack]
:type btracks: list[STrack]
:rtype cost_matrix np.ndarray
"""
if (len(atracks)>0 and isinstance(atracks[0], np.ndarray)) or (len(btracks) > 0 and isinstance(btracks[0], np.ndarray)):
atlbrs = atracks
btlbrs = btracks
else:
atlbrs = [track.tlbr for track in atracks]
btlbrs = [track.tlbr for track in btracks]
_ious = ious(atlbrs, btlbrs)
cost_matrix = 1 - _ious
return cost_matrix
def embedding_distance(tracks, detections, metric='cosine'):
"""
:param tracks: list[STrack]
:param detections: list[BaseTrack]
:param metric:
:return: cost_matrix np.ndarray
"""
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
if cost_matrix.size == 0:
return cost_matrix
det_features = np.asarray([track.curr_feat for track in detections], dtype=np.float)
track_features = np.asarray([track.smooth_feat for track in tracks], dtype=np.float)
cost_matrix = np.maximum(0.0, cdist(track_features, det_features)) # Nomalized features
return cost_matrix
def fuse_motion(kf, cost_matrix, tracks, detections, only_position=False, lambda_=0.98, gate=True):
if cost_matrix.size == 0:
return cost_matrix
gating_dim = 2 if only_position else 4
gating_threshold = kalman_filter.chi2inv95[gating_dim]
measurements = np.asarray([det.to_xyah() for det in detections])
for row, track in enumerate(tracks):
gating_distance = kf.gating_distance(
track.mean, track.covariance, measurements, only_position, metric='maha')
if gate:
cost_matrix[row, gating_distance > gating_threshold] = np.inf
cost_matrix[row] = lambda_ * cost_matrix[row] + (1-lambda_)* gating_distance
return cost_matrix
def center_emb_distance(tracks, detections, metric='cosine'):
"""
:param tracks: list[STrack]
:param detections: list[BaseTrack]
:param metric:
:return: cost_matrix np.ndarray
"""
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
if cost_matrix.size == 0:
return cost_matrix
det_features = torch.stack([track.curr_feat.squeeze() for track in detections])
track_features = torch.stack([track.smooth_feat.squeeze() for track in tracks])
normed_det = F.normalize(det_features)
normed_track = F.normalize(track_features)
cost_matrix = torch.mm(normed_track, normed_det.T)
cost_matrix = 1 - cost_matrix.detach().cpu().numpy()
return cost_matrix
def recons_distance(tracks, detections, tmp=100):
"""
:param tracks: list[STrack]
:param detections: list[BaseTrack]
:param metric:
:return: cost_matrix np.ndarray
"""
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
if cost_matrix.size == 0:
return cost_matrix
det_features_ = torch.stack([track.curr_feat.squeeze() for track in detections])
track_features_ = torch.stack([track.smooth_feat for track in tracks])
det_features = F.normalize(det_features_, dim=1)
track_features = F.normalize(track_features_, dim=1)
ndet, ndim, nw, nh = det_features.shape
ntrk, _, _, _ = track_features.shape
fdet = det_features.permute(0,2,3,1).reshape(-1, ndim).cuda() # ndet*nw*nh, ndim
ftrk = track_features.permute(0,2,3,1).reshape(-1, ndim).cuda() # ntrk*nw*nh, ndim
aff = torch.mm(ftrk, fdet.transpose(0,1)) # ntrk*nw*nh, ndet*nw*nh
aff_td = F.softmax(tmp*aff, dim=1)
aff_dt = F.softmax(tmp*aff, dim=0).transpose(0,1)
recons_ftrk = torch.einsum('tds,dsm->tdm', aff_td.view(ntrk*nw*nh, ndet, nw*nh),
fdet.view(ndet, nw*nh, ndim)) # ntrk*nw*nh, ndet, ndim
recons_fdet = torch.einsum('dts,tsm->dtm', aff_dt.view(ndet*nw*nh, ntrk, nw*nh),
ftrk.view(ntrk, nw*nh, ndim)) # ndet*nw*nh, ntrk, ndim
res_ftrk = (recons_ftrk.permute(0,2,1) - ftrk.unsqueeze(-1)).view(ntrk, nw*nh*ndim, ndet)
res_fdet = (recons_fdet.permute(0,2,1) - fdet.unsqueeze(-1)).view(ndet, nw*nh*ndim, ntrk)
cost_matrix = (torch.abs(res_ftrk).mean(1) + torch.abs(res_fdet).mean(1).transpose(0,1)) * 0.5
cost_matrix = cost_matrix / cost_matrix.max(1)[0].unsqueeze(-1)
#pdb.set_trace()
cost_matrix = cost_matrix.cpu().numpy()
return cost_matrix
def get_track_feat(tracks, feat_flag='curr'):
if feat_flag == 'curr':
feat_list = [track.curr_feat.squeeze(0) for track in tracks]
elif feat_flag == 'smooth':
feat_list = [track.smooth_feat.squeeze(0) for track in tracks]
else:
raise NotImplementedError
n = len(tracks)
fdim = feat_list[0].shape[0]
fdim_num = len(feat_list[0].shape)
if fdim_num > 2:
feat_list = [f.view(fdim,-1) for f in feat_list]
numels = [f.shape[1] for f in feat_list]
ret = torch.zeros(n, fdim, np.max(numels)).to(feat_list[0].device)
for i, f in enumerate(feat_list):
ret[i, :, :numels[i]] = f
return ret
def reconsdot_distance(tracks, detections, tmp=100):
"""
:param tracks: list[STrack]
:param detections: list[BaseTrack]
:param metric:
:return: cost_matrix np.ndarray
"""
cost_matrix = np.zeros((len(tracks), len(detections)), dtype=np.float)
if cost_matrix.size == 0:
return cost_matrix, None
det_features_ = get_track_feat(detections)
track_features_ = get_track_feat(tracks, feat_flag='curr')
det_features = F.normalize(det_features_, dim=1)
track_features = F.normalize(track_features_, dim=1)
ndet, ndim, nsd = det_features.shape
ntrk, _, nst = track_features.shape
fdet = det_features.permute(0, 2, 1).reshape(-1, ndim).cuda()
ftrk = track_features.permute(0, 2, 1).reshape(-1, ndim).cuda()
aff = torch.mm(ftrk, fdet.transpose(0, 1))
aff_td = F.softmax(tmp*aff, dim=1)
aff_dt = F.softmax(tmp*aff, dim=0).transpose(0, 1)
recons_ftrk = torch.einsum('tds,dsm->tdm', aff_td.view(ntrk*nst, ndet, nsd),
fdet.view(ndet, nsd, ndim))
recons_fdet = torch.einsum('dts,tsm->dtm', aff_dt.view(ndet*nsd, ntrk, nst),
ftrk.view(ntrk, nst, ndim))
recons_ftrk = recons_ftrk.permute(0, 2, 1).view(ntrk, nst*ndim, ndet)
recons_ftrk_norm = F.normalize(recons_ftrk, dim=1)
recons_fdet = recons_fdet.permute(0, 2, 1).view(ndet, nsd*ndim, ntrk)
recons_fdet_norm = F.normalize(recons_fdet, dim=1)
dot_td = torch.einsum('tad,ta->td', recons_ftrk_norm,
F.normalize(ftrk.reshape(ntrk, nst*ndim), dim=1))
dot_dt = torch.einsum('dat,da->dt', recons_fdet_norm,
F.normalize(fdet.reshape(ndet, nsd*ndim), dim=1))
cost_matrix = 1 - 0.5 * (dot_td + dot_dt.transpose(0, 1))
cost_matrix = cost_matrix.detach().cpu().numpy()
return cost_matrix, None
def category_gate(cost_matrix, tracks, detections):
"""
:param tracks: list[STrack]
:param detections: list[BaseTrack]
:param metric:
:return: cost_matrix np.ndarray
"""
if cost_matrix.size == 0:
return cost_matrix
det_categories = np.array([d.category for d in detections])
trk_categories = np.array([t.category for t in tracks])
cost_matrix = cost_matrix + np.abs(
det_categories[None, :] - trk_categories[:, None])
return cost_matrix
================================================
FILE: core/motion/kalman_filter.py
================================================
# vim: expandtab:ts=4:sw=4
import numpy as np
import scipy.linalg
"""
Table for the 0.95 quantile of the chi-square distribution with N degrees of
freedom (contains values for N=1, ..., 9). Taken from MATLAB/Octave's chi2inv
function and used as Mahalanobis gating threshold.
"""
chi2inv95 = {
1: 3.8415,
2: 5.9915,
3: 7.8147,
4: 9.4877,
5: 11.070,
6: 12.592,
7: 14.067,
8: 15.507,
9: 16.919}
class KalmanFilter(object):
"""
A simple Kalman filter for tracking bounding boxes in image space.
The 8-dimensional state space
x, y, a, h, vx, vy, va, vh
contains the bounding box center position (x, y), aspect ratio a, height h,
and their respective velocities.
Object motion follows a constant velocity model. The bounding box location
(x, y, a, h) is taken as direct observation of the state space (linear
observation model).
"""
def __init__(self):
ndim, dt = 4, 1.
# Create Kalman filter model matrices.
self._motion_mat = np.eye(2 * ndim, 2 * ndim)
for i in range(ndim):
self._motion_mat[i, ndim + i] = dt
self._update_mat = np.eye(ndim, 2 * ndim)
# Motion and observation uncertainty are chosen relative to the current
# state estimate. These weights control the amount of uncertainty in
# the model. This is a bit hacky.
self._std_weight_position = 1. / 20
self._std_weight_velocity = 1. / 160
def initiate(self, measurement):
"""Create track from unassociated measurement.
Parameters
----------
measurement : ndarray
Bounding box coordinates (x, y, a, h) with center position (x, y),
aspect ratio a, and height h.
Returns
-------
(ndarray, ndarray)
Returns the mean vector (8 dimensional) and covariance matrix (8x8
dimensional) of the new track. Unobserved velocities are initialized
to 0 mean.
"""
mean_pos = measurement
mean_vel = np.zeros_like(mean_pos)
mean = np.r_[mean_pos, mean_vel]
std = [
2 * self._std_weight_position * measurement[3],
2 * self._std_weight_position * measurement[3],
1e-2,
2 * self._std_weight_position * measurement[3],
10 * self._std_weight_velocity * measurement[3],
10 * self._std_weight_velocity * measurement[3],
1e-5,
10 * self._std_weight_velocity * measurement[3]]
covariance = np.diag(np.square(std))
return mean, covariance
def predict(self, mean, covariance):
"""Run Kalman filter prediction step.
Parameters
----------
mean : ndarray
The 8 dimensional mean vector of the object state at the previous
time step.
covariance : ndarray
The 8x8 dimensional covariance matrix of the object state at the
previous time step.
Returns
-------
(ndarray, ndarray)
Returns the mean vector and covariance matrix of the predicted
state. Unobserved velocities are initialized to 0 mean.
"""
std_pos = [
self._std_weight_position * mean[3],
self._std_weight_position * mean[3],
1e-2,
self._std_weight_position * mean[3]]
std_vel = [
self._std_weight_velocity * mean[3],
self._std_weight_velocity * mean[3],
1e-5,
self._std_weight_velocity * mean[3]]
motion_cov = np.diag(np.square(np.r_[std_pos, std_vel]))
mean = np.dot(mean, self._motion_mat.T)
covariance = np.linalg.multi_dot((
self._motion_mat, covariance, self._motion_mat.T)) + motion_cov
return mean, covariance
def project(self, mean, covariance):
"""Project state distribution to measurement space.
Parameters
----------
mean : ndarray
The state's mean vector (8 dimensional array).
covariance : ndarray
The state's covariance matrix (8x8 dimensional).
Returns
-------
(ndarray, ndarray)
Returns the projected mean and covariance matrix of the given state
estimate.
"""
std = [
self._std_weight_position * mean[3],
self._std_weight_position * mean[3],
1e-1,
self._std_weight_position * mean[3]]
innovation_cov = np.diag(np.square(std))
mean = np.dot(self._update_mat, mean)
covariance = np.linalg.multi_dot((
self._update_mat, covariance, self._update_mat.T))
return mean, covariance + innovation_cov
def multi_predict(self, mean, covariance):
"""Run Kalman filter prediction step (Vectorized version).
Parameters
----------
mean : ndarray
The Nx8 dimensional mean matrix of the object states at the previous
time step.
covariance : ndarray
The Nx8x8 dimensional covariance matrics of the object states at the
previous time step.
Returns
-------
(ndarray, ndarray)
Returns the mean vector and covariance matrix of the predicted
state. Unobserved velocities are initialized to 0 mean.
"""
std_pos = [
self._std_weight_position * mean[:, 3],
self._std_weight_position * mean[:, 3],
1e-2 * np.ones_like(mean[:, 3]),
self._std_weight_position * mean[:, 3]]
std_vel = [
self._std_weight_velocity * mean[:, 3],
self._std_weight_velocity * mean[:, 3],
1e-5 * np.ones_like(mean[:, 3]),
self._std_weight_velocity * mean[:, 3]]
sqr = np.square(np.r_[std_pos, std_vel]).T
motion_cov = []
for i in range(len(mean)):
motion_cov.append(np.diag(sqr[i]))
motion_cov = np.asarray(motion_cov)
mean = np.dot(mean, self._motion_mat.T)
left = np.dot(self._motion_mat, covariance).transpose((1,0,2))
covariance = np.dot(left, self._motion_mat.T) + motion_cov
return mean, covariance
def update(self, mean, covariance, measurement):
"""Run Kalman filter correction step.
Parameters
----------
mean : ndarray
The predicted state's mean vector (8 dimensional).
covariance : ndarray
The state's covariance matrix (8x8 dimensional).
measurement : ndarray
The 4 dimensional measurement vector (x, y, a, h), where (x, y)
is the center position, a the aspect ratio, and h the height of the
bounding box.
Returns
-------
(ndarray, ndarray)
Returns the measurement-corrected state distribution.
"""
projected_mean, projected_cov = self.project(mean, covariance)
chol_factor, lower = scipy.linalg.cho_factor(
projected_cov, lower=True, check_finite=False)
kalman_gain = scipy.linalg.cho_solve(
(chol_factor, lower), np.dot(covariance, self._update_mat.T).T,
check_finite=False).T
innovation = measurement - projected_mean
new_mean = mean + np.dot(innovation, kalman_gain.T)
new_covariance = covariance - np.linalg.multi_dot((
kalman_gain, projected_cov, kalman_gain.T))
return new_mean, new_covariance
def gating_distance(self, mean, covariance, measurements,
only_position=False, metric='maha'):
"""Compute gating distance between state distribution and measurements.
A suitable distance threshold can be obtained from `chi2inv95`. If
`only_position` is False, the chi-square distribution has 4 degrees of
freedom, otherwise 2.
Parameters
----------
mean : ndarray
Mean vector over the state distribution (8 dimensional).
covariance : ndarray
Covariance of the state distribution (8x8 dimensional).
measurements : ndarray
An Nx4 dimensional matrix of N measurements, each in
format (x, y, a, h) where (x, y) is the bounding box center
position, a the aspect ratio, and h the height.
only_position : Optional[bool]
If True, distance computation is done with respect to the bounding
box center position only.
Returns
-------
ndarray
Returns an array of length N, where the i-th element contains the
squared Mahalanobis distance between (mean, covariance) and
`measurements[i]`.
"""
mean, covariance = self.project(mean, covariance)
if only_position:
mean, covariance = mean[:2], covariance[:2, :2]
measurements = measurements[:, :2]
d = measurements - mean
if metric == 'gaussian':
return np.sum(d * d, axis=1)
elif metric == 'maha':
cholesky_factor = np.linalg.cholesky(covariance)
z = scipy.linalg.solve_triangular(
cholesky_factor, d.T, lower=True, check_finite=False,
overwrite_b=True)
squared_maha = np.sum(z * z, axis=0)
return squared_maha
else:
raise ValueError('invalid distance metric')
================================================
FILE: core/propagation/__init__.py
================================================
###################################################################
# File Name: __init__.py
# Author: Zhongdao Wang
# mail: wcd17@mails.tsinghua.edu.cn
# Created Time: Mon Jan 18 15:57:34 2021
###################################################################
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
from .propagate_box import propagate_box
from .propagate_mask import propagate_mask
from .propagate_pose import propagate_pose
def propagate(temp_feats, obs, img, model, format='box'):
if format == 'box':
return propagate_box(temp_feats, obs, img, model)
elif format == 'mask':
return propagate_box(temp_feats, obs, img, model)
elif format == 'pose':
return propagate_pose(temp_feats, obs, img, model)
else:
raise ValueError('Observation format not supported.')
================================================
FILE: core/propagation/propagate_box.py
================================================
###################################################################
# File Name: propagate_box.py
# Author: Zhongdao Wang
# mail: wcd17@mails.tsinghua.edu.cn
# Created Time: Mon Jan 18 16:01:46 2021
###################################################################
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
def propagate_box(temp_feats, box, img, model):
pass
================================================
FILE: core/propagation/propagate_mask.py
================================================
###################################################################
# File Name: propagate_box.py
# Author: Zhongdao Wang
# mail: wcd17@mails.tsinghua.edu.cn
# Created Time: Mon Jan 18 16:01:46 2021
###################################################################
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
def propagate_mask(temp_feats, mask, img, model):
pass
================================================
FILE: core/propagation/propagate_pose.py
================================================
###################################################################
# File Name: propagate_box.py
# Author: Zhongdao Wang
# mail: wcd17@mails.tsinghua.edu.cn
# Created Time: Mon Jan 18 16:01:46 2021
###################################################################
from __future__ import print_function
from __future__ import division
from __future__ import absolute_import
def propagate_pose(temp_feats, pose, img, model):
pass
================================================
FILE: data/jhmdb.py
================================================
from __future__ import print_function, absolute_import
import os
import numpy as np
import math
import scipy.io as sio
import cv2
import torch
from matplotlib import cm
from utils import im_to_numpy, im_to_torch
def resize(img, owidth, oheight):
img = im_to_numpy(img)
img = cv2.resize( img, (owidth, oheight) )
img = im_to_torch(img)
return img
def load_image(img_path):
# H x W x C => C x H x W
img = cv2.imread(img_path)
# print(img_path)
img = img.astype(np.float32)
img = img / 255.0
img = img[:,:,::-1]
img = img.copy()
return im_to_torch(img)
def color_normalize(x, mean, std):
if x.size(0) == 1:
x = x.repeat(3, 1, 1)
for t, m, s in zip(x, mean, std):
t.sub_(m)
t.div_(s)
return x
import time
######################################################################
def try_np_load(p):
try:
return np.load(p)
except:
return None
def make_lbl_set(lbls):
print(lbls.shape)
t00 = time.time()
lbl_set = [np.zeros(3).astype(np.uint8)]
count_lbls = [0]
flat_lbls_0 = lbls[0].copy().reshape(-1, lbls.shape[-1]).astype(np.uint8)
lbl_set = np.unique(flat_lbls_0, axis=0)
# print(lbl_set)
# if (lbl_set > 20).sum() > 0:
# import pdb; pdb.set_trace()
# count_lbls = [np.all(flat_lbls_0 == ll, axis=-1).sum() for ll in lbl_set]
print('lbls', time.time() - t00)
return lbl_set
def texturize(onehot):
flat_onehot = onehot.reshape(-1, onehot.shape[-1])
lbl_set = np.unique(flat_onehot, axis=0)
count_lbls = [np.all(flat_onehot == ll, axis=-1).sum() for ll in lbl_set]
object_id = np.argsort(count_lbls)[::-1][1]
hidxs = []
for h in range(onehot.shape[0]):
# appears = any(np.all(onehot[h] == lbl_set[object_id], axis=-1))
appears = np.any(onehot[h, :, 1:] == 1)
if appears:
hidxs.append(h)
nstripes = min(10, len(hidxs))
out = np.zeros((*onehot.shape[:2], nstripes+1))
out[:, :, 0] = 1
for i, h in enumerate(hidxs):
cidx = int(i // (len(hidxs) / nstripes))
w = np.any(onehot[h, :, 1:] == 1, axis=-1)
out[h][w] = 0
out[h][w, cidx+1] = 1
# print(i, h, cidx)
return out
class JhmdbSet(torch.utils.data.Dataset):
def __init__(self, args, sigma=0.5):
self.filelist = args.filelist
self.imgSize = args.imgSize
self.videoLen = args.videoLen
self.mapScale = args.mapScale
self.sigma = sigma
f = open(self.filelist, 'r')
self.jpgfiles = []
self.lblfiles = []
for line in f:
rows = line.split()
jpgfile = rows[1]
lblfile = rows[0]
self.jpgfiles.append(jpgfile)
self.lblfiles.append(lblfile)
f.close()
def get_onehot_lbl(self, lbl_path):
name = '/' + '/'.join(lbl_path.split('.')[:-1]) + '_onehot.npy'
if os.path.exists(name):
return np.load(name)
else:
return None
def make_paths(self, folder_path, label_path):
I = [ ll for ll in os.listdir(folder_path) if '.png' in ll ]
frame_num = len(I) + self.videoLen
I.sort(key=lambda x:int(x.split('.')[0]))
I_out, L_out = [], []
for i in range(frame_num):
i = max(0, i - self.videoLen)
img_path = "%s/%s" % (folder_path, I[i])
I_out.append(img_path)
return I_out
def __getitem__(self, index):
folder_path = self.jpgfiles[index]
label_path = self.lblfiles[index]
imgs = []
imgs_orig = []
lbls = []
lbls_onehot = []
patches = []
target_imgs = []
img_paths = self.make_paths(folder_path, label_path)
frame_num = len(img_paths)
mean, std = [0.485, 0.456, 0.406], [0.229, 0.224, 0.225]
t000 = time.time()
# frame_num = 30
for i in range(frame_num):
t00 = time.time()
img_path = img_paths[i]
img = load_image(img_path) # CxHxW
# print('loaded', i, time.time() - t00)
ht, wd = img.size(1), img.size(2)
if self.imgSize > 0:
newh, neww = ht, wd
if ht <= wd:
ratio = 1.0 #float(wd) / float(ht)
# width, height
img = resize(img, int(self.imgSize * ratio), self.imgSize)
newh = self.imgSize
neww = int(self.imgSize * ratio)
else:
ratio = 1.0 #float(ht) / float(wd)
# width, height
img = resize(img, self.imgSize, int(self.imgSize * ratio))
newh = int(self.imgSize * ratio)
neww = self.imgSize
img_orig = img.clone()
img = color_normalize(img, mean, std)
imgs_orig.append(img_orig)
imgs.append(img)
rsz_h, rsz_w = math.ceil(img.size(1) / self.mapScale[0]), math.ceil(img.size(2) /self.mapScale[1])
lbls_mat = sio.loadmat(label_path)
lbls_coord = lbls_mat['pos_img']
lbls_coord = lbls_coord - 1
lbls_coord[0, :, :] = lbls_coord[0, :, :] * float(neww) / float(wd) / self.mapScale[0]
lbls_coord[1, :, :] = lbls_coord[1, :, :] * float(newh) / float(ht) / self.mapScale[1]
lblsize = (rsz_h, rsz_w)
lbls = np.zeros((lbls_coord.shape[2], lblsize[0], lblsize[1], lbls_coord.shape[1]))
for i in range(lbls_coord.shape[2]):
lbls_coord_now = lbls_coord[:, :, i]
scales = lbls_coord_now.max(1) - lbls_coord_now.min(1)
scale = scales.max()
scale = max(0.5, scale*0.015)
for j in range(lbls_coord.shape[1]):
if self.sigma > 0:
draw_labelmap_np(lbls[i, :, :, j], lbls_coord_now[:, j], scale)
else:
tx = int(lbls_coord_now[0, j])
ty = int(lbls_coord_now[1, j])
if tx < lblsize[1] and ty < lblsize[0] and tx >=0 and ty >=0:
lbls[i, ty, tx, j] = 1.0
lbls_tensor = torch.zeros(frame_num, lblsize[0], lblsize[1], lbls_coord.shape[1])
for i in range(frame_num):
if i < self.videoLen:
nowlbl = lbls[0]
else:
if(i - self.videoLen < len(lbls)):
nowlbl = lbls[i - self.videoLen]
lbls_tensor[i] = torch.from_numpy(nowlbl)
lbls_tensor = torch.cat([(lbls_tensor.sum(-1) == 0)[..., None] *1.0, lbls_tensor], dim=-1)
lblset = np.arange(lbls_tensor.shape[-1]-1)
lblset = np.array([[0, 0, 0]] + [cm.Paired(i)[:3] for i in lblset]) * 255.0
# Meta info
meta = dict(folder_path=folder_path, img_paths=img_paths, lbl_paths=[])
imgs = torch.stack(imgs)
imgs_orig = torch.stack(imgs_orig)
lbls_resize = lbls_tensor #np.stack(resizes)
assert lbls_resize.shape[0] == len(meta['img_paths'])
#print('vid', i, 'took', time.time() - t000)
return imgs, imgs_orig, lbls_resize, lbls_tensor, lblset, meta
def __len__(self):
return len(self.jpgfiles)
def draw_labelmap_np(img, pt, sigma, type='Gaussian'):
# Draw a 2D gaussian
# Adopted from https://github.com/anewell/pose-hg-train/blob/master/src/pypose/draw.py
# Check that any part of the gaussian is in-bounds
ul = [int(pt[0] - 3 * sigma), int(pt[1] - 3 * sigma)]
br = [int(pt[0] + 3 * sigma + 1), int(pt[1] + 3 * sigma + 1)]
if (ul[0] >= img.shape[1] or ul[1] >= img.shape[0] or
br[0] < 0 or br[1] < 0):
# If not, just return the image as is
return img
# Generate gaussian
size = 6 * sigma + 1
x = np.arange(0, size, 1, float)
y = x[:, np.newaxis]
x0 = y0 = size // 2
# The gaussian is not normalized, we want the center value to equal 1
if type == 'Gaussian':
g = np.exp(- ((x - x0) ** 2 + (y - y0) ** 2) / (2 * sigma ** 2))
elif type == 'Cauchy':
g = sigma / (((x - x0) ** 2 + (y - y0) ** 2 + sigma ** 2) ** 1.5)
# Usable gaussian range
g_x = max(0, -ul[0]), min(br[0], img.shape[1]) - ul[0]
g_y = max(0, -ul[1]), min(br[1], img.shape[0]) - ul[1]
# Image range
img_x = max(0, ul[0]), min(br[0], img.shape[1])
img_y = max(0, ul[1]), min(br[1], img.shape[0])
img[img_y[0]:img_y[1], img_x[0]:img_x[1]] = g[g_y[0]:g_y[1], g_x[0]:g_x[1]]
return img
================================================
FILE: data/kinetics.py
================================================
import torchvision.datasets.video_utils
from torchvision.datasets.video_utils import VideoClips
from torchvision.datasets.utils import list_dir
from torchvision.datasets.folder import make_dataset
from torchvision.datasets.vision import VisionDataset
import numpy as np
class Kinetics400(VisionDataset):
"""
`Kinetics-400 <https://deepmind.com/research/open-source/open-source-datasets/kinetics/>`_
dataset.
Kinetics-400 is an action recognition video dataset.
This dataset consider every video as a collection of video clips of fixed size, specified
by ``frames_per_clip``, where the step in frames between each clip is given by
``step_between_clips``.
To give an example, for 2 videos with 10 and 15 frames respectively, if ``frames_per_clip=5``
and ``step_between_clips=5``, the dataset size will be (2 + 3) = 5, where the first two
elements will come from video 1, and the next three elements from video 2.
Note that we drop clips which do not have exactly ``frames_per_clip`` elements, so not all
frames in a video might be present.
Internally, it uses a VideoClips object to handle clip creation.
Args:
root (string): Root directory of the Kinetics-400 Dataset.
frames_per_clip (int): number of frames in a clip
step_between_clips (int): number of frames between each clip
transform (callable, optional): A function/transform that takes in a TxHxWxC video
and returns a transformed version.
Returns:
video (Tensor[T, H, W, C]): the `T` video frames
audio(Tensor[K, L]): the audio frames, where `K` is the number of channels
and `L` is the number of points
label (int): class of the video clip
"""
def __init__(self, root, frames_per_clip, step_between_clips=1, frame_rate=None,
extensions=('mp4',), transform=None, cached=None, _precomputed_metadata=None):
super(Kinetics400, self).__init__(root)
extensions = extensions
classes = list(sorted(list_dir(root)))
class_to_idx = {classes[i]: i for i in range(len(classes))}
self.samples = make_dataset(self.root, class_to_idx, extensions, is_valid_file=None)
self.classes = classes
video_list = [x[0] for x in self.samples]
self.video_clips = VideoClips(
video_list,
frames_per_clip,
step_between_clips,
frame_rate,
_precomputed_metadata,
)
self.transform = transform
def __len__(self):
return self.video_clips.num_clips()
def __getitem__(self, idx):
success = False
while not success:
try:
video, audio, info, video_idx = self.video_clips.get_clip(idx)
success = True
except:
print('skipped idx', idx)
idx = np.random.randint(self.__len__())
label = self.samples[video_idx][1]
if self.transform is not None:
video = self.transform(video)
return video, audio, label
================================================
FILE: data/video.py
================================================
import os
import pdb
import glob
import json
import os.path as osp
import cv2
import numpy as np
import pycocotools.mask as mask_utils
from utils.box import xyxy2xywh
from torchvision.transforms import transforms as T
class LoadImages: # for inference
def __init__(self, path, img_size=(1088, 608)):
if os.path.isdir(path):
image_format = ['.jpg', '.jpeg', '.png', '.tif']
self.files = sorted(glob.glob('%s/*.*' % path))
self.files = list(filter(lambda x: os.path.splitext(x)[1].lower()
in image_format, self.files))
elif os.path.isfile(path):
self.files = [path]
self.nF = len(self.files) # number of image files
self.width = img_size[0]
self.height = img_size[1]
self.count = 0
assert self.nF > 0, 'No images found in ' + path
def __iter__(self):
self.count = -1
return self
def __next__(self):
self.count += 1
if self.count == self.nF:
raise StopIteration
img_path = self.files[self.count]
# Read image
img0 = cv2.imread(img_path) # BGR
assert img0 is not None, 'Failed to load ' + img_path
# Padded resize
img, _, _, _ = letterbox(img0, height=self.height, width=self.width)
# Normalize RGB
img = img[:, :, ::-1].transpose(2, 0, 1)
img = np.ascontiguousarray(img, dtype=np.float32)
img /= 255.0
return img_path, img, img0
def __getitem__(self, idx):
idx = idx % self.nF
img_path = self.files[idx]
# Read image
img0 = cv2.imread(img_path) # BGR
assert img0 is not None, 'Failed to load ' + img_path
# Padded resize
img, _, _, _ = letterbox(img0, height=self.height, width=self.width)
# Normalize RGB
img = img[:, :, ::-1].transpose(2, 0, 1)
img = np.ascontiguousarray(img, dtype=np.float32)
img /= 255.0
return img_path, img, img0
def __len__(self):
return self.nF # number of files
class LoadVideo: # for inference
def __init__(self, path, img_size=(1088, 608)):
self.cap = cv2.VideoCapture(path)
self.frame_rate = int(round(self.cap.get(cv2.CAP_PROP_FPS)))
self.vw = int(self.cap.get(cv2.CAP_PROP_FRAME_WIDTH))
self.vh = int(self.cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
self.vn = int(self.cap.get(cv2.CAP_PROP_FRAME_COUNT))
self.width = img_size[0]
self.height = img_size[1]
self.count = 0
self.w, self.h = self.get_size(self.vw, self.vh, self.width, self.height)
print('Lenth of the video: {:d} frames'.format(self.vn))
def get_size(self, vw, vh, dw, dh):
wa, ha = float(dw) / vw, float(dh) / vh
a = min(wa, ha)
return int(vw * a), int(vh*a)
def __iter__(self):
self.count = -1
return self
def __next__(self):
self.count += 1
if self.count == len(self):
raise StopIteration
# Read image
res, img0 = self.cap.read() # BGR
assert img0 is not None, 'Failed to load frame {:d}'.format(self.count)
img0 = cv2.resize(img0, (self.w, self.h))
# Padded resize
img, _, _, _ = letterbox(img0, height=self.height, width=self.width)
# Normalize RGB
img = img[:, :, ::-1]
img = np.ascontiguousarray(img, dtype=np.float32)
return self.count, img, img0
def __len__(self):
return self.vn # number of files
class LoadImagesAndObs:
def __init__(self, path, opt):
obid = opt.obid
img_size = getattr(opt,'img_size', None)
if os.path.isdir(path):
image_format = ['.jpg', '.jpeg', '.png', '.tif']
self.img_files = sorted(glob.glob('%s/*.*' % path))
self.img_files = list(filter(
lambda x: os.path.splitext(x)[1].lower() in image_format, self.img_files))
elif os.path.isfile(path):
self.img_files = [path,]
self.label_files = [x.replace('images', osp.join('obs', obid)).replace(
'.png', '.txt').replace('.jpg', '.txt') for x in self.img_files]
self.nF = len(self.img_files) # number of image files
self.transforms = T.Compose([T.ToTensor(), T.Normalize(opt.im_mean, opt.im_std)])
self.use_lab = getattr(opt, 'use_lab', False)
if not img_size is None:
self.width = img_size[0]
self.height = img_size[1]
def __getitem__(self, files_index):
img_path = self.img_files[files_index]
label_path = self.label_files[files_index]
return self.get_data(img_path, label_path)
def get_data(self, img_path, label_path):
height = self.height
width = self.width
img_ori = cv2.imread(img_path) # BGR
if img_ori is None:
raise ValueError('File corrupt {}'.format(img_path))
h, w, _ = img_ori.shape
img, ratio, padw, padh = letterbox(img_ori, height=height, width=width)
# Load labels
if os.path.isfile(label_path):
labels0 = np.loadtxt(label_path, dtype=np.float32).reshape(-1, 5)
# Normalized xywh to pixel xyxy format
labels = labels0.copy()
labels[:, 0] = ratio * w * (labels0[:, 0] - labels0[:, 2] / 2) + padw
labels[:, 1] = ratio * h * (labels0[:, 1] - labels0[:, 3] / 2) + padh
labels[:, 2] = ratio * w * (labels0[:, 0] + labels0[:, 2] / 2) + padw
labels[:, 3] = ratio * h * (labels0[:, 1] + labels0[:, 3] / 2) + padh
else:
labels = np.array([])
nL = len(labels)
if nL > 0:
# convert xyxy to xywh
labels[:, 0:4] = xyxy2xywh(labels[:, 0:4].copy())
labels[:, 0] /= width
labels[:, 1] /= height
labels[:, 2] /= width
labels[:, 3] /= height
if self.use_lab:
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
img = np.array([img[:, :, 0], ]*3)
img = img.transpose(1, 2, 0)
img = img / 255.
img = np.ascontiguousarray(img[:, :, ::-1]) # BGR to RGB
if self.transforms is not None:
img = self.transforms(img)
return img, labels, img_ori, (h, w)
def __len__(self):
return self.nF # number of batches
class LoadImagesAndObsTAO:
def __init__(self, root, video_meta, obs, opt):
self.dataroot = root
self.img_ind = [x['id'] for x in video_meta]
self.img_files = [x['file_name'] for x in video_meta]
self.img_files = [osp.join(root, 'frames', x) for x in self.img_files]
self.obs = [obs.get(x, []) for x in self.img_ind]
self.use_lab = getattr(opt, 'use_lab', False)
self.transforms = T.Compose([T.ToTensor(), T.Normalize(opt.im_mean, opt.im_std)])
def __getitem__(self, index):
img_ori = cv2.imread(self.img_files[index])
if img_ori is None:
raise ValueError('File corrupt {}'.format(img_path))
h, w, _ = img_ori.shape
img = img_ori
if self.use_lab:
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
img = np.array([img[:,:,0],]*3)
img = img.transpose(1,2,0)
img = img / 255.
img = np.ascontiguousarray(img[ :, :, ::-1]) # BGR to RGB
if self.transforms is not None:
img = self.transforms(img)
obs = self.obs[index]
if len(obs) == 0:
labels = np.array([[0,0,1,1,-1,-1]])
else:
boxes = np.array([x.get('bbox', [0,0,1,1]) for x in obs])
scores = np.array([x.get('score', 0) for x in obs])[:, None]
cat_ids = np.array([x.get('category_id',-1) for x in obs])[:, None]
labels = np.concatenate([boxes, scores, cat_ids], axis=1)
if len(labels) > 0:
# From tlwh to xywh: (x,y) is the box center
labels[:, 0] = labels[:, 0] + labels[:, 2] / 2
labels[:, 1] = labels[:, 1] + labels[:, 3] / 2
labels[:, 0] /= w
labels[:, 1] /= h
labels[:, 2] /= w
labels[:, 3] /= h
return img, labels, img_ori, (h,w)
def __len__(self):
return len(self.img_files)
class LoadImagesAndMaskObsVIS:
def __init__(self, path, info, obs, opt):
self.dataroot = path
self.nF = info['length']
self.img_files = [osp.join(path, p) for p in info['file_names']]
self.obsbyobj = obs
self.transforms = T.Compose([T.ToTensor(), T.Normalize(opt.im_mean, opt.im_std)])
self.use_lab = getattr(opt, 'use_lab', False)
def __getitem__(self, idx):
img_ori = cv2.imread(self.img_files[idx])
if img_ori is None:
raise ValueError('File corrupt {}'.format(img_path))
h, w, _ = img_ori.shape
img = img_ori
if self.use_lab:
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
img = np.array([img[:,:,0],]*3)
img = img.transpose(1,2,0)
img = img / 255.
img = np.ascontiguousarray(img[ :, :, ::-1]) # BGR to RGB
if self.transforms is not None:
img = self.transforms(img)
labels = list()
for obj in self.obsbyobj:
RLE = obj['segmentations'][idx]
if RLE: labels.append(mask_utils.decode(RLE))
else: labels.append(np.zeros((h, w), dtype=np.uint8))
labels = np.stack(labels)
return img, labels, img_ori, (h, w)
def __len__(self):
return self.nF
class LoadImagesAndMaskObsMOTS(LoadImagesAndObs):
def __init__(self, path, opt):
super(LoadImagesAndMaskObsMOTS, self).__init__(path, opt)
def get_data(self, img_path, label_path):
img_ori = cv2.imread(img_path) # BGR
if img_ori is None:
raise ValueError('File corrupt {}'.format(img_path))
h, w, _ = img_ori.shape
img = img_ori
if self.use_lab:
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
img = np.array([img[:,:,0],]*3)
img = img.transpose(1,2,0)
img = img / 255.
img = np.ascontiguousarray(img[ :, :, ::-1]) # BGR to RGB
if self.transforms is not None:
img = self.transforms(img)
# Load labels
labels = []
if os.path.isfile(label_path):
with open(label_path, 'r') as f:
for line in f:
labels.append(line.strip().split())
nL = len(labels)
if nL > 0:
labels = [{'size':(int(h),int(w)), 'counts':m} for \
_, _,cid,h,w,m in labels if cid=='2']
labels = [mask_utils.decode(rle) for rle in labels]
labels = np.stack(labels)
return img, labels, img_ori, (h, w)
class LoadImagesAndPoseObs(LoadImagesAndObs):
def __init__(self, obs_jpath, opt):
fjson = open(obs_jpath, 'r')
self.infoj = json.load(fjson)['annolist']
self.dataroot = opt.data_root
self.nF = len(self.infoj)
self.img_files = [osp.join(opt.data_root, p['image'][0]['name']) for p in self.infoj]
self.transforms = T.Compose([T.ToTensor(), T.Normalize(opt.im_mean, opt.im_std)])
self.use_lab = getattr(opt, 'use_lab', False)
def __getitem__(self, idx):
img_ori = cv2.imread(self.img_files[idx])
if img_ori is None:
raise ValueError('File corrupt {}'.format(img_path))
h, w, _ = img_ori.shape
img = img_ori
if self.use_lab:
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
img = np.array([img[:,:,0],]*3)
img = img.transpose(1,2,0)
img = img / 255.
img = np.ascontiguousarray(img[ :, :, ::-1]) # BGR to RGB
if self.transforms is not None:
img = self.transforms(img)
info_label = self.infoj[idx]['annorect']
nobj = len(info_label)
labels = list()
labels = [l['annopoints'][0]['point'] for l in info_label]
return img, labels, img_ori, (h, w)
def letterbox(img, height=608, width=1088, color=(127.5, 127.5, 127.5)): # resize a rectangular image to a padded rectangular
shape = img.shape[:2] # shape = [height, width]
ratio = min(float(height)/shape[0], float(width)/shape[1])
new_shape = (round(shape[1] * ratio), round(shape[0] * ratio)) # new_shape = [width, height]
dw = (width - new_shape[0]) / 2 # width padding
dh = (height - new_shape[1]) / 2 # height padding
top, bottom = round(dh - 0.1), round(dh + 0.1)
left, right = round(dw - 0.1), round(dw + 0.1)
img = cv2.resize(img, new_shape, interpolation=cv2.INTER_AREA) # resized, no border
img = cv2.copyMakeBorder(img, top, bottom, left, right, cv2.BORDER_CONSTANT, value=color) # padded rectangular
return img, ratio, dw, dh
================================================
FILE: data/vos.py
================================================
from __future__ import print_function, absolute_import
import os
import pdb
import os.path as osp
import numpy as np
import math
import cv2
import torch
import time
from matplotlib import cm
from utils import im_to_numpy, im_to_torch
def resize(img, owidth, oheight):
img = im_to_numpy(img)
img = cv2.resize(img, (owidth, oheight))
img = im_to_torch(img)
return img
def load_image(img):
# H x W x C => C x H x W
if isinstance(img, str):
img = cv2.imread(img)
if len(img.shape) == 2:
img = cv2.cvtColor(img, cv2.COLOR_GRAY2BGR)
img = img.astype(np.float32)
img = img / 255.0
img = img[:, :, ::-1]
img = img.copy()
return im_to_torch(img)
def color_normalize(x, mean, std):
if x.size(0) == 1:
x = x.repeat(3, 1, 1)
for t, m, s in zip(x, mean, std):
t.sub_(m)
t.div_(s)
return x
######################################################################
def try_np_load(p):
try:
return np.load(p)
except:
return None
def make_lbl_set(lbls):
lbl_set = [np.zeros(3).astype(np.uint8)]
flat_lbls_0 = lbls[0].copy().reshape(-1, lbls.shape[-1]).astype(np.uint8)
lbl_set = np.unique(flat_lbls_0, axis=0)
return lbl_set
def texturize(onehot):
flat_onehot = onehot.reshape(-1, onehot.shape[-1])
lbl_set = np.unique(flat_onehot, axis=0)
count_lbls = [np.all(flat_onehot == ll, axis=-1).sum() for ll in lbl_set]
object_id = np.argsort(count_lbls)[::-1][1]
hidxs = []
for h in range(onehot.shape[0]):
appears = np.any(onehot[h, :, 1:] == 1)
if appears:
hidxs.append(h)
nstripes = min(10, len(hidxs))
out = np.zeros((*onehot.shape[:2], nstripes+1))
out[:, :, 0] = 1
for i, h in enumerate(hidxs):
cidx = int(i // (len(hidxs) / nstripes))
w = np.any(onehot[h, :, 1:] == 1, axis=-1)
out[h][w] = 0
out[h][w, cidx+1] = 1
return out
class VOSDataset(torch.utils.data.Dataset):
def __init__(self, args):
self.davisroot = args.davisroot
self.split = args.split
self.imgSize = args.imgSize
self.videoLen = args.videoLen
self.mapScale = args.mapScale
self.texture = False
self.round = False
self.use_lab = getattr(args, 'use_lab', False)
self.im_mean = args.im_mean
self.im_std = args.im_std
filelist = osp.join(self.davisroot, 'ImageSets/2017', self.split+'.txt')
f = open(filelist, 'r')
self.jpgfiles = []
self.lblfiles = []
for line in f:
seq = line.strip()
self.jpgfiles.append(osp.join(self.davisroot,'JPEGImages','480p', seq))
self.lblfiles.append(osp.join(self.davisroot, 'Annotations','480p', seq))
f.close()
def get_onehot_lbl(self, lbl_path):
name = '/' + '/'.join(lbl_path.split('.')[:-1]) + '_onehot.npy'
if os.path.exists(name):
return np.load(name)
else:
return None
def make_paths(self, folder_path, label_path):
I, L = os.listdir(folder_path), os.listdir(label_path)
L = [ll for ll in L if 'npy' not in ll]
frame_num = len(I) + self.videoLen
I.sort(key=lambda x:int(x.split('.')[0]))
L.sort(key=lambda x:int(x.split('.')[0]))
I_out, L_out = [], []
for i in range(frame_num):
i = max(0, i - self.videoLen)
img_path = "%s/%s" % (folder_path, I[i])
lbl_path = "%s/%s" % (label_path, L[i])
I_out.append(img_path)
L_out.append(lbl_path)
return I_out, L_out
def __getitem__(self, index):
folder_path = self.jpgfiles[index]
label_path = self.lblfiles[index]
imgs = []
imgs_orig = []
lbls = []
lbls_onehot = []
patches = []
target_imgs = []
frame_num = len(os.listdir(folder_path)) + self.videoLen
img_paths, lbl_paths = self.make_paths(folder_path, label_path)
t000 = time.time()
for i in range(frame_num):
t00 = time.time()
img_path, lbl_path = img_paths[i], lbl_paths[i]
img = load_image(img_path) # CxHxW
lblimg = cv2.imread(lbl_path)
'''
Resize img to 320x320
'''
ht, wd = img.size(1), img.size(2)
if self.imgSize > 0:
newh, neww = ht, wd
if ht <= wd:
ratio = 1.0 #float(wd) / float(ht)
# width, height
img = resize(img, int(self.imgSize * ratio), self.imgSize)
newh = self.imgSize
neww = int(self.imgSize * ratio)
else:
ratio = 1.0 #float(ht) / float(wd)
# width, height
img = resize(img, self.imgSize, int(self.imgSize * ratio))
newh = int(self.imgSize * ratio)
neww = self.imgSize
lblimg = cv2.resize(lblimg, (newh, neww), cv2.INTER_NEAREST)
# Resized, but not augmented image
img_orig = img.clone()
'''
Transforms
'''
if self.use_lab:
img = im_to_numpy(img)
img = (img * 255).astype(np.uint8)[:,:,::-1]
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
img = im_to_torch(img) / 255.
img = color_normalize(img, self.im_mean, self.im_std)
img = torch.stack([img[0]]*3)
else:
img = color_normalize(img, self.im_mean, self.im_std)
imgs_orig.append(img_orig)
imgs.append(img)
lbls.append(lblimg.copy())
# Meta info
meta = dict(folder_path=folder_path, img_paths=img_paths, lbl_paths=lbl_paths)
########################################################
# Load reshaped label information (load cached versions if possible)
lbls = np.stack(lbls)
prefix = '/' + '/'.join(lbl_paths[0].split('.')[:-1])
# Get lblset
lblset = make_lbl_set(lbls)
if np.all((lblset[1:] - lblset[:-1]) == 1):
lblset = lblset[:, 0:1]
onehots = []
resizes = []
rsz_h, rsz_w = math.ceil(img.size(1) / self.mapScale[0]), math.ceil(img.size(2) /self.mapScale[1])
for i,p in enumerate(lbl_paths):
prefix = '/' + '/'.join(p.split('.')[:-1])
# print(prefix)
oh_path = "%s_%s.npy" % (prefix, 'onehot')
rz_path = "%s_%s.npy" % (prefix, 'size%sx%s' % (rsz_h, rsz_w))
onehot = try_np_load(oh_path)
if onehot is None:
print('computing onehot lbl for', oh_path)
onehot = np.stack([np.all(lbls[i] == ll, axis=-1) for ll in lblset], axis=-1)
np.save(oh_path, onehot)
resized = try_np_load(rz_path)
if resized is None:
print('computing resized lbl for', rz_path)
resized = cv2.resize(np.float32(onehot), (rsz_w, rsz_h), cv2.INTER_LINEAR)
np.save(rz_path, resized)
if self.texture:
texturized = texturize(resized)
resizes.append(texturized)
lblset = np.array([[0, 0, 0]] + [cm.Paired(i)[:3] for i in range(texturized.shape[-1])]) * 255.0
break
else:
resizes.append(resized)
onehots.append(onehot)
if self.texture:
resizes = resizes * self.videoLen
for _ in range(len(lbl_paths)-self.videoLen):
resizes.append(np.zeros(resizes[0].shape))
onehots = resizes
########################################################
imgs = torch.stack(imgs)
imgs_orig = torch.stack(imgs_orig)
lbls_tensor = torch.from_numpy(np.stack(lbls))
lbls_resize = np.stack(resizes)
assert lbls_resize.shape[0] == len(meta['lbl_paths'])
return imgs, imgs_orig, lbls_resize, lbls_tensor, lblset, meta
def __len__(self):
return len(self.jpgfiles)
================================================
FILE: demo/mot_demo.py
================================================
###################################################################
# File Name: mot_demo.py
# Author: Zhongdao Wang
# mail: wcd17@mails.tsinghua.edu.cn
# Created Time: Sat Jul 24 16:07:23 2021
###################################################################
import os
import sys
import yaml
import argparse
import os.path as osp
from loguru import logger
import cv2
import torch
import numpy as np
from torchvision.transforms import transforms as T
sys.path[0] = os.getcwd()
from data.video import LoadVideo
from utils.meter import Timer
from utils import visualize as vis
from detector.YOLOX.yolox.exp import get_exp
from detector.YOLOX.yolox.utils import get_model_info
from detector.YOLOX.yolox.data.datasets import COCO_CLASSES
from detector.YOLOX.tools.demo import Predictor
from utils.box import scale_box_input_size
from tracker.mot.box import BoxAssociationTracker
def make_parser():
parser = argparse.ArgumentParser("YOLOX + UniTrack MOT demo")
# Common arguments
parser.add_argument('--demo', default='video',
help='demo type, eg. video or webcam')
parser.add_argument('--path', default='./docs/test_video.mp3',
help='path to images or video')
parser.add_argument('--save_result', action='store_true',
help='whether to save result')
parser.add_argument("--nms", default=None, type=float,
help="test nms threshold")
parser.add_argument("--tsize", default=[640, 480], type=int, nargs='+',
help="test img size")
parser.add_argument("--exp_file", type=str,
default='./detector/YOLOX/exps/default/yolox_x.py',
help="pls input your expriment description file")
parser.add_argument('--output-root', default='./results/mot_demo',
help='output directory')
parser.add_argument('--classes', type=int, nargs='+',
default=list(range(90)), help='COCO_CLASSES')
# Detector related
parser.add_argument("-c", "--ckpt", type=str,
default='./detector/YOLOX/weights/yolox_x.pth',
help="model weights of the detector")
parser.add_argument("--conf", default=0.65, type=float,
help="detection confidence threshold")
# UniTrack related
parser.add_argument('--config', type=str, help='tracker config file',
default='./config/imagenet_resnet18_s3.yaml')
return parser
def dets2obs(dets, imginfo, cls):
if dets is None or len(dets) == 0:
return np.array([])
obs = dets.cpu().numpy()
h, w = imginfo['height'], imginfo['width']
# To xywh
ret = np.zeros((len(obs), 6))
ret[:, 0] = (obs[:, 0] + obs[:, 2]) * 0.5 / w
ret[:, 1] = (obs[:, 1] + obs[:, 3]) * 0.5 / h
ret[:, 2] = (obs[:, 2] - obs[:, 0]) / w
ret[:, 3] = (obs[:, 3] - obs[:, 1]) / h
ret[:, 4] = obs[:, 4] * obs[:, 5]
ret[:, 5] = obs[:, 6]
ret = [r for r in ret if int(r[5]) in cls]
ret = np.array(ret)
return ret
def eval_seq(opt, dataloader, detector, tracker,
result_filename, save_dir=None,
show_image=True):
transforms = T.Compose([T.ToTensor(),
T.Normalize(opt.im_mean, opt.im_std)])
if save_dir:
os.makedirs(save_dir, exist_ok=True)
timer = Timer()
results = []
for frame_id, (_, img, img0) in enumerate(dataloader):
if frame_id % 20 == 0:
logger.info('Processing frame {} ({:.2f} fps)'.format(
frame_id, 1./max(1e-5, timer.average_time)))
# run tracking
timer.tic()
det_outputs, img_info = detector.inference(img)
img = img / 255.
img = transforms(img)
obs = dets2obs(det_outputs[0], img_info, opt.classes)
if len(obs) == 0:
online_targets = []
else:
online_targets = tracker.update(img, img0, obs)
online_tlwhs = []
online_ids = []
for t in online_targets:
tlwh = t.tlwh
tid = t.track_id
online_tlwhs.append(tlwh)
online_ids.append(tid)
timer.toc()
# save results
results.append((frame_id + 1, online_tlwhs, online_ids))
if show_image or save_dir is not None:
online_im = vis.plot_tracking(
img0, online_tlwhs, online_ids, frame_id=frame_id,
fps=1. / timer.average_time)
if show_image:
cv2.imshow('online_im', online_im)
if save_dir is not None:
cv2.imwrite(os.path.join(
save_dir, '{:05d}.jpg'.format(frame_id)), online_im)
return frame_id, timer.average_time, timer.calls
def main(exp, args):
logger.info("Args: {}".format(args))
# Data, I/O
dataloader = LoadVideo(args.path, args.tsize)
video_name = osp.basename(args.path).split('.')[0]
result_root = osp.join(args.output_root, video_name)
result_filename = os.path.join(result_root, 'results.txt')
args.frame_rate = dataloader.frame_rate
# Detector init
det_model = exp.get_model()
logger.info("Model Summary: {}".format(
get_model_info(det_model, exp.test_size)))
det_model.cuda()
det_model.eval()
logger.info("loading checkpoint")
ckpt = torch.load(args.ckpt, map_location="cpu")
# load the model state dict
det_model.load_state_dict(ckpt["model"])
logger.info("loaded checkpoint done.")
detector = Predictor(det_model, exp, COCO_CLASSES, None, None, 'gpu')
# Tracker init
tracker = BoxAssociationTracker(args)
frame_dir = osp.join(result_root, 'frame')
try:
eval_seq(args, dataloader, detector, tracker, result_filename,
save_dir=frame_dir, show_image=False)
except Exception as e:
print(e)
output_video_path = osp.join(result_root, video_name+'.avi')
cmd_str = 'ffmpeg -f image2 -i {}/%05d.jpg -c:v copy {}'.format(
osp.join(result_root, 'frame'), output_video_path)
os.system(cmd_str)
if __name__ == '__main__':
args = make_parser().parse_args()
with open(args.config) as f:
common_args = yaml.load(f)
for k, v in common_args['common'].items():
setattr(args, k, v)
for k, v in common_args['mot'].items():
setattr(args, k, v)
exp = get_exp(args.exp_file, None)
if args.conf is not None:
args.conf_thres = args.conf
exp.test_conf = args.conf
if args.nms is not None:
exp.nmsthre = args.nms
if args.tsize is not None:
exp.test_size = args.tsize[::-1]
args.img_size = args.tsize
args.classes = [x for x in args.classes]
main(exp, args)
================================================
FILE: demo/sot_demo.py
================================================
# ------------------------------------------------------------------------------
# Copyright (c) Microsoft
# Licensed under the MIT License.
# Written by Zhipeng Zhang (zhangzhipeng2017@ia.ac.cn)
# ------------------------------------------------------------------------------
import os
import pdb
import sys
sys.path[0] = os.getcwd()
import cv2
import yaml
import argparse
from PIL import Image
from glob import glob
from os.path import exists, join
from easydict import EasyDict as edict
import torch
import numpy as np
import tracker.sot.lib.models as models
from tracker.sot.lib.utils.utils import load_dataset, crop_chw, \
gaussian_shaped_labels, cxy_wh_2_rect1, rect1_2_cxy_wh, cxy_wh_2_bbox
from tracker.sot.lib.core.eval_otb import eval_auc_tune
import utils
from model import AppearanceModel, partial_load
from data.vos import color_normalize, load_image, im_to_numpy, im_to_torch
def get_frames(video_name):
if not video_name:
cap = cv2.VideoCapture(0)
# warmup
for i in range(5):
cap.read()
while True:
ret, frame = cap.read()
if ret:
yield frame
else:
break
elif video_name.endswith('avi') or video_name.endswith('mp4'):
cap = cv2.VideoCapture(video_name)
while True:
ret, frame = cap.read()
if ret:
yield frame
else:
break
else:
images = glob(os.path.join(video_name, '*.jp*'))
images = sorted(images,
key=lambda x: int(x.split('/')[-1].split('.')[0]))
for img in images:
frame = cv2.imread(img)
yield frame
def preproc(img, im_mean, im_std, use_lab=False):
img = load_image(img)
if use_lab:
img = im_to_numpy(img)
img = (img*255).astype(np.uint8)[:, :, ::-1]
img = cv2.cvtColor(img, cv2.COLOR_BGR2LAB)
img = im_to_torch(img) / 255.
img = color_normalize(img, im_mean, im_std)
if use_lab:
img = torch.stack([img[0], ]*3)
img = img.permute(1, 2, 0).numpy() # H, W, C
return img
class TrackerConfig(object):
crop_sz = 512 + 8
downscale = 8
temp_sz = crop_sz // downscale
lambda0 = 1e-4
padding = 3.5
interp_factor = 0.01
num_scale = 3
scale_step = 1.0275
scale_factor = scale_step ** (np.arange(num_scale) - num_scale // 2)
min_scale_factor = 0.2
max_scale_factor = 5
scale_penalty = 0.985
scale_penalties = scale_penalty ** (np.abs((np.arange(num_scale) - num_scale // 2)))
net_output_size = [temp_sz, temp_sz]
cos_window = torch.Tensor(np.outer(np.hanning(temp_sz), np.hanning(temp_sz))).cuda()
def track(net, args):
toc = 0
config = TrackerConfig()
video_name = os.path.basename(args.input) if args.input else 'webcam'
regions = [] # FINAL RESULTS
for f, img_raw in enumerate(get_frames(args.input)):
img_raw = cv2.resize(img_raw, (640,480))
use_lab = getattr(args, 'use_lab', False)
im = preproc(img_raw, args.im_mean, args.im_std, use_lab)
tic = cv2.getTickCount()
# Init
if f == 0:
try:
init_rect = cv2.selectROI(video_name, img_raw, False, False)
except Exception:
exit()
target_pos, target_sz = rect1_2_cxy_wh(init_rect)
min_sz = np.maximum(config.min_scale_factor * target_sz, 4)
max_sz = np.minimum(im.shape[:2], config.max_scale_factor * target_sz)
# crop template
window_sz = target_sz * (1 + config.padding)
bbox = cxy_wh_2_bbox(target_pos, window_sz)
patch = crop_chw(im, bbox, config.crop_sz)
target = patch
net.update(torch.Tensor(np.expand_dims(target, axis=0)).cuda(), lr=1)
regions.append(cxy_wh_2_rect1(target_pos, target_sz))
patch_crop = np.zeros((config.num_scale, patch.shape[0],
patch.shape[1], patch.shape[2]), np.float32)
# Track
else:
for i in range(config.num_scale): # crop multi-scale search region
window_sz = target_sz * (config.scale_factor[i] * (1 + config.padding))
bbox = cxy_wh_2_bbox(target_pos, window_sz)
patch_crop[i, :] = crop_chw(im, bbox, config.crop_sz)
search = patch_crop
response = net(torch.Tensor(search).cuda())
net_output_size = [response.shape[-2], response.shape[-1]]
peak, idx = torch.max(response.view(config.num_scale, -1), 1)
peak = peak.data.cpu().numpy() * config.scale_penalties
best_scale = np.argmax(peak)
r_max, c_max = np.unravel_index(idx[best_scale].cpu(), net_output_size)
r_max = r_max - net_output_size[0] * 0.5
c_max = c_max - net_output_size[1] * 0.5
window_sz = target_sz * (config.scale_factor[best_scale] * (1 + config.padding))
target_pos = target_pos + np.array([c_max, r_max]) * window_sz / net_output_size
target_sz = np.minimum(np.maximum(window_sz / (1 + config.padding), min_sz), max_sz)
# model update
window_sz = target_sz * (1 + config.padding)
bbox = cxy_wh_2_bbox(target_pos, window_sz)
patch = crop_chw(im, bbox, config.crop_sz)
target = patch
regions.append(cxy_wh_2_rect1(target_pos, target_sz)) # 1-index
toc += cv2.getTickCount() - tic
bbox = list(map(int, regions[-1]))
cv2.rectangle(img_raw, (bbox[0], bbox[1]),
(bbox[0]+bbox[2], bbox[1]+bbox[3]), (0, 255, 0), 3)
cv2.imshow(video_name, img_raw)
cv2.waitKey(40)
toc /= cv2.getTickFrequency()
def main():
parser = argparse.ArgumentParser()
parser.add_argument('--config', default='', required=True, type=str)
parser.add_argument('--input', required=True, type=str)
args = parser.parse_args()
with open(args.config) as f:
common_args = yaml.load(f)
for k, v in common_args['common'].items():
setattr(args, k, v)
for k, v in common_args['sot'].items():
setattr(args, k, v)
args.arch = 'SiamFC'
# prepare model
base = AppearanceModel(args).to(args.device)
print('Total params: %.2fM' %
(sum(p.numel() for p in base.parameters())/1e6))
print(base)
net = models.__dict__[args.arch](base=base, config=TrackerConfig())
net.eval()
net = net.cuda()
track(net, args)
if __name__ == '__main__':
main()
================================================
FILE: detector/YOLOX/.gitignore
================================================
### Linux ###
*~
# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*
# KDE directory preferences
.directory
# Linux trash folder which might appear on any partition or disk
.Trash-*
# .nfs files are created when an open file is removed but is still being accessed
.nfs*
### PyCharm ###
# User-specific stuff
.idea
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
# JetBrains templates
**___jb_tmp___
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Django stuff:
*.log
local_settings.py
db.sqlite3
# Flask stuff:
instance/
.webassets-cache
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
docs/build/
# PyBuilder
target/
# Jupyter Notebook
.ipynb_checkpoints
# IPython
profile_default/
ipython_config.py
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don’t work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Environments
.env
.venv
env/
venv/
ENV/
env.bak/
venv.bak/
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
### Vim ###
# Swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-rt-v][a-z]
[._]ss[a-gi-z]
[._]sw[a-p]
# Session
Session.vim
# Temporary
.netrwhist
# Auto-generated tag files
tags
# Persistent undo
[._]*.un~
# output
docs/api
.code-workspace.code-workspace
*.pkl
*.npy
*.pth
*.onnx
events.out.tfevents*
# vscode
*.code-workspace
.vscode
# vim
.vim
================================================
FILE: detector/YOLOX/LICENSE
================================================
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "{}"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright 2021 Megvii, Base Detection
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
================================================
FILE: detector/YOLOX/README.md
================================================
<div align="center"><img src="assets/logo.png" width="350"></div>
<img src="assets/demo.png" >
## Introduction
YOLOX is an anchor-free version of YOLO, with a simpler design but better performance! It aims to bridge the gap between research and industrial communities.
For more details, please refer to our [report on Arxiv](https://arxiv.org/abs/2107.08430).
<img src="assets/git_fig.png" width="1000" >
## Updates!!
* 【2021/07/20】 We have released our technical report on [Arxiv](https://arxiv.org/abs/2107.08430).
## Comming soon
- [ ] YOLOX-P6 and larger model.
- [ ] Objects365 pretrain.
- [ ] Transformer modules.
- [ ] More features in need.
## Benchmark
#### Standard Models.
|Model |size |mAP<sup>test<br>0.5:0.95 | Speed V100<br>(ms) | Params<br>(M) |FLOPs<br>(G)| weights |
| ------ |:---: | :---: |:---: |:---: | :---: | :----: |
|[YOLOX-s](./exps/default/yolox_s.py) |640 |39.6 |9.8 |9.0 | 26.8 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EW62gmO2vnNNs5npxjzunVwB9p307qqygaCkXdTO88BLUg?e=NMTQYw)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_s.pth) |
|[YOLOX-m](./exps/default/yolox_m.py) |640 |46.4 |12.3 |25.3 |73.8| [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/ERMTP7VFqrVBrXKMU7Vl4TcBQs0SUeCT7kvc-JdIbej4tQ?e=1MDo9y)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_m.pth) |
|[YOLOX-l](./exps/default/yolox_l.py) |640 |50.0 |14.5 |54.2| 155.6 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EWA8w_IEOzBKvuueBqfaZh0BeoG5sVzR-XYbOJO4YlOkRw?e=wHWOBE)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_l.pth) |
|[YOLOX-x](./exps/default/yolox_x.py) |640 |**51.2** | 17.3 |99.1 |281.9 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EdgVPHBziOVBtGAXHfeHI5kBza0q9yyueMGdT0wXZfI1rQ?e=tABO5u)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_x.pth) |
|[YOLOX-Darknet53](./exps/default/yolov3.py) |640 | 47.4 | 11.1 |63.7 | 185.3 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EZ-MV1r_fMFPkPrNjvbJEMoBLOLAnXH-XKEB77w8LhXL6Q?e=mf6wOc)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_darknet53.pth) |
#### Light Models.
|Model |size |mAP<sup>val<br>0.5:0.95 | Params<br>(M) |FLOPs<br>(G)| weights |
| ------ |:---: | :---: |:---: |:---: | :---: |
|[YOLOX-Nano](./exps/default/nano.py) |416 |25.3 | 0.91 |1.08 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EdcREey-krhLtdtSnxolxiUBjWMy6EFdiaO9bdOwZ5ygCQ?e=yQpdds)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_nano.pth) |
|[YOLOX-Tiny](./exps/default/yolox_tiny.py) |416 |31.7 | 5.06 |6.45 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EYtjNFPqvZBBrQ-VowLcSr4B6Z5TdTflUsr_gO2CwhC3bQ?e=SBTwXj)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_tiny.pth) |
## Quick Start
<details>
<summary>Installation</summary>
Step1. Install YOLOX.
```shell
git clone git@github.com:Megvii-BaseDetection/YOLOX.git
cd YOLOX
pip3 install -U pip && pip3 install -r requirements.txt
pip3 install -v -e . # or python3 setup.py develop
```
Step2. Install [apex](https://github.com/NVIDIA/apex).
```shell
# skip this step if you don't want to train model.
git clone https://github.com/NVIDIA/apex
cd apex
pip3 install -v --disable-pip-version-check --no-cache-dir --global-option="--cpp_ext" --global-option="--cuda_ext" ./
```
Step3. Install [pycocotools](https://github.com/cocodataset/cocoapi).
```shell
pip3 install cython; pip3 install 'git+https://github.com/cocodataset/cocoapi.git#subdirectory=PythonAPI'
```
</details>
<details>
<summary>Demo</summary>
Step1. Download a pretrained model from the benchmark table.
Step2. Use either -n or -f to specify your detector's config. For example:
```shell
python tools/demo.py image -n yolox-s -c /path/to/your/yolox_s.pth.tar --path assets/dog.jpg --conf 0.3 --nms 0.65 --tsize 640 --save_result --device [cpu/gpu]
```
or
```shell
python tools/demo.py image -f exps/default/yolox_s.py -c /path/to/your/yolox_s.pth.tar --path assets/dog.jpg --conf 0.3 --nms 0.65 --tsize 640 --save_result --device [cpu/gpu]
```
Demo for video:
```shell
python tools/demo.py video -n yolox-s -c /path/to/your/yolox_s.pth.tar --path /path/to/your/video --conf 0.3 --nms 0.65 --tsize 640 --save_result --device [cpu/gpu]
```
</details>
<details>
<summary>Reproduce our results on COCO</summary>
Step1. Prepare COCO dataset
```shell
cd <YOLOX_HOME>
ln -s /path/to/your/COCO ./datasets/COCO
```
Step2. Reproduce our results on COCO by specifying -n:
```shell
python tools/train.py -n yolox-s -d 8 -b 64 --fp16 -o
yolox-m
yolox-l
yolox-x
```
* -d: number of gpu devices
* -b: total batch size, the recommended number for -b is num-gpu * 8
* --fp16: mixed precision training
When using -f, the above commands are equivalent to:
```shell
python tools/train.py -f exps/default/yolox-s.py -d 8 -b 64 --fp16 -o
exps/default/yolox-m.py
exps/default/yolox-l.py
exps/default/yolox-x.py
```
</details>
<details>
<summary>Evaluation</summary>
We support batch testing for fast evaluation:
```shell
python tools/eval.py -n yolox-s -c yolox_s.pth.tar -b 64 -d 8 --conf 0.001 [--fp16] [--fuse]
yolox-m
yolox-l
yolox-x
```
* --fuse: fuse conv and bn
* -d: number of GPUs used for evaluation. DEFAULT: All GPUs available will be used.
* -b: total batch size across on all GPUs
To reproduce speed test, we use the following command:
```shell
python tools/eval.py -n yolox-s -c yolox_s.pth.tar -b 1 -d 1 --conf 0.001 --fp16 --fuse
yolox-m
yolox-l
yolox-x
```
</details>
<details open>
<summary>Tutorials</summary>
* [Training on custom data](docs/train_custom_data.md).
</details>
## Deployment
1. [ONNX export and an ONNXRuntime](./demo/ONNXRuntime)
2. [TensorRT in C++ and Python](./demo/TensorRT)
3. [ncnn in C++ and Java](./demo/ncnn)
4. [OpenVINO in C++ and Python](./demo/OpenVINO)
## Third-party resources
* The ncnn android app with video support: [ncnn-android-yolox](https://github.com/FeiGeChuanShu/ncnn-android-yolox) from [FeiGeChuanShu](https://github.com/FeiGeChuanShu)
* YOLOX with Tengine support: [Tengine](https://github.com/OAID/Tengine/blob/tengine-lite/examples/tm_yolox.cpp) from [BUG1989](https://github.com/BUG1989)
* YOLOX + ROS2 Foxy: [YOLOX-ROS](https://github.com/Ar-Ray-code/YOLOX-ROS) from [Ar-Ray](https://github.com/Ar-Ray-code)
* YOLOX Deploy DeepStream: [YOLOX-deepstream](https://github.com/nanmi/YOLOX-deepstream) from [nanmi](https://github.com/nanmi)
* YOLOX ONNXRuntime C++ Demo: [lite.ai](https://github.com/DefTruth/lite.ai/blob/main/ort/cv/yolox.cpp) from [DefTruth](https://github.com/DefTruth)
## Cite YOLOX
If you use YOLOX in your research, please cite our work by using the following BibTeX entry:
```latex
@article{yolox2021,
title={YOLOX: Exceeding YOLO Series in 2021},
author={Ge, Zheng and Liu, Songtao and Wang, Feng and Li, Zeming and Sun, Jian},
journal={arXiv preprint arXiv:2107.08430},
year={2021}
}
```
================================================
FILE: detector/YOLOX/datasets/README.md
================================================
# Prepare datasets
If you have a dataset directory, you could use os environment variable named `YOLOX_DATADIR`. Under this directory, YOLOX will look for datasets in the structure described below, if needed.
```
$YOLOX_DATADIR/
COCO/
```
You can set the location for builtin datasets by
```shell
export YOLOX_DATADIR=/path/to/your/datasets
```
If `YOLOX_DATADIR` is not set, the default value of dataset directory is `./datasets` relative to your current working directory.
## Expected dataset structure for [COCO detection](https://cocodataset.org/#download):
```
COCO/
annotations/
instances_{train,val}2017.json
{train,val}2017/
# image files that are mentioned in the corresponding json
```
You can use the 2014 version of the dataset as well.
================================================
FILE: detector/YOLOX/demo/ONNXRuntime/README.md
================================================
## YOLOX-ONNXRuntime in Python
This doc introduces how to convert your pytorch model into onnx, and how to run an onnxruntime demo to verify your convertion.
### Download ONNX models.
| Model | Parameters | GFLOPs | Test Size | mAP | Weights |
|:------| :----: | :----: | :---: | :---: | :---: |
| YOLOX-Nano | 0.91M | 1.08 | 416x416 | 25.3 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EfAGwvevU-lNhW5OqFAyHbwBJdI_7EaKu5yU04fgF5BU7w?e=gvq4hf)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_nano.onnx) |
| YOLOX-Tiny | 5.06M | 6.45 | 416x416 |31.7 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EVigCszU1ilDn-MwLwHCF1ABsgTy06xFdVgZ04Yyo4lHVA?e=hVKiCw)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_tiny.onnx) |
| YOLOX-S | 9.0M | 26.8 | 640x640 |39.6 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/Ec0L1d1x2UtIpbfiahgxhtgBZVjb1NCXbotO8SCOdMqpQQ?e=siyIsK)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_s.onnx) |
| YOLOX-M | 25.3M | 73.8 | 640x640 |46.4 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/ERUKlQe-nlxBoTKPy1ynbxsBmAZ_h-VBEV-nnfPdzUIkZQ?e=hyQQtl)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_m.onnx) |
| YOLOX-L | 54.2M | 155.6 | 640x640 |50.0 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/ET5w926jCA5GlVfg9ixB4KEBiW0HYl7SzaHNRaRG9dYO_A?e=ISmCYX)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_l.onnx) |
| YOLOX-Darknet53| 63.72M | 185.3 | 640x640 |47.3 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/ESArloSW-MlPlLuemLh9zKkBdovgweKbfu4zkvzKAp7pPQ?e=f81Ikw)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_darknet53.onnx) |
| YOLOX-X | 99.1M | 281.9 | 640x640 |51.2 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/ERjqoeMJlFdGuM3tQfXQmhABmGHlIHydWCwhlugeWLE9AA)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox.onnx) |
### Convert Your Model to ONNX
First, you should move to <YOLOX_HOME> by:
```shell
cd <YOLOX_HOME>
```
Then, you can:
1. Convert a standard YOLOX model by -n:
```shell
python3 tools/export_onnx.py --output-name yolox_s.onnx -n yolox-s -c yolox_s.pth.tar
```
Notes:
* -n: specify a model name. The model name must be one of the [yolox-s,m,l,x and yolox-nane, yolox-tiny, yolov3]
* -c: the model you have trained
* -o: opset version, default 11. **However, if you will further convert your onnx model to [OpenVINO](../OpenVINO/), please specify the opset version to 10.**
* --no-onnxsim: disable onnxsim
* To customize an input shape for onnx model, modify the following code in tools/export.py:
```python
dummy_input = torch.randn(1, 3, exp.test_size[0], exp.test_size[1])
```
2. Convert a standard YOLOX model by -f. When using -f, the above command is equivalent to:
```shell
python3 tools/export_onnx.py --output-name yolox_s.onnx -f exps/default/yolox_s.py -c yolox_s.pth.tar
```
3. To convert your customized model, please use -f:
```shell
python3 tools/export_onnx.py --output-name your_yolox.onnx -f exps/your_dir/your_yolox.py -c your_yolox.pth.tar
```
### ONNXRuntime Demo
Step1.
```shell
cd <YOLOX_HOME>/demo/ONNXRuntime
```
Step2.
```shell
python3 onnx_inference.py -m <ONNX_MODEL_PATH> -i <IMAGE_PATH> -o <OUTPUT_DIR> -s 0.3 --input_shape 640,640
```
Notes:
* -m: your converted onnx model
* -i: input_image
* -s: score threshold for visualization.
* --input_shape: should be consistent with the shape you used for onnx convertion.
================================================
FILE: detector/YOLOX/demo/ONNXRuntime/onnx_inference.py
================================================
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (c) Megvii, Inc. and its affiliates.
import argparse
import os
import cv2
import numpy as np
import onnxruntime
from yolox.data.data_augment import preproc as preprocess
from yolox.data.datasets import COCO_CLASSES
from yolox.utils import mkdir, multiclass_nms, demo_postprocess, vis
def make_parser():
parser = argparse.ArgumentParser("onnxruntime inference sample")
parser.add_argument(
"-m",
"--model",
type=str,
default="yolox.onnx",
help="Input your onnx model.",
)
parser.add_argument(
"-i",
"--image_path",
type=str,
default='test_image.png',
help="Path to your input image.",
)
parser.add_argument(
"-o",
"--output_dir",
type=str,
default='demo_output',
help="Path to your output directory.",
)
parser.add_argument(
"-s",
"--score_thr",
type=float,
default=0.3,
help="Score threshould to filter the result.",
)
parser.add_argument(
"--input_shape",
type=str,
default="640,640",
help="Specify an input shape for inference.",
)
parser.add_argument(
"--with_p6",
action="store_true",
help="Whether your model uses p6 in FPN/PAN.",
)
return parser
if __name__ == '__main__':
args = make_parser().parse_args()
input_shape = tuple(map(int, args.input_shape.split(',')))
origin_img = cv2.imread(args.image_path)
mean = (0.485, 0.456, 0.406)
std = (0.229, 0.224, 0.225)
img, ratio = preprocess(origin_img, input_shape, mean, std)
session = onnxruntime.InferenceSession(args.model)
ort_inputs = {session.get_inputs()[0].name: img[None, :, :, :]}
output = session.run(None, ort_inputs)
predictions = demo_postprocess(output[0], input_shape, p6=args.with_p6)[0]
boxes = predictions[:, :4]
scores = predictions[:, 4:5] * predictions[:, 5:]
boxes_xyxy = np.ones_like(boxes)
boxes_xyxy[:, 0] = boxes[:, 0] - boxes[:, 2]/2.
boxes_xyxy[:, 1] = boxes[:, 1] - boxes[:, 3]/2.
boxes_xyxy[:, 2] = boxes[:, 0] + boxes[:, 2]/2.
boxes_xyxy[:, 3] = boxes[:, 1] + boxes[:, 3]/2.
boxes_xyxy /= ratio
dets = multiclass_nms(boxes_xyxy, scores, nms_thr=0.65, score_thr=0.1)
if dets is not None:
final_boxes, final_scores, final_cls_inds = dets[:, :4], dets[:, 4], dets[:, 5]
origin_img = vis(origin_img, final_boxes, final_scores, final_cls_inds,
conf=args.score_thr, class_names=COCO_CLASSES)
mkdir(args.output_dir)
output_path = os.path.join(args.output_dir, args.image_path.split("/")[-1])
cv2.imwrite(output_path, origin_img)
================================================
FILE: detector/YOLOX/demo/OpenVINO/README.md
================================================
## YOLOX for OpenVINO
* [C++ Demo](./cpp)
* [Python Demo](./python)
================================================
FILE: detector/YOLOX/demo/OpenVINO/cpp/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 3.4.1)
set(CMAKE_CXX_STANDARD 14)
project(yolox_openvino_demo)
find_package(OpenCV REQUIRED)
find_package(InferenceEngine REQUIRED)
find_package(ngraph REQUIRED)
include_directories(
${OpenCV_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_BINARY_DIR}
)
add_executable(yolox_openvino yolox_openvino.cpp)
target_link_libraries(
yolox_openvino
${InferenceEngine_LIBRARIES}
${NGRAPH_LIBRARIES}
${OpenCV_LIBS}
)
================================================
FILE: detector/YOLOX/demo/OpenVINO/cpp/README.md
================================================
# YOLOX-OpenVINO in C++
This toturial includes a C++ demo for OpenVINO, as well as some converted models.
### Download OpenVINO models.
| Model | Parameters | GFLOPs | Test Size | mAP | Weights |
|:------| :----: | :----: | :---: | :---: | :---: |
| [YOLOX-Nano](../../../exps/nano.py) | 0.91M | 1.08 | 416x416 | 25.3 | [Download](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EeWY57o5wQZFtXYd1KJw6Z8B4vxZru649XxQHYIFgio3Qw?e=ZS81ce)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_nano_openvino.tar.gz) |
| [YOLOX-Tiny](../../../exps/yolox_tiny.py) | 5.06M | 6.45 | 416x416 |31.7 | [Download](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/ETfvOoCXdVZNinoSpKA_sEYBIQVqfjjF5_M6VvHRnLVcsA?e=STL1pi)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_tiny_openvino.tar.gz) |
| [YOLOX-S](../../../exps/yolox_s.py) | 9.0M | 26.8 | 640x640 |39.6 | [Download](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EXUjf3PQnbBLrxNrXPueqaIBzVZOrYQOnJpLK1Fytj5ssA?e=GK0LOM)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_s_openvino.tar.gz) |
| [YOLOX-M](../../../exps/yolox_m.py) | 25.3M | 73.8 | 640x640 |46.4 | [Download](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EcoT1BPpeRpLvE_4c441zn8BVNCQ2naxDH3rho7WqdlgLQ?e=95VaM9)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_m_openvino.tar.gz) |
| [YOLOX-L](../../../exps/yolox_l.py) | 54.2M | 155.6 | 640x640 |50.0 | [Download](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EZvmn-YLRuVPh0GAP_w3xHMB2VGvrKqQXyK_Cv5yi_DXUg?e=YRh6Eq)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_l_openvino.tar.gz) |
| [YOLOX-Darknet53](../../../exps/yolov3.py) | 63.72M | 185.3 | 640x640 |47.3 | [Download](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EQP8LSroikFHuwX0jFRetmcBOCDWSFmylHxolV7ezUPXGw?e=bEw5iq)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_darknet53_openvino.tar.gz) |
| [YOLOX-X](../../../exps/yolox_x.py) | 99.1M | 281.9 | 640x640 |51.2 | [Download](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EZFPnLqiD-xIlt7rcZYDjQgB4YXE9wnq1qaSXQwJrsKbdg?e=83nwEz)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_x_openvino.tar.gz) |
## Install OpenVINO Toolkit
Please visit [Openvino Homepage](https://docs.openvinotoolkit.org/latest/get_started_guides.html) for more details.
## Set up the Environment
### For Linux
**Option1. Set up the environment tempororally. You need to run this command everytime you start a new shell window.**
```shell
source /opt/intel/openvino_2021/bin/setupvars.sh
```
**Option2. Set up the environment permenantly.**
*Step1.* For Linux:
```shell
vim ~/.bashrc
```
*Step2.* Add the following line into your file:
```shell
source /opt/intel/openvino_2021/bin/setupvars.sh
```
*Step3.* Save and exit the file, then run:
```shell
source ~/.bashrc
```
## Convert model
1. Export ONNX model
Please refer to the [ONNX toturial](../../ONNXRuntime). **Note that you should set --opset to 10, otherwise your next step will fail.**
2. Convert ONNX to OpenVINO
``` shell
cd <INSTSLL_DIR>/openvino_2021/deployment_tools/model_optimizer
```
Install requirements for convert tool
```shell
sudo ./install_prerequisites/install_prerequisites_onnx.sh
```
Then convert model.
```shell
python3 mo.py --input_model <ONNX_MODEL> --input_shape <INPUT_SHAPE> [--data_type FP16]
```
For example:
```shell
python3 mo.py --input_model yolox.onnx --input_shape (1,3,640,640) --data_type FP16
```
## Build
### Linux
```shell
source /opt/intel/openvino_2021/bin/setupvars.sh
mkdir build
cd build
cmake ..
make
```
## Demo
### c++
```shell
./yolox_openvino <XML_MODEL_PATH> <IMAGE_PATH> <DEVICE>
```
================================================
FILE: detector/YOLOX/demo/OpenVINO/cpp/yolox_openvino.cpp
================================================
// Copyright (C) 2018-2021 Intel Corporation
// SPDX-License-Identifier: Apache-2.0
//
#include <iterator>
#include <memory>
#include <string>
#include <vector>
#include <opencv2/opencv.hpp>
#include <iostream>
#include <inference_engine.hpp>
using namespace InferenceEngine;
/**
* @brief Define names based depends on Unicode path support
*/
#define tcout std::cout
#define file_name_t std::string
#define imread_t cv::imread
#define NMS_THRESH 0.65
#define BBOX_CONF_THRESH 0.3
static const int INPUT_W = 416;
static const int INPUT_H = 416;
cv::Mat static_resize(cv::Mat& img) {
float r = std::min(INPUT_W / (img.cols*1.0), INPUT_H / (img.rows*1.0));
// r = std::min(r, 1.0f);
int unpad_w = r * img.cols;
int unpad_h = r * img.rows;
cv::Mat re(unpad_h, unpad_w, CV_8UC3);
cv::resize(img, re, re.size());
cv::Mat out(INPUT_W, INPUT_H, CV_8UC3, cv::Scalar(114, 114, 114));
re.copyTo(out(cv::Rect(0, 0, re.cols, re.rows)));
return out;
}
void blobFromImage(cv::Mat& img, Blob::Ptr& blob){
cv::cvtColor(img, img, cv::COLOR_BGR2RGB);
int channels = 3;
int img_h = img.rows;
int img_w = img.cols;
std::vector<float> mean = {0.485, 0.456, 0.406};
std::vector<float> std = {0.229, 0.224, 0.225};
InferenceEngine::MemoryBlob::Ptr mblob = InferenceEngine::as<InferenceEngine::MemoryBlob>(blob);
if (!mblob)
{
THROW_IE_EXCEPTION << "We expect blob to be inherited from MemoryBlob in matU8ToBlob, "
<< "but by fact we were not able to cast inputBlob to MemoryBlob";
}
// locked memory holder should be alive all time while access to its buffer happens
auto mblobHolder = mblob->wmap();
float *blob_data = mblobHolder.as<float *>();
for (size_t c = 0; c < channels; c++)
{
for (size_t h = 0; h < img_h; h++)
{
for (size_t w = 0; w < img_w; w++)
{
blob_data[c * img_w * img_h + h * img_w + w] =
(((float)img.at<cv::Vec3b>(h, w)[c]) / 255.0f - mean[c]) / std[c];
}
}
}
}
struct Object
{
cv::Rect_<float> rect;
int label;
float prob;
};
struct GridAndStride
{
int grid0;
int grid1;
int stride;
};
static void generate_grids_and_stride(const int target_size, std::vector<int>& strides, std::vector<GridAndStride>& grid_strides)
{
for (auto stride : strides)
{
int num_grid = target_size / stride;
for (int g1 = 0; g1 < num_grid; g1++)
{
for (int g0 = 0; g0 < num_grid; g0++)
{
grid_strides.push_back((GridAndStride){g0, g1, stride});
}
}
}
}
static void generate_yolox_proposals(std::vector<GridAndStride> grid_strides, const float* feat_ptr, float prob_threshold, std::vector<Object>& objects)
{
const int num_class = 80; // COCO has 80 classes. Modify this value on your own dataset.
const int num_anchors = grid_strides.size();
for (int anchor_idx = 0; anchor_idx < num_anchors; anchor_idx++)
{
const int grid0 = grid_strides[anchor_idx].grid0;
const int grid1 = grid_strides[anchor_idx].grid1;
const int stride = grid_strides[anchor_idx].stride;
const int basic_pos = anchor_idx * 85;
// yolox/models/yolo_head.py decode logic
// outputs[..., :2] = (outputs[..., :2] + grids) * strides
// outputs[..., 2:4] = torch.exp(outputs[..., 2:4]) * strides
float x_center = (feat_ptr[basic_pos + 0] + grid0) * stride;
float y_center = (feat_ptr[basic_pos + 1] + grid1) * stride;
float w = exp(feat_ptr[basic_pos + 2]) * stride;
float h = exp(feat_ptr[basic_pos + 3]) * stride;
float x0 = x_center - w * 0.5f;
float y0 = y_center - h * 0.5f;
float box_objectness = feat_ptr[basic_pos + 4];
for (int class_idx = 0; class_idx < num_class; class_idx++)
{
float box_cls_score = feat_ptr[basic_pos + 5 + class_idx];
float box_prob = box_objectness * box_cls_score;
if (box_prob > prob_threshold)
{
Object obj;
obj.rect.x = x0;
obj.rect.y = y0;
obj.rect.width = w;
obj.rect.height = h;
obj.label = class_idx;
obj.prob = box_prob;
objects.push_back(obj);
}
} // class loop
} // point anchor loop
}
static inline float intersection_area(const Object& a, const Object& b)
{
cv::Rect_<float> inter = a.rect & b.rect;
return inter.area();
}
static void qsort_descent_inplace(std::vector<Object>& faceobjects, int left, int right)
{
int i = left;
int j = right;
float p = faceobjects[(left + right) / 2].prob;
while (i <= j)
{
while (faceobjects[i].prob > p)
i++;
while (faceobjects[j].prob < p)
j--;
if (i <= j)
{
// swap
std::swap(faceobjects[i], faceobjects[j]);
i++;
j--;
}
}
#pragma omp parallel sections
{
#pragma omp section
{
if (left < j) qsort_descent_inplace(faceobjects, left, j);
}
#pragma omp section
{
if (i < right) qsort_descent_inplace(faceobjects, i, right);
}
}
}
static void qsort_descent_inplace(std::vector<Object>& objects)
{
if (objects.empty())
return;
qsort_descent_inplace(objects, 0, objects.size() - 1);
}
static void nms_sorted_bboxes(const std::vector<Object>& faceobjects, std::vector<int>& picked, float nms_threshold)
{
picked.clear();
const int n = faceobjects.size();
std::vector<float> areas(n);
for (int i = 0; i < n; i++)
{
areas[i] = faceobjects[i].rect.area();
}
for (int i = 0; i < n; i++)
{
const Object& a = faceobjects[i];
int keep = 1;
for (int j = 0; j < (int)picked.size(); j++)
{
const Object& b = faceobjects[picked[j]];
// intersection over union
float inter_area = intersection_area(a, b);
float union_area = areas[i] + areas[picked[j]] - inter_area;
// float IoU = inter_area / union_area
if (inter_area / union_area > nms_threshold)
keep = 0;
}
if (keep)
picked.push_back(i);
}
}
static void decode_outputs(const float* prob, std::vector<Object>& objects, float scale, const int img_w, const int img_h) {
std::vector<Object> proposals;
std::vector<int> strides = {8, 16, 32};
std::vector<GridAndStride> grid_strides;
generate_grids_and_stride(INPUT_W, strides, grid_strides);
generate_yolox_proposals(grid_strides, prob, BBOX_CONF_THRESH, proposals);
qsort_descent_inplace(proposals);
std::vector<int> picked;
nms_sorted_bboxes(proposals, picked, NMS_THRESH);
int count = picked.size();
objects.resize(count);
for (int i = 0; i < count; i++)
{
objects[i] = proposals[picked[i]];
// adjust offset to original unpadded
float x0 = (objects[i].rect.x) / scale;
float y0 = (objects[i].rect.y) / scale;
float x1 = (objects[i].rect.x + objects[i].rect.width) / scale;
float y1 = (objects[i].rect.y + objects[i].rect.height) / scale;
// clip
x0 = std::max(std::min(x0, (float)(img_w - 1)), 0.f);
y0 = std::max(std::min(y0, (float)(img_h - 1)), 0.f);
x1 = std::max(std::min(x1, (float)(img_w - 1)), 0.f);
y1 = std::max(std::min(y1, (float)(img_h - 1)), 0.f);
objects[i].rect.x = x0;
objects[i].rect.y = y0;
objects[i].rect.width = x1 - x0;
objects[i].rect.height = y1 - y0;
}
}
const float color_list[80][3] =
{
{0.000, 0.447, 0.741},
{0.850, 0.325, 0.098},
{0.929, 0.694, 0.125},
{0.494, 0.184, 0.556},
{0.466, 0.674, 0.188},
{0.301, 0.745, 0.933},
{0.635, 0.078, 0.184},
{0.300, 0.300, 0.300},
{0.600, 0.600, 0.600},
{1.000, 0.000, 0.000},
{1.000, 0.500, 0.000},
{0.749, 0.749, 0.000},
{0.000, 1.000, 0.000},
{0.000, 0.000, 1.000},
{0.667, 0.000, 1.000},
{0.333, 0.333, 0.000},
{0.333, 0.667, 0.000},
{0.333, 1.000, 0.000},
{0.667, 0.333, 0.000},
{0.667, 0.667, 0.000},
{0.667, 1.000, 0.000},
{1.000, 0.333, 0.000},
{1.000, 0.667, 0.000},
{1.000, 1.000, 0.000},
{0.000, 0.333, 0.500},
{0.000, 0.667, 0.500},
{0.000, 1.000, 0.500},
{0.333, 0.000, 0.500},
{0.333, 0.333, 0.500},
{0.333, 0.667, 0.500},
{0.333, 1.000, 0.500},
{0.667, 0.000, 0.500},
{0.667, 0.333, 0.500},
{0.667, 0.667, 0.500},
{0.667, 1.000, 0.500},
{1.000, 0.000, 0.500},
{1.000, 0.333, 0.500},
{1.000, 0.667, 0.500},
{1.000, 1.000, 0.500},
{0.000, 0.333, 1.000},
{0.000, 0.667, 1.000},
{0.000, 1.000, 1.000},
{0.333, 0.000, 1.000},
{0.333, 0.333, 1.000},
{0.333, 0.667, 1.000},
{0.333, 1.000, 1.000},
{0.667, 0.000, 1.000},
{0.667, 0.333, 1.000},
{0.667, 0.667, 1.000},
{0.667, 1.000, 1.000},
{1.000, 0.000, 1.000},
{1.000, 0.333, 1.000},
{1.000, 0.667, 1.000},
{0.333, 0.000, 0.000},
{0.500, 0.000, 0.000},
{0.667, 0.000, 0.000},
{0.833, 0.000, 0.000},
{1.000, 0.000, 0.000},
{0.000, 0.167, 0.000},
{0.000, 0.333, 0.000},
{0.000, 0.500, 0.000},
{0.000, 0.667, 0.000},
{0.000, 0.833, 0.000},
{0.000, 1.000, 0.000},
{0.000, 0.000, 0.167},
{0.000, 0.000, 0.333},
{0.000, 0.000, 0.500},
{0.000, 0.000, 0.667},
{0.000, 0.000, 0.833},
{0.000, 0.000, 1.000},
{0.000, 0.000, 0.000},
{0.143, 0.143, 0.143},
{0.286, 0.286, 0.286},
{0.429, 0.429, 0.429},
{0.571, 0.571, 0.571},
{0.714, 0.714, 0.714},
{0.857, 0.857, 0.857},
{0.000, 0.447, 0.741},
{0.314, 0.717, 0.741},
{0.50, 0.5, 0}
};
static void draw_objects(const cv::Mat& bgr, const std::vector<Object>& objects)
{
static const char* class_names[] = {
"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
"microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
"hair drier", "toothbrush"
};
cv::Mat image = bgr.clone();
for (size_t i = 0; i < objects.size(); i++)
{
const Object& obj = objects[i];
fprintf(stderr, "%d = %.5f at %.2f %.2f %.2f x %.2f\n", obj.label, obj.prob,
obj.rect.x, obj.rect.y, obj.rect.width, obj.rect.height);
cv::Scalar color = cv::Scalar(color_list[obj.label][0], color_list[obj.label][1], color_list[obj.label][2]);
float c_mean = cv::mean(color)[0];
cv::Scalar txt_color;
if (c_mean > 0.5){
txt_color = cv::Scalar(0, 0, 0);
}else{
txt_color = cv::Scalar(255, 255, 255);
}
cv::rectangle(image, obj.rect, color * 255, 2);
char text[256];
sprintf(text, "%s %.1f%%", class_names[obj.label], obj.prob * 100);
int baseLine = 0;
cv::Size label_size = cv::getTextSize(text, cv::FONT_HERSHEY_SIMPLEX, 0.4, 1, &baseLine);
cv::Scalar txt_bk_color = color * 0.7 * 255;
int x = obj.rect.x;
int y = obj.rect.y + 1;
//int y = obj.rect.y - label_size.height - baseLine;
if (y > image.rows)
y = image.rows;
//if (x + label_size.width > image.cols)
//x = image.cols - label_size.width;
cv::rectangle(image, cv::Rect(cv::Point(x, y), cv::Size(label_size.width, label_size.height + baseLine)),
txt_bk_color, -1);
cv::putText(image, text, cv::Point(x, y + label_size.height),
cv::FONT_HERSHEY_SIMPLEX, 0.4, txt_color, 1);
}
cv::imwrite("_demo.jpg" , image);
fprintf(stderr, "save vis file\n");
/* cv::imshow("image", image); */
/* cv::waitKey(0); */
}
int main(int argc, char* argv[]) {
try {
// ------------------------------ Parsing and validation of input arguments
// ---------------------------------
if (argc != 4) {
tcout << "Usage : " << argv[0] << " <path_to_model> <path_to_image> <device_name>" << std::endl;
return EXIT_FAILURE;
}
const file_name_t input_model {argv[1]};
const file_name_t input_image_path {argv[2]};
const std::string device_name {argv[3]};
// -----------------------------------------------------------------------------------------------------
// --------------------------- Step 1. Initialize inference engine core
// -------------------------------------
Core ie;
// -----------------------------------------------------------------------------------------------------
// Step 2. Read a model in OpenVINO Intermediate Representation (.xml and
// .bin files) or ONNX (.onnx file) format
CNNNetwork network = ie.ReadNetwork(input_model);
if (network.getOutputsInfo().size() != 1)
throw std::logic_error("Sample supports topologies with 1 output only");
if (network.getInputsInfo().size() != 1)
throw std::logic_error("Sample supports topologies with 1 input only");
// -----------------------------------------------------------------------------------------------------
// --------------------------- Step 3. Configure input & output
// ---------------------------------------------
// --------------------------- Prepare input blobs
// -----------------------------------------------------
InputInfo::Ptr input_info = network.getInputsInfo().begin()->second;
std::string input_name = network.getInputsInfo().begin()->first;
/* Mark input as resizable by setting of a resize algorithm.
* In this case we will be able to set an input blob of any shape to an
* infer request. Resize and layout conversions are executed automatically
* during inference */
//input_info->getPreProcess().setResizeAlgorithm(RESIZE_BILINEAR);
//input_info->setLayout(Layout::NHWC);
//input_info->setPrecision(Precision::FP32);
// --------------------------- Prepare output blobs
// ----------------------------------------------------
if (network.getOutputsInfo().empty()) {
std::cerr << "Network outputs info is empty" << std::endl;
return EXIT_FAILURE;
}
DataPtr output_info = network.getOutputsInfo().begin()->second;
std::string output_name = network.getOutputsInfo().begin()->first;
output_info->setPrecision(Precision::FP32);
// -----------------------------------------------------------------------------------------------------
// --------------------------- Step 4. Loading a model to the device
// ------------------------------------------
ExecutableNetwork executable_network = ie.LoadNetwork(network, device_name);
// -----------------------------------------------------------------------------------------------------
// --------------------------- Step 5. Create an infer request
// -------------------------------------------------
InferRequest infer_request = executable_network.CreateInferRequest();
// -----------------------------------------------------------------------------------------------------
// --------------------------- Step 6. Prepare input
// --------------------------------------------------------
/* Read input image to a blob and set it to an infer request without resize
* and layout conversions. */
cv::Mat image = imread_t(input_image_path);
cv::Mat pr_img = static_resize(image);
Blob::Ptr imgBlob = infer_request.GetBlob(input_name); // just wrap Mat data by Blob::Ptr
blobFromImage(pr_img, imgBlob);
// infer_request.SetBlob(input_name, imgBlob); // infer_request accepts input blob of any size
// -----------------------------------------------------------------------------------------------------
// --------------------------- Step 7. Do inference
// --------------------------------------------------------
/* Running the request synchronously */
infer_request.Infer();
// -----------------------------------------------------------------------------------------------------
// --------------------------- Step 8. Process output
// ------------------------------------------------------
const Blob::Ptr output_blob = infer_request.GetBlob(output_name);
MemoryBlob::CPtr moutput = as<MemoryBlob>(output_blob);
if (!moutput) {
throw std::logic_error("We expect output to be inherited from MemoryBlob, "
"but by fact we were not able to cast output to MemoryBlob");
}
// locked memory holder should be alive all time while access to its buffer
// happens
auto moutputHolder = moutput->rmap();
const float* net_pred = moutputHolder.as<const PrecisionTrait<Precision::FP32>::value_type*>();
const int image_size = 416;
int img_w = image.cols;
int img_h = image.rows;
float scale = std::min(INPUT_W / (image.cols*1.0), INPUT_H / (image.rows*1.0));
std::vector<Object> objects;
decode_outputs(net_pred, objects, scale, img_w, img_h);
draw_objects(image, objects);
// -----------------------------------------------------------------------------------------------------
} catch (const std::exception& ex) {
std::cerr << ex.what() << std::endl;
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
================================================
FILE: detector/YOLOX/demo/OpenVINO/python/README.md
================================================
# YOLOX-OpenVINO in Python
This toturial includes a Python demo for OpenVINO, as well as some converted models.
### Download OpenVINO models.
| Model | Parameters | GFLOPs | Test Size | mAP | Weights |
|:------| :----: | :----: | :---: | :---: | :---: |
| [YOLOX-Nano](../../../exps/default/nano.py) | 0.91M | 1.08 | 416x416 | 25.3 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EeWY57o5wQZFtXYd1KJw6Z8B4vxZru649XxQHYIFgio3Qw?e=ZS81ce)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_nano_openvino.tar.gz) |
| [YOLOX-Tiny](../../../exps/default/yolox_tiny.py) | 5.06M | 6.45 | 416x416 |31.7 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/ETfvOoCXdVZNinoSpKA_sEYBIQVqfjjF5_M6VvHRnLVcsA?e=STL1pi)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_tiny_openvino.tar.gz) |
| [YOLOX-S](../../../exps/default/yolox_s.py) | 9.0M | 26.8 | 640x640 |39.6 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EXUjf3PQnbBLrxNrXPueqaIBzVZOrYQOnJpLK1Fytj5ssA?e=GK0LOM)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_s_openvino.tar.gz) |
| [YOLOX-M](../../../exps/default/yolox_m.py) | 25.3M | 73.8 | 640x640 |46.4 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EcoT1BPpeRpLvE_4c441zn8BVNCQ2naxDH3rho7WqdlgLQ?e=95VaM9)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_m_openvino.tar.gz) |
| [YOLOX-L](../../../exps/default/yolox_l.py) | 54.2M | 155.6 | 640x640 |50.0 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EZvmn-YLRuVPh0GAP_w3xHMB2VGvrKqQXyK_Cv5yi_DXUg?e=YRh6Eq)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_l_openvino.tar.gz) |
| [YOLOX-Darknet53](../../../exps/default/yolov3.py) | 63.72M | 185.3 | 640x640 |47.3 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EQP8LSroikFHuwX0jFRetmcBOCDWSFmylHxolV7ezUPXGw?e=bEw5iq)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_darknet53_openvino.tar.gz) |
| [YOLOX-X](../../../exps/default/yolox_x.py) | 99.1M | 281.9 | 640x640 |51.2 | [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/EZFPnLqiD-xIlt7rcZYDjQgB4YXE9wnq1qaSXQwJrsKbdg?e=83nwEz)/[github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_x_openvino.tar.gz) |
## Install OpenVINO Toolkit
Please visit [Openvino Homepage](https://docs.openvinotoolkit.org/latest/get_started_guides.html) for more details.
## Set up the Environment
### For Linux
**Option1. Set up the environment tempororally. You need to run this command everytime you start a new shell window.**
```shell
source /opt/intel/openvino_2021/bin/setupvars.sh
```
**Option2. Set up the environment permenantly.**
*Step1.* For Linux:
```shell
vim ~/.bashrc
```
*Step2.* Add the following line into your file:
```shell
source /opt/intel/openvino_2021/bin/setupvars.sh
```
*Step3.* Save and exit the file, then run:
```shell
source ~/.bashrc
```
## Convert model
1. Export ONNX model
Please refer to the [ONNX toturial](../../ONNXRuntime). **Note that you should set --opset to 10, otherwise your next step will fail.**
2. Convert ONNX to OpenVINO
``` shell
cd <INSTSLL_DIR>/openvino_2021/deployment_tools/model_optimizer
```
Install requirements for convert tool
```shell
sudo ./install_prerequisites/install_prerequisites_onnx.sh
```
Then convert model.
```shell
python3 mo.py --input_model <ONNX_MODEL> --input_shape <INPUT_SHAPE> [--data_type FP16]
```
For example:
```shell
python3 mo.py --input_model yolox.onnx --input_shape [1,3,640,640] --data_type FP16 --output_dir converted_output
```
## Demo
### python
```shell
python openvino_inference.py -m <XML_MODEL_PATH> -i <IMAGE_PATH>
```
or
```shell
python openvino_inference.py -m <XML_MODEL_PATH> -i <IMAGE_PATH> -o <OUTPUT_DIR> -s <SCORE_THR> -d <DEVICE>
```
================================================
FILE: detector/YOLOX/demo/OpenVINO/python/openvino_inference.py
================================================
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# Copyright (C) 2018-2021 Intel Corporation
# SPDX-License-Identifier: Apache-2.0
# Copyright (c) Megvii, Inc. and its affiliates.
import argparse
import logging as log
import os
import sys
import cv2
import numpy as np
from openvino.inference_engine import IECore
from yolox.data.data_augment import preproc as preprocess
from yolox.data.datasets import COCO_CLASSES
from yolox.utils import mkdir, multiclass_nms, demo_postprocess, vis
def parse_args() -> argparse.Namespace:
"""Parse and return command line arguments"""
parser = argparse.ArgumentParser(add_help=False)
args = parser.add_argument_group('Options')
args.add_argument(
'-h',
'--help',
action='help',
help='Show this help message and exit.')
args.add_argument(
'-m',
'--model',
required=True,
type=str,
help='Required. Path to an .xml or .onnx file with a trained model.')
args.add_argument(
'-i',
'--input',
required=True,
type=str,
help='Required. Path to an image file.')
args.add_argument(
'-o',
'--output_dir',
type=str,
default='demo_output',
help='Path to your output dir.')
args.add_argument(
'-s',
'--score_thr',
type=float,
default=0.3,
help="Score threshould to visualize the result.")
args.add_argument(
'-d',
'--device',
default='CPU',
type=str,
help='Optional. Specify the target device to infer on; CPU, GPU, \
MYRIAD, HDDL or HETERO: is acceptable. The sample will look \
for a suitable plugin for device specified. Default value \
is CPU.')
args.add_argument(
'--labels',
default=None,
type=str,
help='Option:al. Path to a labels mapping file.')
args.add_argument(
'-nt',
'--number_top',
default=10,
type=int,
help='Optional. Number of top results.')
return parser.parse_args()
def main():
log.basicConfig(format='[ %(levelname)s ] %(message)s', level=log.INFO, stream=sys.stdout)
args = parse_args()
# ---------------------------Step 1. Initialize inference engine core--------------------------------------------------
log.info('Creating Inference Engine')
ie = IECore()
# ---------------------------Step 2. Read a model in OpenVINO Intermediate Representation or ONNX format---------------
log.info(f'Reading the network: {args.model}')
# (.xml and .bin files) or (.onnx file)
net = ie.read_network(model=args.model)
if len(net.input_info) != 1:
log.error('Sample supports only single input topologies')
return -1
if len(net.outputs) != 1:
log.error('Sample supports only single output topologies')
return -1
# ---------------------------Step 3. Configure input & output----------------------------------------------------------
log.info('Configuring input and output blobs')
# Get names of input and output blobs
input_blob = next(iter(net.input_info))
out_blob = next(iter(net.outputs))
# Set input and output precision manually
net.input_info[input_blob].precision = 'FP32'
net.outputs[out_blob].precision = 'FP16'
# Get a number of classes recognized by a model
num_of_classes = max(net.outputs[out_blob].shape)
# ---------------------------Step 4. Loading model to the device-------------------------------------------------------
log.info('Loading the model to the plugin')
exec_net = ie.load_network(network=net, device_name=args.device)
# ---------------------------Step 5. Create infer request--------------------------------------------------------------
# load_network() method of the IECore class with a specified number of requests (default 1) returns an ExecutableNetwork
# instance which stores infer requests. So you already created Infer requests in the previous step.
# ---------------------------Step 6. Prepare input---------------------------------------------------------------------
origin_img = cv2.imread(args.input)
_, _, h, w = net.input_info[input_blob].input_data.shape
mean = (0.485, 0.456, 0.406)
std = (0.229, 0.224, 0.225)
image, ratio = preprocess(origin_img, (h, w), mean, std)
# ---------------------------Step 7. Do inference----------------------------------------------------------------------
log.info('Starting inference in synchronous mode')
res = exec_net.infer(inputs={input_blob: image})
# ---------------------------Step 8. Process output--------------------------------------------------------------------
res = res[out_blob]
predictions = demo_postprocess(res, (h, w), p6=False)[0]
boxes = predictions[:, :4]
scores = predictions[:, 4, None] * predictions[:, 5:]
boxes_xyxy = np.ones_like(boxes)
boxes_xyxy[:, 0] = boxes[:, 0] - boxes[:, 2]/2.
boxes_xyxy[:, 1] = boxes[:, 1] - boxes[:, 3]/2.
boxes_xyxy[:, 2] = boxes[:, 0] + boxes[:, 2]/2.
boxes_xyxy[:, 3] = boxes[:, 1] + boxes[:, 3]/2.
boxes_xyxy /= ratio
dets = multiclass_nms(boxes_xyxy, scores, nms_thr=0.65, score_thr=0.1)
if dets is not None:
final_boxes = dets[:, :4]
final_scores, final_cls_inds = dets[:, 4], dets[:, 5]
origin_img = vis(origin_img, final_boxes, final_scores, final_cls_inds,
conf=args.score_thr, class_names=COCO_CLASSES)
mkdir(args.output_dir)
output_path = os.path.join(args.output_dir, args.image_path.split("/")[-1])
cv2.imwrite(output_path, origin_img)
if __name__ == '__main__':
sys.exit(main())
================================================
FILE: detector/YOLOX/demo/TensorRT/cpp/CMakeLists.txt
================================================
cmake_minimum_required(VERSION 2.6)
project(yolox)
add_definitions(-std=c++11)
option(CUDA_USE_STATIC_CUDA_RUNTIME OFF)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE Debug)
find_package(CUDA REQUIRED)
include_directories(${PROJECT_SOURCE_DIR}/include)
# include and link dirs of cuda and tensorrt, you need adapt them if yours are different
# cuda
include_directories(/data/cuda/cuda-10.2/cuda/include)
link_directories(/data/cuda/cuda-10.2/cuda/lib64)
# cudnn
include_directories(/data/cuda/cuda-10.2/cudnn/v8.0.4/include)
link_directories(/data/cuda/cuda-10.2/cudnn/v8.0.4/lib64)
# tensorrt
include_directories(/data/cuda/cuda-10.2/TensorRT/v7.2.1.6/include)
link_directories(/data/cuda/cuda-10.2/TensorRT/v7.2.1.6/lib)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Ofast -Wfatal-errors -D_MWAITXINTRIN_H_INCLUDED")
find_package(OpenCV)
include_directories(${OpenCV_INCLUDE_DIRS})
add_executable(yolox ${PROJECT_SOURCE_DIR}/yolox.cpp)
target_link_libraries(yolox nvinfer)
target_link_libraries(yolox cudart)
target_link_libraries(yolox ${OpenCV_LIBS})
add_definitions(-O2 -pthread)
================================================
FILE: detector/YOLOX/demo/TensorRT/cpp/README.md
================================================
# YOLOX-TensorRT in C++
As YOLOX models is easy to converted to tensorrt using [torch2trt gitrepo](https://github.com/NVIDIA-AI-IOT/torch2trt),
our C++ demo will not include the model converting or constructing like other tenorrt demos.
## Step 1: Prepare serialized engine file
Follow the trt [python demo README](../python/README.md) to convert and save the serialized engine file.
Check the 'model_trt.engine' file generated from Step 1, which will automatically saved at the current demo dir.
## Step 2: build the demo
Please follow the [TensorRT Installation Guide](https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html) to install TensorRT.
Install opencv with ```sudo apt-get install libopencv-dev```.
build the demo:
```shell
mkdir build
cd build
cmake ..
make
```
Then run the demo:
```shell
./yolox ../model_trt.engine -i ../../../../assets/dog.jpg
```
or
```shell
./yolox <path/to/your/engine_file> -i <path/to/image>
```
================================================
FILE: detector/YOLOX/demo/TensorRT/cpp/logging.h
================================================
/*
* Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TENSORRT_LOGGING_H
#define TENSORRT_LOGGING_H
#include "NvInferRuntimeCommon.h"
#include <cassert>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <ostream>
#include <sstream>
#include <string>
using Severity = nvinfer1::ILogger::Severity;
class LogStreamConsumerBuffer : public std::stringbuf
{
public:
LogStreamConsumerBuffer(std::ostream& stream, const std::string& prefix, bool shouldLog)
: mOutput(stream)
, mPrefix(prefix)
, mShouldLog(shouldLog)
{
}
LogStreamConsumerBuffer(LogStreamConsumerBuffer&& other)
: mOutput(other.mOutput)
{
}
~LogStreamConsumerBuffer()
{
// std::streambuf::pbase() gives a pointer to the beginning of the buffered part of the output sequence
// std::streambuf::pptr() gives a pointer to the current position of the output sequence
// if the pointer to the beginning is not equal to the pointer to the current position,
// call putOutput() to log the output to the stream
if (pbase() != pptr())
{
putOutput();
}
}
// synchronizes the stream buffer and returns 0 on success
// synchronizing the stream buffer consists of inserting the buffer contents into the stream,
// resetting the buffer and flushing the stream
virtual int sync()
{
putOutput();
return 0;
}
void putOutput()
{
if (mShouldLog)
{
// prepend timestamp
std::time_t timestamp = std::time(nullptr);
tm* tm_local = std::localtime(×tamp);
std::cout << "[";
std::cout << std::setw(2) << std::setfill('0') << 1 + tm_local->tm_mon << "/";
std::cout << std::setw(2) << std::setfill('0') << tm_local->tm_mday << "/";
std::cout << std::setw(4) << std::setfill('0') << 1900 + tm_local->tm_year << "-";
std::cout << std::setw(2) << std::setfill('0') << tm_local->tm_hour << ":";
std::cout << std::setw(2) << std::setfill('0') << tm_local->tm_min << ":";
std::cout << std::setw(2) << std::setfill('0') << tm_local->tm_sec << "] ";
// std::stringbuf::str() gets the string contents of the buffer
// insert the buffer contents pre-appended by the appropriate prefix into the stream
mOutput << mPrefix << str();
// set the buffer to empty
str("");
// flush the stream
mOutput.flush();
}
}
void setShouldLog(bool shouldLog)
{
mShouldLog = shouldLog;
}
private:
std::ostream& mOutput;
std::string mPrefix;
bool mShouldLog;
};
//!
//! \class LogStreamConsumerBase
//! \brief Convenience object used to initialize LogStreamConsumerBuffer before std::ostream in LogStreamConsumer
//!
class LogStreamConsumerBase
{
public:
LogStreamConsumerBase(std::ostream& stream, const std::string& prefix, bool shouldLog)
: mBuffer(stream, prefix, shouldLog)
{
}
protected:
LogStreamConsumerBuffer mBuffer;
};
//!
//! \class LogStreamConsumer
//! \brief Convenience object used to facilitate use of C++ stream syntax when logging messages.
//! Order of base classes is LogStreamConsumerBase and then std::ostream.
//! This is because the LogStreamConsumerBase class is used to initialize the LogStreamConsumerBuffer member field
//! in LogStreamConsumer and then the address of the buffer is passed to std::ostream.
//! This is necessary to prevent the address of an uninitialized buffer from being passed to std::ostream.
//! Please do not change the order of the parent classes.
//!
class LogStreamConsumer : protected LogStreamConsumerBase, public std::ostream
{
public:
//! \brief Creates a LogStreamConsumer which logs messages with level severity.
//! Reportable severity determines if the messages are severe enough to be logged.
LogStreamConsumer(Severity reportableSeverity, Severity severity)
: LogStreamConsumerBase(severityOstream(severity), severityPrefix(severity), severity <= reportableSeverity)
, std::ostream(&mBuffer) // links the stream buffer with the stream
, mShouldLog(severity <= reportableSeverity)
, mSeverity(severity)
{
}
LogStreamConsumer(LogStreamConsumer&& other)
: LogStreamConsumerBase(severityOstream(other.mSeverity), severityPrefix(other.mSeverity), other.mShouldLog)
, std::ostream(&mBuffer) // links the stream buffer with the stream
, mShouldLog(other.mShouldLog)
, mSeverity(other.mSeverity)
{
}
void setReportableSeverity(Severity reportableSeverity)
{
mShouldLog = mSeverity <= reportableSeverity;
mBuffer.setShouldLog(mShouldLog);
}
private:
static std::ostream& severityOstream(Severity severity)
{
return severity >= Severity::kINFO ? std::cout : std::cerr;
}
static std::string severityPrefix(Severity severity)
{
switch (severity)
{
case Severity::kINTERNAL_ERROR: return "[F] ";
case Severity::kERROR: return "[E] ";
case Severity::kWARNING: return "[W] ";
case Severity::kINFO: return "[I] ";
case Severity::kVERBOSE: return "[V] ";
default: assert(0); return "";
}
}
bool mShouldLog;
Severity mSeverity;
};
//! \class Logger
//!
//! \brief Class which manages logging of TensorRT tools and samples
//!
//! \details This class provides a common interface for TensorRT tools and samples to log information to the console,
//! and supports logging two types of messages:
//!
//! - Debugging messages with an associated severity (info, warning, error, or internal error/fatal)
//! - Test pass/fail messages
//!
//! The advantage of having all samples use this class for logging as opposed to emitting directly to stdout/stderr is
//! that the logic for controlling the verbosity and formatting of sample output is centralized in one location.
//!
//! In the future, this class could be extended to support dumping test results to a file in some standard format
//! (for example, JUnit XML), and providing additional metadata (e.g. timing the duration of a test run).
//!
//! TODO: For backwards compatibility with existing samples, this class inherits directly from the nvinfer1::ILogger
//! interface, which is problematic since there isn't a clean separation between messages coming from the TensorRT
//! library and messages coming from the sample.
//!
//! In the future (once all samples are updated to use Logger::getTRTLogger() to access the ILogger) we can refactor the
//! class to eliminate the inheritance and instead make the nvinfer1::ILogger implementation a member of the Logger
//! object.
class Logger : public nvinfer1::ILogger
{
public:
Logger(Severity severity = Severity::kWARNING)
: mReportableSeverity(severity)
{
}
//!
//! \enum TestResult
//! \brief Represents the state of a given test
//!
enum class TestResult
{
kRUNNING, //!< The test is running
kPASSED, //!< The test passed
kFAILED, //!< The test failed
kWAIVED //!< The test was waived
};
//!
//! \brief Forward-compatible method for retrieving the nvinfer::ILogger associated with this Logger
//! \return The nvinfer1::ILogger associated with this Logger
//!
//! TODO Once all samples are updated to use this method to register the logger with TensorRT,
//! we can eliminate the inheritance of Logger from ILogger
//!
nvinfer1::ILogger& getTRTLogger()
{
return *this;
}
//!
//! \brief Implementation of the nvinfer1::ILogger::log() virtual method
//!
//! Note samples should not be calling this function directly; it will eventually go away once we eliminate the
//! inheritance from nvinfer1::ILogger
//!
void log(Severity severity, const char* msg) override
{
LogStreamConsumer(mReportableSeverity, severity) << "[TRT] " << std::string(msg) << std::endl;
}
//!
//! \brief Method for controlling the verbosity of logging output
//!
//! \param severity The logger will only emit messages that have severity of this level or higher.
//!
void setReportableSeverity(Severity severity)
{
mReportableSeverity = severity;
}
//!
//! \brief Opaque handle that holds logging information for a particular test
//!
//! This object is an opaque handle to information used by the Logger to print test results.
//! The sample must call Logger::defineTest() in order to obtain a TestAtom that can be used
//! with Logger::reportTest{Start,End}().
//!
class TestAtom
{
public:
TestAtom(TestAtom&&) = default;
private:
friend class Logger;
TestAtom(bool started, const std::string& name, const std::string& cmdline)
: mStarted(started)
, mName(name)
, mCmdline(cmdline)
{
}
bool mStarted;
std::string mName;
std::string mCmdline;
};
//!
//! \brief Define a test for logging
//!
//! \param[in] name The name of the test. This should be a string starting with
//! "TensorRT" and containing dot-separated strings containing
//! the characters [A-Za-z0-9_].
//! For example, "TensorRT.sample_googlenet"
//! \param[in] cmdline The command line used to reproduce the test
//
//! \return a TestAtom that can be used in Logger::reportTest{Start,End}().
//!
static TestAtom defineTest(const std::string& name, const std::string& cmdline)
{
return TestAtom(false, name, cmdline);
}
//!
//! \brief A convenience overloaded version of defineTest() that accepts an array of command-line arguments
//! as input
//!
//! \param[in] name The name of the test
//! \param[in] argc The number of command-line arguments
//! \param[in] argv The array of command-line arguments (given as C strings)
//!
//! \return a TestAtom that can be used in Logger::reportTest{Start,End}().
static TestAtom defineTest(const std::string& name, int argc, char const* const* argv)
{
auto cmdline = genCmdlineString(argc, argv);
return defineTest(name, cmdline);
}
//!
//! \brief Report that a test has started.
//!
//! \pre reportTestStart() has not been called yet for the given testAtom
//!
//! \param[in] testAtom The handle to the test that has started
//!
static void reportTestStart(TestAtom& testAtom)
{
reportTestResult(testAtom, TestResult::kRUNNING);
assert(!testAtom.mStarted);
testAtom.mStarted = true;
}
//!
//! \brief Report that a test has ended.
//!
//! \pre reportTestStart() has been called for the given testAtom
//!
//! \param[in] testAtom The handle to the test that has ended
//! \param[in] result The result of the test. Should be one of TestResult::kPASSED,
//! TestResult::kFAILED, TestResult::kWAIVED
//!
static void reportTestEnd(const TestAtom& testAtom, TestResult result)
{
assert(result != TestResult::kRUNNING);
assert(testAtom.mStarted);
reportTestResult(testAtom, result);
}
static int reportPass(const TestAtom& testAtom)
{
reportTestEnd(testAtom, TestResult::kPASSED);
return EXIT_SUCCESS;
}
static int reportFail(const TestAtom& testAtom)
{
reportTestEnd(testAtom, TestResult::kFAILED);
return EXIT_FAILURE;
}
static int reportWaive(const TestAtom& testAtom)
{
reportTestEnd(testAtom, TestResult::kWAIVED);
return EXIT_SUCCESS;
}
static int reportTest(const TestAtom& testAtom, bool pass)
{
return pass ? reportPass(testAtom) : reportFail(testAtom);
}
Severity getReportableSeverity() const
{
return mReportableSeverity;
}
private:
//!
//! \brief returns an appropriate string for prefixing a log message with the given severity
//!
static const char* severityPrefix(Severity severity)
{
switch (severity)
{
case Severity::kINTERNAL_ERROR: return "[F] ";
case Severity::kERROR: return "[E] ";
case Severity::kWARNING: return "[W] ";
case Severity::kINFO: return "[I] ";
case Severity::kVERBOSE: return "[V] ";
default: assert(0); return "";
}
}
//!
//! \brief returns an appropriate string for prefixing a test result message with the given result
//!
static const char* testResultString(TestResult result)
{
switch (result)
{
case TestResult::kRUNNING: return "RUNNING";
case TestResult::kPASSED: return "PASSED";
case TestResult::kFAILED: return "FAILED";
case TestResult::kWAIVED: return "WAIVED";
default: assert(0); return "";
}
}
//!
//! \brief returns an appropriate output stream (cout or cerr) to use with the given severity
//!
static std::ostream& severityOstream(Severity severity)
{
return severity >= Severity::kINFO ? std::cout : std::cerr;
}
//!
//! \brief method that implements logging test results
//!
static void reportTestResult(const TestAtom& testAtom, TestResult result)
{
severityOstream(Severity::kINFO) << "&&&& " << testResultString(result) << " " << testAtom.mName << " # "
<< testAtom.mCmdline << std::endl;
}
//!
//! \brief generate a command line string from the given (argc, argv) values
//!
static std::string genCmdlineString(int argc, char const* const* argv)
{
std::stringstream ss;
for (int i = 0; i < argc; i++)
{
if (i > 0)
ss << " ";
ss << argv[i];
}
return ss.str();
}
Severity mReportableSeverity;
};
namespace
{
//!
//! \brief produces a LogStreamConsumer object that can be used to log messages of severity kVERBOSE
//!
//! Example usage:
//!
//! LOG_VERBOSE(logger) << "hello world" << std::endl;
//!
inline LogStreamConsumer LOG_VERBOSE(const Logger& logger)
{
return LogStreamConsumer(logger.getReportableSeverity(), Severity::kVERBOSE);
}
//!
//! \brief produces a LogStreamConsumer object that can be used to log messages of severity kINFO
//!
//! Example usage:
//!
//! LOG_INFO(logger) << "hello world" << std::endl;
//!
inline LogStreamConsumer LOG_INFO(const Logger& logger)
{
return LogStreamConsumer(logger.getReportableSeverity(), Severity::kINFO);
}
//!
//! \brief produces a LogStreamConsumer object that can be used to log messages of severity kWARNING
//!
//! Example usage:
//!
//! LOG_WARN(logger) << "hello world" << std::endl;
//!
inline LogStreamConsumer LOG_WARN(const Logger& logger)
{
return LogStreamConsumer(logger.getReportableSeverity(), Severity::kWARNING);
}
//!
//! \brief produces a LogStreamConsumer object that can be used to log messages of severity kERROR
//!
//! Example usage:
//!
//! LOG_ERROR(logger) << "hello world" << std::endl;
//!
inline LogStreamConsumer LOG_ERROR(const Logger& logger)
{
return LogStreamConsumer(logger.getReportableSeverity(), Severity::kERROR);
}
//!
//! \brief produces a LogStreamConsumer object that can be used to log messages of severity kINTERNAL_ERROR
// ("fatal" severity)
//!
//! Example usage:
//!
//! LOG_FATAL(logger) << "hello world" << std::endl;
//!
inline LogStreamConsumer LOG_FATAL(const Logger& logger)
{
return LogStreamConsumer(logger.getReportableSeverity(), Severity::kINTERNAL_ERROR);
}
} // anonymous namespace
#endif // TENSORRT_LOGGING_H
================================================
FILE: detector/YOLOX/demo/TensorRT/cpp/yolox.cpp
================================================
#include <fstream>
#include <iostream>
#include <sstream>
#include <numeric>
#include <chrono>
#include <vector>
#include <opencv2/opencv.hpp>
#include <dirent.h>
#include "NvInfer.h"
#include "cuda_runtime_api.h"
#include "logging.h"
#define CHECK(status) \
do\
{\
auto ret = (status);\
if (ret != 0)\
{\
std::cerr << "Cuda failure: " << ret << std::endl;\
abort();\
}\
} while (0)
#define DEVICE 0 // GPU id
#define NMS_THRESH 0.65
#define BBOX_CONF_THRESH 0.3
using namespace nvinfer1;
// stuff we know about the network and the input/output blobs
static const int INPUT_W = 640;
static const int INPUT_H = 640;
const char* INPUT_BLOB_NAME = "input_0";
const char* OUTPUT_BLOB_NAME = "output_0";
static Logger gLogger;
cv::Mat static_resize(cv::Mat& img) {
float r = std::min(INPUT_W / (img.cols*1.0), INPUT_H / (img.rows*1.0));
// r = std::min(r, 1.0f);
int unpad_w = r * img.cols;
int unpad_h = r * img.rows;
cv::Mat re(unpad_h, unpad_w, CV_8UC3);
cv::resize(img, re, re.size());
cv::Mat out(INPUT_W, INPUT_H, CV_8UC3, cv::Scalar(114, 114, 114));
re.copyTo(out(cv::Rect(0, 0, re.cols, re.rows)));
return out;
}
struct Object
{
cv::Rect_<float> rect;
int label;
float prob;
};
struct GridAndStride
{
int grid0;
int grid1;
int stride;
};
static void generate_grids_and_stride(const int target_size, std::vector<int>& strides, std::vector<GridAndStride>& grid_strides)
{
for (auto stride : strides)
{
int num_grid = target_size / stride;
for (int g1 = 0; g1 < num_grid; g1++)
{
for (int g0 = 0; g0 < num_grid; g0++)
{
grid_strides.push_back((GridAndStride){g0, g1, stride});
}
}
}
}
static inline float intersection_area(const Object& a, const Object& b)
{
cv::Rect_<float> inter = a.rect & b.rect;
return inter.area();
}
static void qsort_descent_inplace(std::vector<Object>& faceobjects, int left, int right)
{
int i = left;
int j = right;
float p = faceobjects[(left + right) / 2].prob;
while (i <= j)
{
while (faceobjects[i].prob > p)
i++;
while (faceobjects[j].prob < p)
j--;
if (i <= j)
{
// swap
std::swap(faceobjects[i], faceobjects[j]);
i++;
j--;
}
}
#pragma omp parallel sections
{
#pragma omp section
{
if (left < j) qsort_descent_inplace(faceobjects, left, j);
}
#pragma omp section
{
if (i < right) qsort_descent_inplace(faceobjects, i, right);
}
}
}
static void qsort_descent_inplace(std::vector<Object>& objects)
{
if (objects.empty())
return;
qsort_descent_inplace(objects, 0, objects.size() - 1);
}
static void nms_sorted_bboxes(const std::vector<Object>& faceobjects, std::vector<int>& picked, float nms_threshold)
{
picked.clear();
const int n = faceobjects.size();
std::vector<float> areas(n);
for (int i = 0; i < n; i++)
{
areas[i] = faceobjects[i].rect.area();
}
for (int i = 0; i < n; i++)
{
const Object& a = faceobjects[i];
int keep = 1;
for (int j = 0; j < (int)picked.size(); j++)
{
const Object& b = faceobjects[picked[j]];
// intersection over union
float inter_area = intersection_area(a, b);
float union_area = areas[i] + areas[picked[j]] - inter_area;
// float IoU = inter_area / union_area
if (inter_area / union_area > nms_threshold)
keep = 0;
}
if (keep)
picked.push_back(i);
}
}
static void generate_yolox_proposals(std::vector<GridAndStride> grid_strides, float* feat_blob, float prob_threshold, std::vector<Object>& objects)
{
const int num_class = 80;
const int num_anchors = grid_strides.size();
for (int anchor_idx = 0; anchor_idx < num_anchors; anchor_idx++)
{
const int grid0 = grid_strides[anchor_idx].grid0;
const int grid1 = grid_strides[anchor_idx].grid1;
const int stride = grid_strides[anchor_idx].stride;
const int basic_pos = anchor_idx * 85;
// yolox/models/yolo_head.py decode logic
float x_center = (feat_blob[basic_pos+0] + grid0) * stride;
float y_center = (feat_blob[basic_pos+1] + grid1) * stride;
float w = exp(feat_blob[basic_pos+2]) * stride;
float h = exp(feat_blob[basic_pos+3]) * stride;
float x0 = x_center - w * 0.5f;
float y0 = y_center - h * 0.5f;
float box_objectness = feat_blob[basic_pos+4];
for (int class_idx = 0; class_idx < num_class; class_idx++)
{
float box_cls_score = feat_blob[basic_pos + 5 + class_idx];
float box_prob = box_objectness * box_cls_score;
if (box_prob > prob_threshold)
{
Object obj;
obj.rect.x = x0;
obj.rect.y = y0;
obj.rect.width = w;
obj.rect.height = h;
obj.label = class_idx;
obj.prob = box_prob;
objects.push_back(obj);
}
} // class loop
} // point anchor loop
}
float* blobFromImage(cv::Mat& img){
cv::cvtColor(img, img, cv::COLOR_BGR2RGB);
float* blob = new float[img.total()*3];
int channels = 3;
int img_h = 640;
int img_w = 640;
std::vector<float> mean = {0.485, 0.456, 0.406};
std::vector<float> std = {0.229, 0.224, 0.225};
for (size_t c = 0; c < channels; c++)
{
for (size_t h = 0; h < img_h; h++)
{
for (size_t w = 0; w < img_w; w++)
{
blob[c * img_w * img_h + h * img_w + w] =
(((float)img.at<cv::Vec3b>(h, w)[c]) / 255.0f - mean[c]) / std[c];
}
}
}
return blob;
}
static void decode_outputs(float* prob, std::vector<Object>& objects, float scale, const int img_w, const int img_h) {
std::vector<Object> proposals;
std::vector<int> strides = {8, 16, 32};
std::vector<GridAndStride> grid_strides;
generate_grids_and_stride(INPUT_W, strides, grid_strides);
generate_yolox_proposals(grid_strides, prob, BBOX_CONF_THRESH, proposals);
std::cout << "num of boxes before nms: " << proposals.size() << std::endl;
qsort_descent_inplace(proposals);
std::vector<int> picked;
nms_sorted_bboxes(proposals, picked, NMS_THRESH);
int count = picked.size();
std::cout << "num of boxes: " << count << std::endl;
objects.resize(count);
for (int i = 0; i < count; i++)
{
objects[i] = proposals[picked[i]];
// adjust offset to original unpadded
float x0 = (objects[i].rect.x) / scale;
float y0 = (objects[i].rect.y) / scale;
float x1 = (objects[i].rect.x + objects[i].rect.width) / scale;
float y1 = (objects[i].rect.y + objects[i].rect.height) / scale;
// clip
x0 = std::max(std::min(x0, (float)(img_w - 1)), 0.f);
y0 = std::max(std::min(y0, (float)(img_h - 1)), 0.f);
x1 = std::max(std::min(x1, (float)(img_w - 1)), 0.f);
y1 = std::max(std::min(y1, (float)(img_h - 1)), 0.f);
objects[i].rect.x = x0;
objects[i].rect.y = y0;
objects[i].rect.width = x1 - x0;
objects[i].rect.height = y1 - y0;
}
}
const float color_list[80][3] =
{
{0.000, 0.447, 0.741},
{0.850, 0.325, 0.098},
{0.929, 0.694, 0.125},
{0.494, 0.184, 0.556},
{0.466, 0.674, 0.188},
{0.301, 0.745, 0.933},
{0.635, 0.078, 0.184},
{0.300, 0.300, 0.300},
{0.600, 0.600, 0.600},
{1.000, 0.000, 0.000},
{1.000, 0.500, 0.000},
{0.749, 0.749, 0.000},
{0.000, 1.000, 0.000},
{0.000, 0.000, 1.000},
{0.667, 0.000, 1.000},
{0.333, 0.333, 0.000},
{0.333, 0.667, 0.000},
{0.333, 1.000, 0.000},
{0.667, 0.333, 0.000},
{0.667, 0.667, 0.000},
{0.667, 1.000, 0.000},
{1.000, 0.333, 0.000},
{1.000, 0.667, 0.000},
{1.000, 1.000, 0.000},
{0.000, 0.333, 0.500},
{0.000, 0.667, 0.500},
{0.000, 1.000, 0.500},
{0.333, 0.000, 0.500},
{0.333, 0.333, 0.500},
{0.333, 0.667, 0.500},
{0.333, 1.000, 0.500},
{0.667, 0.000, 0.500},
{0.667, 0.333, 0.500},
{0.667, 0.667, 0.500},
{0.667, 1.000, 0.500},
{1.000, 0.000, 0.500},
{1.000, 0.333, 0.500},
{1.000, 0.667, 0.500},
{1.000, 1.000, 0.500},
{0.000, 0.333, 1.000},
{0.000, 0.667, 1.000},
{0.000, 1.000, 1.000},
{0.333, 0.000, 1.000},
{0.333, 0.333, 1.000},
{0.333, 0.667, 1.000},
{0.333, 1.000, 1.000},
{0.667, 0.000, 1.000},
{0.667, 0.333, 1.000},
{0.667, 0.667, 1.000},
{0.667, 1.000, 1.000},
{1.000, 0.000, 1.000},
{1.000, 0.333, 1.000},
{1.000, 0.667, 1.000},
{0.333, 0.000, 0.000},
{0.500, 0.000, 0.000},
{0.667, 0.000, 0.000},
{0.833, 0.000, 0.000},
{1.000, 0.000, 0.000},
{0.000, 0.167, 0.000},
{0.000, 0.333, 0.000},
{0.000, 0.500, 0.000},
{0.000, 0.667, 0.000},
{0.000, 0.833, 0.000},
{0.000, 1.000, 0.000},
{0.000, 0.000, 0.167},
{0.000, 0.000, 0.333},
{0.000, 0.000, 0.500},
{0.000, 0.000, 0.667},
{0.000, 0.000, 0.833},
{0.000, 0.000, 1.000},
{0.000, 0.000, 0.000},
{0.143, 0.143, 0.143},
{0.286, 0.286, 0.286},
{0.429, 0.429, 0.429},
{0.571, 0.571, 0.571},
{0.714, 0.714, 0.714},
{0.857, 0.857, 0.857},
{0.000, 0.447, 0.741},
{0.314, 0.717, 0.741},
{0.50, 0.5, 0}
};
static void draw_objects(const cv::Mat& bgr, const std::vector<Object>& objects, std::string f)
{
static const char* class_names[] = {
"person", "bicycle", "car", "motorcycle", "airplane", "bus", "train", "truck", "boat", "traffic light",
"fire hydrant", "stop sign", "parking meter", "bench", "bird", "cat", "dog", "horse", "sheep", "cow",
"elephant", "bear", "zebra", "giraffe", "backpack", "umbrella", "handbag", "tie", "suitcase", "frisbee",
"skis", "snowboard", "sports ball", "kite", "baseball bat", "baseball glove", "skateboard", "surfboard",
"tennis racket", "bottle", "wine glass", "cup", "fork", "knife", "spoon", "bowl", "banana", "apple",
"sandwich", "orange", "broccoli", "carrot", "hot dog", "pizza", "donut", "cake", "chair", "couch",
"potted plant", "bed", "dining table", "toilet", "tv", "laptop", "mouse", "remote", "keyboard", "cell phone",
"microwave", "oven", "toaster", "sink", "refrigerator", "book", "clock", "vase", "scissors", "teddy bear",
"hair drier", "toothbrush"
};
cv::Mat image = bgr.clone();
for (size_t i = 0; i < objects.size(); i++)
{
const Object& obj = objects[i];
fprintf(stderr, "%d = %.5f at %.2f %.2f %.2f x %.2f\n", obj.label, obj.prob,
obj.rect.x, obj.rect.y, obj.rect.width, obj.rect.height);
cv::Scalar color = cv::Scalar(color_list[obj.label][0], color_list[obj.label][1], color_list[obj.label][2]);
float c_mean = cv::mean(color)[0];
cv::Scalar txt_color;
if (c_mean > 0.5){
txt_color = cv::Scalar(0, 0, 0);
}else{
txt_color = cv::Scalar(255, 255, 255);
}
cv::rectangle(image, obj.rect, color * 255, 2);
char text[256];
sprintf(text, "%s %.1f%%", class_names[obj.label], obj.prob * 100);
int baseLine = 0;
cv::Size label_size = cv::getTextSize(text, cv::FONT_HERSHEY_SIMPLEX, 0.4, 1, &baseLine);
cv::Scalar txt_bk_color = color * 0.7 * 255;
int x = obj.rect.x;
int y = obj.rect.y + 1;
//int y = obj.rect.y - label_size.height - baseLine;
if (y > image.rows)
y = image.rows;
//if (x + label_size.width > image.cols)
//x = image.cols - label_size.width;
cv::rectangle(image, cv::Rect(cv::Point(x, y), cv::Size(label_size.width, label_size.height + baseLine)),
txt_bk_color, -1);
cv::putText(image, text, cv::Point(x, y + label_size.height),
cv::FONT_HERSHEY_SIMPLEX, 0.4, txt_color, 1);
}
cv::imwrite("det_res.jpg", image);
fprintf(stderr, "save vis file\n");
/* cv::imshow("image", image); */
/* cv::waitKey(0); */
}
void doInference(IExecutionContext& context, float* input, float* output, const int output_size, cv::Size input_shape) {
const ICudaEngine& engine = context.getEngine();
// Pointers to input and output device buffers to pass to engine.
// Engine requires exactly IEngine::getNbBindings() number of buffers.
assert(engine.getNbBindings() == 2);
void* buffers[2];
// In order to bind the buffers, we need to know the names of the input and output tensors.
// Note that indices are guaranteed to be less than IEngine::getNbBindings()
const int inputIndex = engine.getBindingIndex(INPUT_BLOB_NAME);
assert(engine.getBindingDataType(inputIndex) == nvinfer1::DataType::kFLOAT);
const int outputIndex = engine.getBindingIndex(OUTPUT_BLOB_NAME);
assert(engine.getBindingDataType(outputIndex) == nvinfer1::DataType::kFLOAT);
int mBatchSize = engine.getMaxBatchSize();
// Create GPU buffers on device
CHECK(cudaMalloc(&buffers[inputIndex], 3 * input_shape.height * input_shape.width * sizeof(float)));
CHECK(cudaMalloc(&buffers[outputIndex], output_size*sizeof(float)));
// Create stream
cudaStream_t stream;
CHECK(cudaStreamCreate(&stream));
// DMA input batch data to device, infer on the batch asynchronously, and DMA output back to host
CHECK(cudaMemcpyAsync(buffers[inputIndex], input, 3 * input_shape.height * input_shape.width * sizeof(float), cudaMemcpyHostToDevice, stream));
context.enqueue(1, buffers, stream, nullptr);
CHECK(cudaMemcpyAsync(output, buffers[outputIndex], output_size * sizeof(float), cudaMemcpyDeviceToHost, stream));
cudaStreamSynchronize(stream);
// Release stream and buffers
cudaStreamDestroy(stream);
CHECK(cudaFree(buffers[inputIndex]));
CHECK(cudaFree(buffers[outputIndex]));
}
int main(int argc, char** argv) {
cudaSetDevice(DEVICE);
// create a model using the API directly and serialize it to a stream
char *trtModelStream{nullptr};
size_t size{0};
if (argc == 4 && std::string(argv[2]) == "-i") {
const std::string engine_file_path {argv[1]};
std::ifstream file(engine_file_path, std::ios::binary);
if (file.good()) {
file.seekg(0, file.end);
size = file.tellg();
file.seekg(0, file.beg);
trtModelStream = new char[size];
assert(trtModelStream);
file.read(trtModelStream, size);
file.close();
}
} else {
std::cerr << "arguments not right!" << std::endl;
std::cerr << "run 'python3 yolox/deploy/trt.py -n yolox-{tiny, s, m, l, x}' to serialize model first!" << std::endl;
std::cerr << "Then use the following command:" << std::endl;
std::cerr << "./yolox ../model_trt.engine -i ../../../assets/dog.jpg // deserialize file and run inference" << std::endl;
return -1;
}
const std::string input_image_path {argv[3]};
//std::vector<std::string> file_names;
//if (read_files_in_dir(argv[2], file_names) < 0) {
//std::cout << "read_files_in_dir failed." << std::endl;
//return -1;
//}
IRuntime* runtime = createInferRuntime(gLogger);
assert(runtime != nullptr);
ICudaEngine* engine = runtime->deserializeCudaEngine(trtModelStream, size);
assert(engine != nullptr);
IExecutionContext* context = engine->createExecutionContext();
assert(context != nullptr);
delete[] trtModelStream;
auto out_dims = engine->getBindingDimensions(1);
auto output_size = 1;
for(int j=0;j<out_dims.nbDims;j++) {
output_size *= out_dims.d[j];
}
static float* prob = new float[output_size];
cv::Mat img = cv::imread(input_image_path);
int img_w = img.cols;
int img_h = img.rows;
cv::Mat pr_img = static_resize(img);
std::cout << "blob image" << std::endl;
float* blob;
blob = blobFromImage(pr_img);
float scale = std::min(INPUT_W / (img.cols*1.0), INPUT_H / (img.rows*1.0));
// run inference
auto start = std::chrono::system_clock::now();
doInference(*context, blob, prob, output_size, pr_img.size());
auto end = std::chrono::system_clock::now();
std::cout << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
std::vector<Object> objects;
decode_outputs(prob, objects, scale, img_w, img_h);
draw_objects(img, objects, input_image_path);
// destroy the engine
context->destroy();
engine->destroy();
runtime->destroy();
return 0;
}
================================================
FILE: detector/YOLOX/demo/TensorRT/python/README.md
================================================
# YOLOX-TensorRT in Python
This toturial includes a Python demo for TensorRT.
## Install TensorRT Toolkit
Please follow the [TensorRT Installation Guide](https://docs.nvidia.com/deeplearning/tensorrt/install-guide/index.html) and [torch2trt gitrepo](https://github.com/NVIDIA-AI-IOT/torch2trt) to install TensorRT and torch2trt.
## Convert model
YOLOX models can be easily conveted to TensorRT models using torch2trt
If you want to convert our model, use the flag -n to specify a model name:
```shell
python tools/trt.py -n <YOLOX_MODEL_NAME> -c <YOLOX_CHECKPOINT>
```
For example:
```shell
python tools/trt.py -n yolox-s -c your_ckpt.pth.tar
```
<YOLOX_MODEL_NAME> can be: yolox-nano, yolox-tiny. yolox-s, yolox-m, yolox-l, yolox-x.
If you want to convert your customized model, use the flag -f to specify you exp file:
```shell
python tools/trt.py -f <YOLOX_EXP_FILE> -c <YOLOX_CHECKPOINT>
```
For example:
```shell
python tools/trt.py -f /path/to/your/yolox/exps/yolox_s.py -c your_ckpt.pth.tar
```
*yolox_s.py* can be any exp file modified by you.
The converted model and the serialized engine file (for C++ demo) will be saved on your experiment output dir.
## Demo
The TensorRT python demo is merged on our pytorch demo file, so you can run the pytorch demo command with ```--trt```.
```shell
python tools/demo.py image -n yolox-s --trt --save_result
```
or
```shell
python tools/demo.py image -f exps/default/yolox_s.py --trt --save_result
```
================================================
FILE: detector/YOLOX/demo/ncnn/android/README.md
================================================
# YOLOX-Android-ncnn
Andoird app of YOLOX object detection base on [ncnn](https://github.com/Tencent/ncnn)
## Tutorial
### Step1
Download ncnn-android-vulkan.zip from [releases of ncnn](https://github.com/Tencent/ncnn/releases). This repo us
[20210525 release](https://github.com/Tencent/ncnn/releases/download/20210525/ncnn-20210525-android-vulkan.zip) for building.
### Step2
After downloading, please extract your zip file. Then, there are two ways to finish this step:
* put your extracted directory into app/src/main/jni
* change the ncnn_DIR path in app/src/main/jni/CMakeLists.txt to your extracted directory.
### Step3
Download example param and bin file from [onedrive](https://megvii-my.sharepoint.cn/:u:/g/personal/gezheng_megvii_com/ESXBH_GSSmFMszWJ6YG2VkQB5cWDfqVWXgk0D996jH0rpQ?e=qzEqUh) or [github](https://github.com/Megvii-BaseDetection/storage/releases/download/0.0.1/yolox_s_ncnn.tar.gz). Unzip the file to app/src/main/assets.
### Step4
Open this project with Android Studio, build it and enjoy!
## Reference
* [ncnn-android-yolov5](https://github.com/nihui/ncnn-android-yolov5)
================================================
FILE: detector/YOLOX/demo/ncnn/android/app/build.gradle
================================================
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.megvii.yoloXncnn"
archivesBaseName = "$applicationId"
ndk {
moduleName "ncnn"
abiFilters "armeabi-v7a", "arm64-v8a"
}
minSdkVersion 24
}
externalNativeBuild {
cmake {
version "3.10.2"
path file('src/main/jni/CMakeLists.txt')
}
}
}
================================================
FILE: detector/YOLOX/demo/ncnn/android/app/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.megvii.yoloXncnn"
android:versionCode="1"
android:versionName="1.1">
<application android:label="@string/app_name" >
<activity android:name="MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
================================================
FILE: detector/YOLOX/demo/ncnn/android/app/src/main/assets/yolox.param
================================================
7767517
220 250
Input images 0 1 images
YoloV5Focus focus 1 1 images 503
Convolution Conv_41 1 1 503 877 0=32 1=3 4=1 5=1 6=3456
Swish Mul_43 1 1 877 507
Convolution Conv_44 1 1 507 880 0=64 1=3 3=2 4=1 5=1 6=18432
Swish Mul_46 1 1 880 511
Split splitncnn_0 1 2 511 511_splitncnn_0 511_splitncnn_1
Convolution Conv_47 1 1 511_splitncnn_1 883 0=32 1=1 5=1 6=2048
Swish Mul_49 1 1 883 515
Split splitncnn_1 1 2 515 515_splitncnn_0 515_splitncnn_1
Convolution Conv_50 1 1 511_splitncnn_0 886 0=32 1=1 5=1 6=2048
Swish Mul_52 1 1 886 519
Convolution Conv_53 1 1 515_splitncnn_1 889 0=32 1=1 5=1 6=1024
Swish Mul_55 1 1 889 523
Convolution Conv_56 1 1 523 892 0=32 1=3 4=1 5=1 6=9216
Swish Mul_58 1 1 892 527
BinaryOp Add_59 2 1 527 515_splitncnn_0 528
Concat Concat_60 2 1 528 519 529
Convolution Conv_61 1 1 529 895 0=64 1=1 5=1 6=4096
Swish Mul_63 1 1 895 533
Convolution Conv_64 1 1 533 898 0=128 1=3 3=2 4=1 5=1 6=73728
Swish Mul_66 1 1 898 537
Split splitncnn_2 1 2 537 537_splitncnn_0 537_splitncnn_1
Convolution Conv_67 1 1 537_splitncnn_1 901 0=64 1=1 5=1 6=8192
Swish Mul_69 1 1 901 541
Split splitncnn_3 1 2 541 541_splitncnn_0 541_splitncnn_1
Convolution Conv_70 1 1 537_splitncnn_0 904 0=64 1=1 5=1 6=8192
Swish Mul_72 1 1 904 545
Convolution Conv_73 1 1 541_splitncnn_1 907 0=64 1=1 5=1 6=4096
Swish Mul_75 1 1 907 549
Convolution Conv_76 1 1 549 910 0=64 1=3 4=1 5=1 6=36864
Swish Mul_78 1 1 910 553
BinaryOp Add_79 2 1 553 541_splitncnn_0 554
Split splitncnn_4 1 2 554 554_splitncnn_0 554_splitncnn_1
Convolution Conv_80 1 1 554_splitncnn_1 913 0=64 1=1 5=1 6=4096
Swish Mul_82 1 1 913 558
Convolution Conv_83 1 1 558 916 0=64 1=3 4=1 5=1 6=36864
Swish Mul_85 1 1 916 562
BinaryOp Add_86 2 1 562 554_splitncnn_0 563
Split splitncnn_5 1 2 563 563_splitncnn_0 563_splitncnn_1
Convolution Conv_87 1 1 563_splitncnn_1 919 0=64 1=1 5=1 6=4096
Swish Mul_89 1 1 919 567
Convolution Conv_90 1 1 567 922 0=64 1=3 4=1 5=1 6=36864
Swish Mul_92 1 1 922 571
BinaryOp Add_93 2 1 571 563_splitncnn_0 572
Concat Concat_94 2 1 572 545 573
Convolution Conv_95 1 1 573 925 0=128 1=1 5=1 6=16384
Swish Mul_97 1 1 925 577
Split splitncnn_6 1 2 577 577_splitncnn_0 577_splitncnn_1
Convolution Conv_98 1 1 577_splitncnn_1 928 0=256 1=3 3=2 4=1 5=1 6=294912
Swish Mul_100 1 1 928 581
Split splitncnn_7 1 2 581 581_splitncnn_0 581_splitncnn_1
Convolution Conv_101 1 1 581_splitncnn_1 931 0=128 1=1 5=1 6=32768
Swish Mul_103 1 1 931 585
Split splitncnn_8 1 2 585 585_splitncnn_0 585_splitncnn_1
Convolution Conv_104 1 1 581_splitncnn_0 934 0=128 1=1 5=1 6=32768
Swish Mul_106 1 1 934 589
Convolution Conv_107 1 1 585_splitncnn_1 937 0=128 1=1 5=1 6=16384
Swish Mul_109 1 1 937 593
Convolution Conv_110 1 1 593 940 0=128 1=3 4=1 5=1 6=147456
Swish Mul_112 1 1 940 597
BinaryOp Add_113 2 1 597 585_splitncnn_0 598
Split splitncnn_9 1 2 598 598_splitncnn_0 598_splitncnn_1
Convolution Conv_114 1 1 598_splitncnn_1 943 0=128 1=1 5=1 6=16384
Swish Mul_116 1 1 943 602
Convolution Conv_117 1 1 602 946 0=128 1=3 4=1 5=1 6=147456
Swish
gitextract_942_umbq/
├── .gitignore
├── LICENSE
├── README.md
├── config/
│ ├── crw_resnet18_s3.yaml
│ ├── crw_resnet18_s3_womotion.yaml
│ ├── imagenet_resnet18_s3.yaml
│ └── imagenet_resnet18_s3_womotion.yaml
├── core/
│ ├── association/
│ │ ├── __init__.py
│ │ └── matching.py
│ ├── motion/
│ │ └── kalman_filter.py
│ └── propagation/
│ ├── __init__.py
│ ├── propagate_box.py
│ ├── propagate_mask.py
│ └── propagate_pose.py
├── data/
│ ├── jhmdb.py
│ ├── kinetics.py
│ ├── video.py
│ └── vos.py
├── demo/
│ ├── mot_demo.py
│ └── sot_demo.py
├── detector/
│ └── YOLOX/
│ ├── .gitignore
│ ├── LICENSE
│ ├── README.md
│ ├── datasets/
│ │ └── README.md
│ ├── demo/
│ │ ├── ONNXRuntime/
│ │ │ ├── README.md
│ │ │ └── onnx_inference.py
│ │ ├── OpenVINO/
│ │ │ ├── README.md
│ │ │ ├── cpp/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── README.md
│ │ │ │ └── yolox_openvino.cpp
│ │ │ └── python/
│ │ │ ├── README.md
│ │ │ └── openvino_inference.py
│ │ ├── TensorRT/
│ │ │ ├── cpp/
│ │ │ │ ├── CMakeLists.txt
│ │ │ │ ├── README.md
│ │ │ │ ├── logging.h
│ │ │ │ └── yolox.cpp
│ │ │ └── python/
│ │ │ └── README.md
│ │ └── ncnn/
│ │ ├── android/
│ │ │ ├── README.md
│ │ │ ├── app/
│ │ │ │ ├── build.gradle
│ │ │ │ └── src/
│ │ │ │ └── main/
│ │ │ │ ├── AndroidManifest.xml
│ │ │ │ ├── assets/
│ │ │ │ │ └── yolox.param
│ │ │ │ ├── java/
│ │ │ │ │ └── com/
│ │ │ │ │ └── megvii/
│ │ │ │ │ └── yoloXncnn/
│ │ │ │ │ ├── MainActivity.java
│ │ │ │ │ ├── YOLOXncnn.java
│ │ │ │ │ └── yoloXncnn.java
│ │ │ │ ├── jni/
│ │ │ │ │ ├── CMakeLists.txt
│ │ │ │ │ └── yoloXncnn_jni.cpp
│ │ │ │ └── res/
│ │ │ │ ├── layout/
│ │ │ │ │ └── main.xml
│ │ │ │ └── values/
│ │ │ │ └── strings.xml
│ │ │ ├── build.gradle
│ │ │ ├── gradle/
│ │ │ │ └── wrapper/
│ │ │ │ ├── gradle-wrapper.jar
│ │ │ │ └── gradle-wrapper.properties
│ │ │ ├── gradlew
│ │ │ ├── gradlew.bat
│ │ │ └── settings.gradle
│ │ └── cpp/
│ │ ├── README.md
│ │ └── yolox.cpp
│ ├── demo.py
│ ├── docs/
│ │ └── train_custom_data.md
│ ├── exps/
│ │ ├── default/
│ │ │ ├── nano.py
│ │ │ ├── yolov3.py
│ │ │ ├── yolox_l.py
│ │ │ ├── yolox_m.py
│ │ │ ├── yolox_s.py
│ │ │ ├── yolox_tiny.py
│ │ │ └── yolox_x.py
│ │ └── example/
│ │ └── yolox_voc/
│ │ └── yolox_voc_s.py
│ ├── requirements.txt
│ ├── setup.cfg
│ ├── setup.py
│ ├── tools/
│ │ ├── __init__.py
│ │ ├── demo.py
│ │ ├── eval.py
│ │ ├── export_onnx.py
│ │ ├── train.py
│ │ └── trt.py
│ └── yolox/
│ ├── __init__.py
│ ├── core/
│ │ ├── __init__.py
│ │ ├── launch.py
│ │ └── trainer.py
│ ├── data/
│ │ ├── __init__.py
│ │ ├── data_augment.py
│ │ ├── data_prefetcher.py
│ │ ├── dataloading.py
│ │ ├── datasets/
│ │ │ ├── __init__.py
│ │ │ ├── coco.py
│ │ │ ├── coco_classes.py
│ │ │ ├── datasets_wrapper.py
│ │ │ ├── mosaicdetection.py
│ │ │ ├── voc.py
│ │ │ └── voc_classes.py
│ │ └── samplers.py
│ ├── evaluators/
│ │ ├── __init__.py
│ │ ├── coco_evaluator.py
│ │ ├── voc_eval.py
│ │ └── voc_evaluator.py
│ ├── exp/
│ │ ├── __init__.py
│ │ ├── base_exp.py
│ │ ├── build.py
│ │ └── yolox_base.py
│ ├── layers/
│ │ ├── __init__.py
│ │ ├── csrc/
│ │ │ ├── cocoeval/
│ │ │ │ ├── cocoeval.cpp
│ │ │ │ └── cocoeval.h
│ │ │ └── vision.cpp
│ │ └── fast_coco_eval_api.py
│ ├── models/
│ │ ├── __init__.py
│ │ ├── darknet.py
│ │ ├── losses.py
│ │ ├── network_blocks.py
│ │ ├── yolo_fpn.py
│ │ ├── yolo_head.py
│ │ ├── yolo_pafpn.py
│ │ └── yolox.py
│ └── utils/
│ ├── __init__.py
│ ├── allreduce_norm.py
│ ├── boxes.py
│ ├── checkpoint.py
│ ├── demo_utils.py
│ ├── dist.py
│ ├── ema.py
│ ├── logger.py
│ ├── lr_scheduler.py
│ ├── metric.py
│ ├── model_utils.py
│ ├── setup_env.py
│ └── visualize.py
├── docs/
│ ├── DATA.md
│ ├── INSTALL.md
│ ├── MODELZOO.md
│ ├── RESULTS.md
│ └── RUN.md
├── eval/
│ ├── convert_davis.py
│ ├── davis_dummy.txt
│ ├── eval_mot.py
│ ├── eval_pck.py
│ ├── mots/
│ │ ├── Evaluator.py
│ │ ├── LICENSE
│ │ ├── MOTSVisualization.py
│ │ ├── MOTS_metrics.py
│ │ ├── Metrics.py
│ │ ├── README.md
│ │ ├── Visualize.py
│ │ ├── __init__.py
│ │ ├── evalMOTS.py
│ │ ├── mots_common/
│ │ │ ├── images_to_txt.py
│ │ │ └── io.py
│ │ └── requirements.txt
│ ├── palette.py
│ ├── poseval/
│ │ ├── .gitignore
│ │ ├── .gitmodules
│ │ ├── .pylintrc
│ │ ├── README.md
│ │ ├── evaluate.py
│ │ ├── license.txt
│ │ ├── matlab/
│ │ │ ├── external/
│ │ │ │ └── jsonlab/
│ │ │ │ ├── AUTHORS.txt
│ │ │ │ ├── ChangeLog.txt
│ │ │ │ ├── LICENSE_BSD.txt
│ │ │ │ ├── README.txt
│ │ │ │ ├── examples/
│ │ │ │ │ ├── demo_jsonlab_basic.m
│ │ │ │ │ ├── demo_ubjson_basic.m
│ │ │ │ │ ├── example1.json
│ │ │ │ │ ├── example2.json
│ │ │ │ │ ├── example3.json
│ │ │ │ │ ├── example4.json
│ │ │ │ │ ├── jsonlab_basictest.matlab
│ │ │ │ │ ├── jsonlab_selftest.m
│ │ │ │ │ ├── jsonlab_selftest.matlab
│ │ │ │ │ └── jsonlab_speedtest.m
│ │ │ │ ├── jsonopt.m
│ │ │ │ ├── loadjson.m
│ │ │ │ ├── loadubjson.m
│ │ │ │ ├── mergestruct.m
│ │ │ │ ├── savejson.m
│ │ │ │ ├── saveubjson.m
│ │ │ │ ├── struct2jdata.m
│ │ │ │ └── varargin2struct.m
│ │ │ ├── mat2json.m
│ │ │ └── startup.m
│ │ └── poseval/
│ │ ├── __init__.py
│ │ ├── convert.py
│ │ ├── eval_helpers.py
│ │ ├── evaluateAP.py
│ │ ├── evaluatePCKh.py
│ │ ├── evaluateTracking.py
│ │ └── posetrack18_id2fname.py
│ └── trackeval/
│ ├── __init__.py
│ ├── _timing.py
│ ├── datasets/
│ │ ├── __init__.py
│ │ ├── _base_dataset.py
│ │ ├── bdd100k.py
│ │ ├── davis.py
│ │ ├── kitti_2d_box.py
│ │ ├── kitti_mots.py
│ │ ├── mot_challenge_2d_box.py
│ │ ├── mots_challenge.py
│ │ ├── tao.py
│ │ └── youtube_vis.py
│ ├── eval.py
│ ├── metrics/
│ │ ├── __init__.py
│ │ ├── _base_metric.py
│ │ ├── clear.py
│ │ ├── count.py
│ │ ├── hota.py
│ │ ├── identity.py
│ │ ├── j_and_f.py
│ │ ├── track_map.py
│ │ └── vace.py
│ ├── plotting.py
│ └── utils.py
├── eval.sh
├── model/
│ ├── __init__.py
│ ├── functional.py
│ ├── hrnet.py
│ ├── model.py
│ ├── random_feat_generator.py
│ └── resnet.py
├── requirements.txt
├── setup.py
├── test/
│ ├── test_mot.py
│ ├── test_mots.py
│ ├── test_poseprop.py
│ ├── test_posetrack.py
│ ├── test_sot_cfnet.py
│ ├── test_sot_siamfc.py
│ ├── test_vis.py
│ └── test_vos.py
├── tools/
│ ├── gen_mot16_fairmot.py
│ ├── gen_mot16_gt.py
│ ├── gen_mot16_label17.py
│ ├── gen_mot19_det.py
│ ├── gen_mots_costa.py
│ └── gen_mots_gt.py
├── tracker/
│ ├── mot/
│ │ ├── basetrack.py
│ │ ├── box.py
│ │ ├── mask.py
│ │ ├── multitracker.py
│ │ └── pose.py
│ └── sot/
│ └── lib/
│ ├── core/
│ │ ├── config.py
│ │ ├── config_ocean.py
│ │ ├── config_oceanplus.py
│ │ ├── config_siamdw.py
│ │ ├── eval_davis.py
│ │ ├── eval_got10k.py
│ │ ├── eval_lasot.py
│ │ ├── eval_otb.py
│ │ ├── eval_visdrone.py
│ │ ├── extract_tune_logs.py
│ │ └── function.py
│ ├── dataset/
│ │ ├── crop/
│ │ │ ├── DAVIS/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── RGBT210/
│ │ │ │ ├── RGBT210_genjson.py
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── RGBT234/
│ │ │ │ ├── RGBT234_genjson.py
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── coco/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── det/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ └── readme.md
│ │ │ ├── got10k/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ ├── parser_got10k.py
│ │ │ │ └── readme.md
│ │ │ ├── lasot/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ ├── parser_lasot.py
│ │ │ │ └── readme.md
│ │ │ ├── vid/
│ │ │ │ ├── gen_json.py
│ │ │ │ ├── par_crop.py
│ │ │ │ ├── parse_vid.py
│ │ │ │ └── readme.md
│ │ │ └── visdrone/
│ │ │ ├── gen_json.py
│ │ │ ├── par_crop.py
│ │ │ ├── parser_visdrone.py
│ │ │ └── readme.md
│ │ ├── ocean.py
│ │ └── siamfc.py
│ ├── eval_toolkit/
│ │ ├── bin/
│ │ │ ├── _init_paths.py
│ │ │ └── eval.py
│ │ ├── pysot/
│ │ │ ├── __init__.py
│ │ │ ├── datasets/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── dataset.py
│ │ │ │ ├── got10k.py
│ │ │ │ ├── lasot.py
│ │ │ │ ├── nfs.py
│ │ │ │ ├── otb.py
│ │ │ │ ├── trackingnet.py
│ │ │ │ ├── uav.py
│ │ │ │ ├── video.py
│ │ │ │ └── vot.py
│ │ │ ├── evaluation/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── ar_benchmark.py
│ │ │ │ ├── eao_benchmark.py
│ │ │ │ ├── f1_benchmark.py
│ │ │ │ └── ope_benchmark.py
│ │ │ ├── utils/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── c_region.pxd
│ │ │ │ ├── misc.py
│ │ │ │ ├── region.c
│ │ │ │ ├── region.pyx
│ │ │ │ ├── setup.py
│ │ │ │ ├── src/
│ │ │ │ │ ├── buffer.h
│ │ │ │ │ ├── region.c
│ │ │ │ │ └── region.h
│ │ │ │ └── statistics.py
│ │ │ └── visualization/
│ │ │ ├── __init__.py
│ │ │ ├── draw_eao.py
│ │ │ ├── draw_f1.py
│ │ │ ├── draw_success_precision.py
│ │ │ └── draw_utils.py
│ │ └── requirements.txt
│ ├── models/
│ │ ├── __init__.py
│ │ ├── backbones.py
│ │ ├── cfnet.py
│ │ ├── connect.py
│ │ ├── modules.py
│ │ ├── online/
│ │ │ ├── __init__.py
│ │ │ ├── backbone/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── resnet.py
│ │ │ │ └── resnet18_vggm.py
│ │ │ ├── bbreg/
│ │ │ │ ├── __init__.py
│ │ │ │ └── iou_net.py
│ │ │ ├── classifier/
│ │ │ │ ├── __init__.py
│ │ │ │ ├── features.py
│ │ │ │ ├── initializer.py
│ │ │ │ ├── linear_filter.py
│ │ │ │ └── optimizer.py
│ │ │ └── layers/
│ │ │ ├── __init__.py
│ │ │ ├── activation.py
│ │ │ ├── blocks.py
│ │ │ ├── distance.py
│ │ │ ├── filter.py
│ │ │ ├── normalization.py
│ │ │ └── transform.py
│ │ └── siamfc.py
│ ├── online/
│ │ ├── __init__.py
│ │ ├── augmentation.py
│ │ ├── base_actor.py
│ │ ├── base_trainer.py
│ │ ├── complex.py
│ │ ├── dcf.py
│ │ ├── extractor.py
│ │ ├── fourier.py
│ │ ├── loading.py
│ │ ├── ltr_trainer.py
│ │ ├── model_constructor.py
│ │ ├── operation.py
│ │ ├── optim.py
│ │ ├── optimization.py
│ │ ├── preprocessing.py
│ │ ├── tensordict.py
│ │ ├── tensorlist.py
│ │ └── tracking.py
│ ├── tracker/
│ │ ├── ocean.py
│ │ ├── oceanplus.py
│ │ ├── online.py
│ │ └── siamfc.py
│ ├── utils/
│ │ ├── __init__.py
│ │ ├── cutout.py
│ │ ├── extract_tpejson_fc.py
│ │ ├── extract_tpejson_ocean.py
│ │ ├── extract_tpelog.py
│ │ ├── extract_tpelog_fc.py
│ │ ├── utils.py
│ │ └── watch_tpe.sh
│ └── version.py
└── utils/
├── __init__.py
├── box.py
├── io.py
├── log.py
├── mask.py
├── meter.py
├── palette.py
└── visualize.py
SYMBOL INDEX (2141 symbols across 241 files)
FILE: core/association/matching.py
function merge_matches (line 14) | def merge_matches(m1, m2, shape):
function linear_assignment (line 31) | def linear_assignment(cost_matrix, thresh):
function ious (line 45) | def ious(atlbrs, btlbrs):
function iou_distance (line 65) | def iou_distance(atracks, btracks):
function embedding_distance (line 85) | def embedding_distance(tracks, detections, metric='cosine'):
function fuse_motion (line 102) | def fuse_motion(kf, cost_matrix, tracks, detections, only_position=False...
function center_emb_distance (line 117) | def center_emb_distance(tracks, detections, metric='cosine'):
function recons_distance (line 136) | def recons_distance(tracks, detections, tmp=100):
function get_track_feat (line 176) | def get_track_feat(tracks, feat_flag='curr'):
function reconsdot_distance (line 196) | def reconsdot_distance(tracks, detections, tmp=100):
function category_gate (line 243) | def category_gate(cost_matrix, tracks, detections):
FILE: core/motion/kalman_filter.py
class KalmanFilter (line 23) | class KalmanFilter(object):
method __init__ (line 40) | def __init__(self):
method initiate (line 55) | def initiate(self, measurement):
method predict (line 88) | def predict(self, mean, covariance):
method project (line 125) | def project(self, mean, covariance):
method multi_predict (line 154) | def multi_predict(self, mean, covariance):
method update (line 196) | def update(self, mean, covariance, measurement):
method gating_distance (line 230) | def gating_distance(self, mean, covariance, measurements,
FILE: core/propagation/__init__.py
function propagate (line 16) | def propagate(temp_feats, obs, img, model, format='box'):
FILE: core/propagation/propagate_box.py
function propagate_box (line 12) | def propagate_box(temp_feats, box, img, model):
FILE: core/propagation/propagate_mask.py
function propagate_mask (line 12) | def propagate_mask(temp_feats, mask, img, model):
FILE: core/propagation/propagate_pose.py
function propagate_pose (line 12) | def propagate_pose(temp_feats, pose, img, model):
FILE: data/jhmdb.py
function resize (line 14) | def resize(img, owidth, oheight):
function load_image (line 20) | def load_image(img_path):
function color_normalize (line 30) | def color_normalize(x, mean, std):
function try_np_load (line 45) | def try_np_load(p):
function make_lbl_set (line 51) | def make_lbl_set(lbls):
function texturize (line 71) | def texturize(onehot):
class JhmdbSet (line 101) | class JhmdbSet(torch.utils.data.Dataset):
method __init__ (line 102) | def __init__(self, args, sigma=0.5):
method get_onehot_lbl (line 125) | def get_onehot_lbl(self, lbl_path):
method make_paths (line 133) | def make_paths(self, folder_path, label_path):
method __getitem__ (line 150) | def __getitem__(self, index):
method __len__ (line 257) | def __len__(self):
function draw_labelmap_np (line 261) | def draw_labelmap_np(img, pt, sigma, type='Gaussian'):
FILE: data/kinetics.py
class Kinetics400 (line 10) | class Kinetics400(VisionDataset):
method __init__ (line 42) | def __init__(self, root, frames_per_clip, step_between_clips=1, frame_...
method __len__ (line 62) | def __len__(self):
method __getitem__ (line 65) | def __getitem__(self, idx):
FILE: data/video.py
class LoadImages (line 16) | class LoadImages: # for inference
method __init__ (line 17) | def __init__(self, path, img_size=(1088, 608)):
method __iter__ (line 33) | def __iter__(self):
method __next__ (line 37) | def __next__(self):
method __getitem__ (line 57) | def __getitem__(self, idx):
method __len__ (line 75) | def __len__(self):
class LoadVideo (line 79) | class LoadVideo: # for inference
method __init__ (line 80) | def __init__(self, path, img_size=(1088, 608)):
method get_size (line 94) | def get_size(self, vw, vh, dw, dh):
method __iter__ (line 99) | def __iter__(self):
method __next__ (line 103) | def __next__(self):
method __len__ (line 121) | def __len__(self):
class LoadImagesAndObs (line 125) | class LoadImagesAndObs:
method __init__ (line 126) | def __init__(self, path, opt):
method __getitem__ (line 147) | def __getitem__(self, files_index):
method get_data (line 152) | def get_data(self, img_path, label_path):
method __len__ (line 193) | def __len__(self):
class LoadImagesAndObsTAO (line 196) | class LoadImagesAndObsTAO:
method __init__ (line 197) | def __init__(self, root, video_meta, obs, opt):
method __getitem__ (line 206) | def __getitem__(self, index):
method __len__ (line 241) | def __len__(self):
class LoadImagesAndMaskObsVIS (line 246) | class LoadImagesAndMaskObsVIS:
method __init__ (line 247) | def __init__(self, path, info, obs, opt):
method __getitem__ (line 256) | def __getitem__(self, idx):
method __len__ (line 282) | def __len__(self):
class LoadImagesAndMaskObsMOTS (line 286) | class LoadImagesAndMaskObsMOTS(LoadImagesAndObs):
method __init__ (line 287) | def __init__(self, path, opt):
method get_data (line 290) | def get_data(self, img_path, label_path):
class LoadImagesAndPoseObs (line 321) | class LoadImagesAndPoseObs(LoadImagesAndObs):
method __init__ (line 322) | def __init__(self, obs_jpath, opt):
method __getitem__ (line 331) | def __getitem__(self, idx):
function letterbox (line 358) | def letterbox(img, height=608, width=1088, color=(127.5, 127.5, 127.5)):...
FILE: data/vos.py
function resize (line 15) | def resize(img, owidth, oheight):
function load_image (line 22) | def load_image(img):
function color_normalize (line 35) | def color_normalize(x, mean, std):
function try_np_load (line 44) | def try_np_load(p):
function make_lbl_set (line 50) | def make_lbl_set(lbls):
function texturize (line 58) | def texturize(onehot):
class VOSDataset (line 85) | class VOSDataset(torch.utils.data.Dataset):
method __init__ (line 86) | def __init__(self, args):
method get_onehot_lbl (line 113) | def get_onehot_lbl(self, lbl_path):
method make_paths (line 121) | def make_paths(self, folder_path, label_path):
method __getitem__ (line 142) | def __getitem__(self, index):
method __len__ (line 272) | def __len__(self):
FILE: demo/mot_demo.py
function make_parser (line 33) | def make_parser():
function dets2obs (line 68) | def dets2obs(dets, imginfo, cls):
function eval_seq (line 88) | def eval_seq(opt, dataloader, detector, tracker,
function main (line 134) | def main(exp, args):
FILE: demo/sot_demo.py
function get_frames (line 32) | def get_frames(video_name):
function preproc (line 61) | def preproc(img, im_mean, im_std, use_lab=False):
class TrackerConfig (line 75) | class TrackerConfig(object):
function track (line 95) | def track(net, args):
function main (line 166) | def main():
FILE: detector/YOLOX/demo.py
function make_parser (line 23) | def make_parser():
function get_image_list (line 73) | def get_image_list(path):
class Predictor (line 84) | class Predictor(object):
method __init__ (line 85) | def __init__(self, model, exp, cls_names=COCO_CLASSES, trt_file=None, ...
method inference (line 105) | def inference(self, img):
method visual (line 135) | def visual(self, output, img_info, cls_conf=0.35):
function image_demo (line 154) | def image_demo(predictor, vis_folder, path, current_time, save_result):
function imageflow_demo (line 176) | def imageflow_demo(predictor, vis_folder, current_time, args):
function main (line 205) | def main(exp, args):
FILE: detector/YOLOX/demo/ONNXRuntime/onnx_inference.py
function make_parser (line 18) | def make_parser():
FILE: detector/YOLOX/demo/OpenVINO/cpp/yolox_openvino.cpp
function static_resize (line 27) | cv::Mat static_resize(cv::Mat& img) {
function blobFromImage (line 39) | void blobFromImage(cv::Mat& img, Blob::Ptr& blob){
type Object (line 71) | struct Object
type GridAndStride (line 78) | struct GridAndStride
function generate_grids_and_stride (line 85) | static void generate_grids_and_stride(const int target_size, std::vector...
function generate_yolox_proposals (line 101) | static void generate_yolox_proposals(std::vector<GridAndStride> grid_str...
function intersection_area (line 148) | static inline float intersection_area(const Object& a, const Object& b)
function qsort_descent_inplace (line 154) | static void qsort_descent_inplace(std::vector<Object>& faceobjects, int ...
function qsort_descent_inplace (line 192) | static void qsort_descent_inplace(std::vector<Object>& objects)
function nms_sorted_bboxes (line 200) | static void nms_sorted_bboxes(const std::vector<Object>& faceobjects, st...
function decode_outputs (line 235) | static void decode_outputs(const float* prob, std::vector<Object>& objec...
function draw_objects (line 356) | static void draw_objects(const cv::Mat& bgr, const std::vector<Object>& ...
function main (line 420) | int main(int argc, char* argv[]) {
FILE: detector/YOLOX/demo/OpenVINO/python/openvino_inference.py
function parse_args (line 22) | def parse_args() -> argparse.Namespace:
function main (line 78) | def main():
FILE: detector/YOLOX/demo/TensorRT/cpp/logging.h
function class (line 31) | class LogStreamConsumerBuffer : public std::stringbuf
function class (line 106) | class LogStreamConsumerBase
function std (line 160) | static std::string severityPrefix(Severity severity)
function TestResult (line 213) | enum class TestResult
function LogStreamConsumer (line 447) | inline LogStreamConsumer LOG_VERBOSE(const Logger& logger)
function LogStreamConsumer (line 459) | inline LogStreamConsumer LOG_INFO(const Logger& logger)
function LogStreamConsumer (line 471) | inline LogStreamConsumer LOG_WARN(const Logger& logger)
function LogStreamConsumer (line 483) | inline LogStreamConsumer LOG_ERROR(const Logger& logger)
function LogStreamConsumer (line 496) | inline LogStreamConsumer LOG_FATAL(const Logger& logger)
FILE: detector/YOLOX/demo/TensorRT/cpp/yolox.cpp
function static_resize (line 37) | cv::Mat static_resize(cv::Mat& img) {
type Object (line 49) | struct Object
type GridAndStride (line 56) | struct GridAndStride
function generate_grids_and_stride (line 63) | static void generate_grids_and_stride(const int target_size, std::vector...
function intersection_area (line 78) | static inline float intersection_area(const Object& a, const Object& b)
function qsort_descent_inplace (line 84) | static void qsort_descent_inplace(std::vector<Object>& faceobjects, int ...
function qsort_descent_inplace (line 121) | static void qsort_descent_inplace(std::vector<Object>& objects)
function nms_sorted_bboxes (line 129) | static void nms_sorted_bboxes(const std::vector<Object>& faceobjects, st...
function generate_yolox_proposals (line 164) | static void generate_yolox_proposals(std::vector<GridAndStride> grid_str...
function decode_outputs (line 233) | static void decode_outputs(float* prob, std::vector<Object>& objects, fl...
function draw_objects (line 359) | static void draw_objects(const cv::Mat& bgr, const std::vector<Object>& ...
function doInference (line 423) | void doInference(IExecutionContext& context, float* input, float* output...
function main (line 460) | int main(int argc, char** argv) {
FILE: detector/YOLOX/demo/ncnn/android/app/src/main/java/com/megvii/yoloXncnn/MainActivity.java
class MainActivity (line 28) | public class MainActivity extends Activity
method onCreate (line 39) | @Override
method showObjects (line 89) | private void showObjects(YOLOXncnn.Obj[] objects)
method onActivityResult (line 166) | @Override
method decodeUri (line 192) | private Bitmap decodeUri(Uri selectedImage) throws FileNotFoundException
FILE: detector/YOLOX/demo/ncnn/android/app/src/main/java/com/megvii/yoloXncnn/YOLOXncnn.java
class YOLOXncnn (line 8) | public class YOLOXncnn
method Init (line 10) | public native boolean Init(AssetManager mgr);
class Obj (line 12) | public class Obj
method Detect (line 22) | public native Obj[] Detect(Bitmap bitmap, boolean use_gpu);
FILE: detector/YOLOX/demo/ncnn/android/app/src/main/java/com/megvii/yoloXncnn/yoloXncnn.java
class YOLOXncnn (line 8) | public class YOLOXncnn
method Init (line 10) | public native boolean Init(AssetManager mgr);
class Obj (line 12) | public class Obj
method Detect (line 22) | public native Obj[] Detect(Bitmap bitmap, boolean use_gpu);
FILE: detector/YOLOX/demo/ncnn/android/app/src/main/jni/yoloXncnn_jni.cpp
class YoloV5Focus (line 25) | class YoloV5Focus : public ncnn::Layer
method YoloV5Focus (line 28) | YoloV5Focus()
method forward (line 33) | virtual int forward(const ncnn::Mat& bottom_blob, ncnn::Mat& top_blob,...
type Object (line 73) | struct Object
type GridAndStride (line 83) | struct GridAndStride
function intersection_area (line 90) | static inline float intersection_area(const Object& a, const Object& b)
function qsort_descent_inplace (line 104) | static void qsort_descent_inplace(std::vector<Object>& faceobjects, int ...
function qsort_descent_inplace (line 141) | static void qsort_descent_inplace(std::vector<Object>& faceobjects)
function nms_sorted_bboxes (line 149) | static void nms_sorted_bboxes(const std::vector<Object>& faceobjects, st...
function generate_grids_and_stride (line 183) | static void generate_grids_and_stride(const int target_size, std::vector...
function generate_yolox_proposals (line 198) | static void generate_yolox_proposals(std::vector<GridAndStride> grid_str...
function JNIEXPORT (line 261) | JNIEXPORT jint JNI_OnLoad(JavaVM* vm, void* reserved)
function JNIEXPORT (line 270) | JNIEXPORT void JNI_OnUnload(JavaVM* vm, void* reserved)
function JNIEXPORT (line 278) | JNIEXPORT jboolean JNICALL Java_com_megvii_yoloXncnn_YOLOXncnn_Init(JNIE...
function JNIEXPORT (line 334) | JNIEXPORT jobjectArray JNICALL Java_com_megvii_yoloXncnn_YOLOXncnn_Detec...
FILE: detector/YOLOX/demo/ncnn/cpp/yolox.cpp
class YoloV5Focus (line 31) | class YoloV5Focus : public ncnn::Layer
method YoloV5Focus (line 34) | YoloV5Focus()
method forward (line 39) | virtual int forward(const ncnn::Mat& bottom_blob, ncnn::Mat& top_blob,...
type Object (line 79) | struct Object
type GridAndStride (line 86) | struct GridAndStride
function intersection_area (line 93) | static inline float intersection_area(const Object& a, const Object& b)
function qsort_descent_inplace (line 99) | static void qsort_descent_inplace(std::vector<Object>& faceobjects, int ...
function qsort_descent_inplace (line 136) | static void qsort_descent_inplace(std::vector<Object>& objects)
function nms_sorted_bboxes (line 144) | static void nms_sorted_bboxes(const std::vector<Object>& faceobjects, st...
function generate_grids_and_stride (line 178) | static void generate_grids_and_stride(const int target_size, std::vector...
function generate_yolox_proposals (line 193) | static void generate_yolox_proposals(std::vector<GridAndStride> grid_str...
function detect_yolox (line 243) | static int detect_yolox(const cv::Mat& bgr, std::vector<Object>& objects)
function draw_objects (line 347) | static void draw_objects(const cv::Mat& bgr, const std::vector<Object>& ...
function main (line 396) | int main(int argc, char** argv)
FILE: detector/YOLOX/exps/default/nano.py
class Exp (line 11) | class Exp(MyExp):
method __init__ (line 12) | def __init__(self):
method get_model (line 22) | def get_model(self, sublinear=False):
FILE: detector/YOLOX/exps/default/yolov3.py
class Exp (line 12) | class Exp(MyExp):
method __init__ (line 13) | def __init__(self):
method get_model (line 19) | def get_model(self, sublinear=False):
method get_data_loader (line 35) | def get_data_loader(self, batch_size, is_distributed, no_aug=False):
FILE: detector/YOLOX/exps/default/yolox_l.py
class Exp (line 10) | class Exp(MyExp):
method __init__ (line 11) | def __init__(self):
FILE: detector/YOLOX/exps/default/yolox_m.py
class Exp (line 10) | class Exp(MyExp):
method __init__ (line 11) | def __init__(self):
FILE: detector/YOLOX/exps/default/yolox_s.py
class Exp (line 10) | class Exp(MyExp):
method __init__ (line 11) | def __init__(self):
FILE: detector/YOLOX/exps/default/yolox_tiny.py
class Exp (line 10) | class Exp(MyExp):
method __init__ (line 11) | def __init__(self):
FILE: detector/YOLOX/exps/default/yolox_x.py
class Exp (line 10) | class Exp(MyExp):
method __init__ (line 11) | def __init__(self):
FILE: detector/YOLOX/exps/example/yolox_voc/yolox_voc_s.py
class Exp (line 11) | class Exp(MyExp):
method __init__ (line 12) | def __init__(self):
method get_data_loader (line 19) | def get_data_loader(self, batch_size, is_distributed, no_aug=False):
method get_eval_loader (line 80) | def get_eval_loader(self, batch_size, is_distributed, testdev=False):
method get_evaluator (line 111) | def get_evaluator(self, batch_size, is_distributed, testdev=False):
FILE: detector/YOLOX/setup.py
function get_extensions (line 15) | def get_extensions():
FILE: detector/YOLOX/tools/demo.py
function make_parser (line 22) | def make_parser():
function get_image_list (line 72) | def get_image_list(path):
class Predictor (line 83) | class Predictor(object):
method __init__ (line 84) | def __init__(self, model, exp, cls_names=COCO_CLASSES, trt_file=None, ...
method inference (line 104) | def inference(self, img):
method visual (line 133) | def visual(self, output, img_info, cls_conf=0.35):
function image_demo (line 152) | def image_demo(predictor, vis_folder, path, current_time, save_result):
function imageflow_demo (line 174) | def imageflow_demo(predictor, vis_folder, current_time, args):
function main (line 203) | def main(exp, args):
FILE: detector/YOLOX/tools/eval.py
function make_parser (line 20) | def make_parser():
function main (line 98) | def main(exp, num_gpu, args):
FILE: detector/YOLOX/tools/export_onnx.py
function make_parser (line 17) | def make_parser():
function main (line 48) | def main():
FILE: detector/YOLOX/tools/train.py
function make_parser (line 18) | def make_parser():
function main (line 82) | def main(exp, args):
FILE: detector/YOLOX/tools/trt.py
function make_parser (line 17) | def make_parser():
function main (line 34) | def main():
FILE: detector/YOLOX/yolox/core/launch.py
function _find_free_port (line 19) | def _find_free_port():
function launch (line 34) | def launch(
function _distributed_worker (line 71) | def _distributed_worker(
FILE: detector/YOLOX/yolox/core/trainer.py
class Trainer (line 33) | class Trainer:
method __init__ (line 35) | def __init__(self, exp, args):
method train (line 67) | def train(self):
method train_in_epoch (line 76) | def train_in_epoch(self):
method train_in_iter (line 82) | def train_in_iter(self):
method train_one_iter (line 88) | def train_one_iter(self):
method before_train (line 123) | def before_train(self):
method after_train (line 182) | def after_train(self):
method before_epoch (line 187) | def before_epoch(self):
method after_epoch (line 202) | def after_epoch(self):
method before_iter (line 212) | def before_iter(self):
method after_iter (line 215) | def after_iter(self):
method progress_in_iter (line 256) | def progress_in_iter(self):
method resume_train (line 259) | def resume_train(self, model):
method evaluate_and_save_model (line 291) | def evaluate_and_save_model(self):
method save_ckpt (line 304) | def save_ckpt(self, ckpt_name, update_best_ckpt=False):
FILE: detector/YOLOX/yolox/data/data_augment.py
function augment_hsv (line 21) | def augment_hsv(img, hgain=0.015, sgain=0.7, vgain=0.4):
function box_candidates (line 37) | def box_candidates(box1, box2, wh_thr=2, ar_thr=20, area_thr=0.2):
function random_perspective (line 52) | def random_perspective(
function _distort (line 126) | def _distort(image):
function _mirror (line 156) | def _mirror(image, boxes):
function preproc (line 165) | def preproc(image, input_size, mean, std, swap=(2, 0, 1)):
class TrainTransform (line 190) | class TrainTransform:
method __init__ (line 191) | def __init__(self, p=0.5, rgb_means=None, std=None, max_labels=50):
method __call__ (line 197) | def __call__(self, image, targets, input_dim):
class ValTransform (line 275) | class ValTransform:
method __init__ (line 293) | def __init__(self, rgb_means=None, std=None, swap=(2, 0, 1)):
method __call__ (line 299) | def __call__(self, img, res, input_size):
FILE: detector/YOLOX/yolox/data/data_prefetcher.py
class DataPrefetcher (line 13) | class DataPrefetcher:
method __init__ (line 21) | def __init__(self, loader):
method preload (line 28) | def preload(self):
method next (line 40) | def next(self):
method _input_cuda_for_image (line 51) | def _input_cuda_for_image(self):
method _record_stream_for_image (line 55) | def _record_stream_for_image(input):
function random_resize (line 59) | def random_resize(data_loader, exp, epoch, rank, is_distributed):
FILE: detector/YOLOX/yolox/data/dataloading.py
function get_yolox_datadir (line 15) | def get_yolox_datadir():
class DataLoader (line 28) | class DataLoader(torchDataLoader):
method __init__ (line 71) | def __init__(self, *args, **kwargs):
method close_mosaic (line 119) | def close_mosaic(self):
method change_input_dim (line 122) | def change_input_dim(self, multiple=32, random_range=(10, 19)):
function list_collate (line 163) | def list_collate(batch):
FILE: detector/YOLOX/yolox/data/datasets/coco.py
class COCODataset (line 15) | class COCODataset(Dataset):
method __init__ (line 20) | def __init__(
method __len__ (line 52) | def __len__(self):
method load_anno (line 55) | def load_anno(self, index):
method pull_item (line 86) | def pull_item(self, index):
method __getitem__ (line 108) | def __getitem__(self, index):
FILE: detector/YOLOX/yolox/data/datasets/datasets_wrapper.py
class ConcatDataset (line 12) | class ConcatDataset(torchConcatDataset):
method __init__ (line 13) | def __init__(self, datasets):
method pull_item (line 19) | def pull_item(self, idx):
class MixConcatDataset (line 34) | class MixConcatDataset(torchConcatDataset):
method __init__ (line 35) | def __init__(self, datasets):
method __getitem__ (line 41) | def __getitem__(self, index):
class Dataset (line 62) | class Dataset(torchDataset):
method __init__ (line 70) | def __init__(self, input_dimension, mosaic=True):
method input_dim (line 76) | def input_dim(self):
method resize_getitem (line 90) | def resize_getitem(getitem_fn):
FILE: detector/YOLOX/yolox/data/datasets/mosaicdetection.py
function get_mosaic_coordinate (line 16) | def get_mosaic_coordinate(mosaic_image, mosaic_index, xc, yc, w, h, inpu...
class MosaicDetection (line 37) | class MosaicDetection(Dataset):
method __init__ (line 40) | def __init__(
method __len__ (line 73) | def __len__(self):
method __getitem__ (line 77) | def __getitem__(self, idx):
method mixup (line 153) | def mixup(self, origin_img, origin_labels, input_dim):
FILE: detector/YOLOX/yolox/data/datasets/voc.py
class AnnotationTransform (line 23) | class AnnotationTransform(object):
method __init__ (line 37) | def __init__(self, class_to_ind=None, keep_difficult=True):
method __call__ (line 41) | def __call__(self, target):
class VOCDetection (line 72) | class VOCDetection(Dataset):
method __init__ (line 91) | def __init__(
method __len__ (line 119) | def __len__(self):
method load_anno (line 122) | def load_anno(self, index):
method pull_item (line 130) | def pull_item(self, index):
method __getitem__ (line 152) | def __getitem__(self, index):
method evaluate_detections (line 160) | def evaluate_detections(self, all_boxes, output_dir=None):
method _get_voc_results_file_template (line 182) | def _get_voc_results_file_template(self):
method _write_voc_results_file (line 190) | def _write_voc_results_file(self, all_boxes):
method _do_python_eval (line 215) | def _do_python_eval(self, output_dir="output", iou=0.5):
FILE: detector/YOLOX/yolox/data/samplers.py
class YoloBatchSampler (line 14) | class YoloBatchSampler(torchBatchSampler):
method __init__ (line 21) | def __init__(self, *args, input_dimension=None, mosaic=True, **kwargs):
method __iter__ (line 27) | def __iter__(self):
method __set_input_dim (line 33) | def __set_input_dim(self):
class InfiniteSampler (line 40) | class InfiniteSampler(Sampler):
method __init__ (line 51) | def __init__(
method __iter__ (line 79) | def __iter__(self):
method _infinite_indices (line 85) | def _infinite_indices(self):
method __len__ (line 94) | def __len__(self):
FILE: detector/YOLOX/yolox/evaluators/coco_evaluator.py
class COCOEvaluator (line 26) | class COCOEvaluator:
method __init__ (line 32) | def __init__(
method evaluate (line 51) | def evaluate(
method convert_to_coco_format (line 135) | def convert_to_coco_format(self, outputs, info_imgs, ids):
method evaluate_prediction (line 167) | def evaluate_prediction(self, data_dict, statistics):
FILE: detector/YOLOX/yolox/evaluators/voc_eval.py
function parse_rec (line 15) | def parse_rec(filename):
function voc_ap (line 37) | def voc_ap(rec, prec, use_07_metric=False):
function voc_eval (line 71) | def voc_eval(
FILE: detector/YOLOX/yolox/evaluators/voc_evaluator.py
class VOCEvaluator (line 19) | class VOCEvaluator:
method __init__ (line 24) | def __init__(
method evaluate (line 43) | def evaluate(
method convert_to_voc_format (line 118) | def convert_to_voc_format(self, outputs, info_imgs, ids):
method evaluate_prediction (line 138) | def evaluate_prediction(self, data_dict, statistics):
FILE: detector/YOLOX/yolox/exp/base_exp.py
class BaseExp (line 17) | class BaseExp(metaclass=ABCMeta):
method __init__ (line 21) | def __init__(self):
method get_model (line 28) | def get_model(self) -> Module:
method get_data_loader (line 32) | def get_data_loader(
method get_optimizer (line 38) | def get_optimizer(self, batch_size: int) -> torch.optim.Optimizer:
method get_lr_scheduler (line 42) | def get_lr_scheduler(
method get_evaluator (line 48) | def get_evaluator(self):
method eval (line 52) | def eval(self, model, evaluator, weights):
method __repr__ (line 55) | def __repr__(self):
method merge (line 62) | def merge(self, cfg_list):
FILE: detector/YOLOX/yolox/exp/build.py
function get_exp_by_file (line 10) | def get_exp_by_file(exp_file):
function get_exp_by_name (line 17) | def get_exp_by_name(exp_name):
function get_exp (line 34) | def get_exp(exp_file, exp_name):
FILE: detector/YOLOX/yolox/exp/yolox_base.py
class Exp (line 15) | class Exp(BaseExp):
method __init__ (line 17) | def __init__(self):
method get_model (line 63) | def get_model(self):
method get_data_loader (line 82) | def get_data_loader(self, batch_size, is_distributed, no_aug=False):
method random_resize (line 143) | def random_resize(self, data_loader, epoch, rank, is_distributed):
method get_optimizer (line 162) | def get_optimizer(self, batch_size):
method get_lr_scheduler (line 190) | def get_lr_scheduler(self, lr, iters_per_epoch):
method get_eval_loader (line 204) | def get_eval_loader(self, batch_size, is_distributed, testdev=False):
method get_evaluator (line 235) | def get_evaluator(self, batch_size, is_distributed, testdev=False):
method eval (line 249) | def eval(self, model, evaluator, is_distributed, half=False):
FILE: detector/YOLOX/yolox/layers/csrc/cocoeval/cocoeval.cpp
type COCOeval (line 10) | namespace COCOeval {
function SortInstancesByDetectionScore (line 16) | void SortInstancesByDetectionScore(
function SortInstancesByIgnore (line 32) | void SortInstancesByIgnore(
function MatchDetectionsToGroundTruth (line 59) | void MatchDetectionsToGroundTruth(
function EvaluateImages (line 140) | std::vector<ImageEvaluation> EvaluateImages(
function list_to_vec (line 201) | std::vector<T> list_to_vec(const py::list& l) {
function BuildSortedDetectionList (line 221) | int BuildSortedDetectionList(
function ComputePrecisionRecallCurve (line 282) | void ComputePrecisionRecallCurve(
function Accumulate (line 370) | py::dict Accumulate(
FILE: detector/YOLOX/yolox/layers/csrc/cocoeval/cocoeval.h
function namespace (line 12) | namespace COCOeval {
FILE: detector/YOLOX/yolox/layers/csrc/vision.cpp
function PYBIND11_MODULE (line 3) | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
FILE: detector/YOLOX/yolox/layers/fast_coco_eval_api.py
class COCOeval_opt (line 19) | class COCOeval_opt(COCOeval):
method evaluate (line 25) | def evaluate(self):
method accumulate (line 122) | def accumulate(self):
FILE: detector/YOLOX/yolox/models/darknet.py
class Darknet (line 10) | class Darknet(nn.Module):
method __init__ (line 14) | def __init__(
method make_group_layer (line 49) | def make_group_layer(self, in_channels: int, num_blocks: int, stride: ...
method make_spp_block (line 56) | def make_spp_block(self, filters_list, in_filters):
method forward (line 72) | def forward(self, x):
class CSPDarknet (line 87) | class CSPDarknet(nn.Module):
method __init__ (line 89) | def __init__(
method forward (line 142) | def forward(self, x):
FILE: detector/YOLOX/yolox/models/losses.py
class IOUloss (line 9) | class IOUloss(nn.Module):
method __init__ (line 10) | def __init__(self, reduction="none", loss_type="iou"):
method forward (line 15) | def forward(self, pred, target):
FILE: detector/YOLOX/yolox/models/network_blocks.py
class SiLU (line 9) | class SiLU(nn.Module):
method forward (line 13) | def forward(x):
function get_activation (line 17) | def get_activation(name="silu", inplace=True):
class BaseConv (line 29) | class BaseConv(nn.Module):
method __init__ (line 32) | def __init__(self, in_channels, out_channels, ksize, stride, groups=1,...
method forward (line 48) | def forward(self, x):
method fuseforward (line 51) | def fuseforward(self, x):
class DWConv (line 55) | class DWConv(nn.Module):
method __init__ (line 57) | def __init__(self, in_channels, out_channels, ksize, stride=1, act="si...
method forward (line 68) | def forward(self, x):
class Bottleneck (line 73) | class Bottleneck(nn.Module):
method __init__ (line 75) | def __init__(
method forward (line 86) | def forward(self, x):
class ResLayer (line 93) | class ResLayer(nn.Module):
method __init__ (line 95) | def __init__(self, in_channels: int):
method forward (line 101) | def forward(self, x):
class SPPBottleneck (line 106) | class SPPBottleneck(nn.Module):
method __init__ (line 108) | def __init__(self, in_channels, out_channels, kernel_sizes=(5, 9, 13),...
method forward (line 118) | def forward(self, x):
class CSPLayer (line 125) | class CSPLayer(nn.Module):
method __init__ (line 128) | def __init__(
method forward (line 150) | def forward(self, x):
class Focus (line 158) | class Focus(nn.Module):
method __init__ (line 161) | def __init__(self, in_channels, out_channels, ksize=1, stride=1, act="...
method forward (line 165) | def forward(self, x):
FILE: detector/YOLOX/yolox/models/yolo_fpn.py
class YOLOFPN (line 12) | class YOLOFPN(nn.Module):
method __init__ (line 17) | def __init__(
method _make_cbl (line 36) | def _make_cbl(self, _in, _out, ks):
method _make_embedding (line 39) | def _make_embedding(self, filters_list, in_filters):
method load_pretrained_model (line 53) | def load_pretrained_model(self, filename="./weights/darknet53.mix.pth"):
method forward (line 59) | def forward(self, inputs):
FILE: detector/YOLOX/yolox/models/yolo_head.py
class YOLOXHead (line 18) | class YOLOXHead(nn.Module):
method __init__ (line 19) | def __init__(
method initialize_biases (line 128) | def initialize_biases(self, prior_prob):
method forward (line 139) | def forward(self, xin, labels=None, imgs=None):
method get_output_and_grid (line 197) | def get_output_and_grid(self, output, k, stride, dtype):
method decode_outputs (line 218) | def decode_outputs(self, outputs, dtype):
method get_losses (line 235) | def get_losses(
method get_l1_target (line 346) | def get_l1_target(self, l1_target, gt, stride, x_shifts, y_shifts, eps...
method get_assignments (line 354) | def get_assignments(
method get_in_boxes_info (line 423) | def get_in_boxes_info(
method dynamic_k_matching (line 502) | def dynamic_k_matching(self, cost, pair_wise_ious, gt_classes, num_gt,...
FILE: detector/YOLOX/yolox/models/yolo_pafpn.py
class YOLOPAFPN (line 12) | class YOLOPAFPN(nn.Module):
method __init__ (line 17) | def __init__(
method forward (line 78) | def forward(self, input):
FILE: detector/YOLOX/yolox/models/yolox.py
class YOLOX (line 11) | class YOLOX(nn.Module):
method __init__ (line 18) | def __init__(self, backbone=None, head=None):
method forward (line 28) | def forward(self, x, targets=None):
FILE: detector/YOLOX/yolox/utils/allreduce_norm.py
function get_async_norm_states (line 28) | def get_async_norm_states(module):
function pyobj2tensor (line 37) | def pyobj2tensor(pyobj, device="cuda"):
function tensor2pyobj (line 43) | def tensor2pyobj(tensor):
function _get_reduce_op (line 48) | def _get_reduce_op(op_name):
function all_reduce (line 55) | def all_reduce(py_dict, op="sum", group=None):
function all_reduce_norm (line 94) | def all_reduce_norm(module):
FILE: detector/YOLOX/yolox/utils/boxes.py
function filter_box (line 16) | def filter_box(output, scale_range):
function postprocess (line 27) | def postprocess(prediction, num_classes, conf_thre=0.7, nms_thre=0.45):
function bboxes_iou (line 67) | def bboxes_iou(bboxes_a, bboxes_b, xyxy=True):
function matrix_iou (line 93) | def matrix_iou(a, b):
function adjust_box_anns (line 106) | def adjust_box_anns(bbox, scale_ratio, padw, padh, w_max, h_max):
function xyxy2xywh (line 112) | def xyxy2xywh(bboxes):
FILE: detector/YOLOX/yolox/utils/checkpoint.py
function load_ckpt (line 11) | def load_ckpt(model, ckpt):
function save_checkpoint (line 36) | def save_checkpoint(state, is_best, save_dir, model_name=""):
FILE: detector/YOLOX/yolox/utils/demo_utils.py
function mkdir (line 12) | def mkdir(path):
function nms (line 17) | def nms(boxes, scores, nms_thr):
function multiclass_nms (line 47) | def multiclass_nms(boxes, scores, nms_thr, score_thr):
function demo_postprocess (line 69) | def demo_postprocess(outputs, img_size, p6=False):
FILE: detector/YOLOX/yolox/utils/dist.py
function synchronize (line 37) | def synchronize():
function get_world_size (line 51) | def get_world_size() -> int:
function get_rank (line 59) | def get_rank() -> int:
function get_local_rank (line 67) | def get_local_rank() -> int:
function get_local_size (line 80) | def get_local_size() -> int:
function is_main_process (line 92) | def is_main_process() -> bool:
function _get_global_gloo_group (line 97) | def _get_global_gloo_group():
function _serialize_to_tensor (line 108) | def _serialize_to_tensor(data, group):
function _pad_to_largest_tensor (line 126) | def _pad_to_largest_tensor(tensor, group):
function all_gather (line 156) | def all_gather(data, group=None):
function gather (line 194) | def gather(data, dst=0, group=None):
function shared_random_seed (line 238) | def shared_random_seed():
function time_synchronized (line 251) | def time_synchronized():
FILE: detector/YOLOX/yolox/utils/ema.py
function is_parallel (line 11) | def is_parallel(model):
function copy_attr (line 23) | def copy_attr(a, b, include=(), exclude=()):
class ModelEMA (line 32) | class ModelEMA:
method __init__ (line 42) | def __init__(self, model, decay=0.9999, updates=0):
method update (line 57) | def update(self, model):
method update_attr (line 71) | def update_attr(self, model, include=(), exclude=("process_group", "re...
FILE: detector/YOLOX/yolox/utils/logger.py
function get_caller_name (line 11) | def get_caller_name(depth=0):
class StreamToLoguru (line 27) | class StreamToLoguru:
method __init__ (line 31) | def __init__(self, level="INFO", caller_names=("apex", "pycocotools")):
method write (line 42) | def write(self, buf):
method flush (line 52) | def flush(self):
function redirect_sys_output (line 56) | def redirect_sys_output(log_level="INFO"):
function setup_logger (line 62) | def setup_logger(save_dir, distributed_rank=0, filename="log.txt", mode=...
FILE: detector/YOLOX/yolox/utils/lr_scheduler.py
class LRScheduler (line 9) | class LRScheduler:
method __init__ (line 10) | def __init__(self, name, lr, iters_per_epoch, total_epochs, **kwargs):
method update_lr (line 33) | def update_lr(self, iters):
method _get_lr_func (line 36) | def _get_lr_func(self, name):
function cos_lr (line 97) | def cos_lr(lr, total_iters, iters):
function warm_cos_lr (line 103) | def warm_cos_lr(lr, total_iters, warmup_total_iters, warmup_lr_start, it...
function yolox_warm_cos_lr (line 121) | def yolox_warm_cos_lr(
function yolox_semi_warm_cos_lr (line 151) | def yolox_semi_warm_cos_lr(
function multistep_lr (line 201) | def multistep_lr(lr, milestones, gamma, iters):
FILE: detector/YOLOX/yolox/utils/metric.py
function get_total_and_free_memory_in_Mb (line 22) | def get_total_and_free_memory_in_Mb(cuda_device):
function occumpy_mem (line 31) | def occumpy_mem(cuda_device, mem_ratio=0.9):
function gpu_mem_usage (line 43) | def gpu_mem_usage():
class AverageMeter (line 51) | class AverageMeter:
method __init__ (line 56) | def __init__(self, window_size=50):
method update (line 61) | def update(self, value):
method median (line 67) | def median(self):
method avg (line 72) | def avg(self):
method global_avg (line 78) | def global_avg(self):
method latest (line 82) | def latest(self):
method total (line 86) | def total(self):
method reset (line 89) | def reset(self):
method clear (line 94) | def clear(self):
class MeterBuffer (line 98) | class MeterBuffer(defaultdict):
method __init__ (line 101) | def __init__(self, window_size=20):
method reset (line 105) | def reset(self):
method get_filtered_meter (line 109) | def get_filtered_meter(self, filter_key="time"):
method update (line 112) | def update(self, values=None, **kwargs):
method clear_meters (line 119) | def clear_meters(self):
FILE: detector/YOLOX/yolox/utils/model_utils.py
function get_model_info (line 16) | def get_model_info(model, tsize):
function fuse_conv_and_bn (line 28) | def fuse_conv_and_bn(conv, bn):
function fuse_model (line 63) | def fuse_model(model):
function replace_module (line 74) | def replace_module(module, replaced_module_type, new_module_type, replac...
FILE: detector/YOLOX/yolox/utils/setup_env.py
function configure_nccl (line 13) | def configure_nccl():
function configure_module (line 25) | def configure_module(ulimit_value=8192):
FILE: detector/YOLOX/yolox/utils/visualize.py
function vis (line 11) | def vis(img, boxes, scores, cls_ids, conf=0.5, class_names=None):
FILE: eval/convert_davis.py
function color2id (line 35) | def color2id(c):
function convert_dir (line 38) | def convert_dir(i):
FILE: eval/eval_mot.py
class Evaluator (line 9) | class Evaluator(object):
method __init__ (line 11) | def __init__(self, data_root, seq_name, data_type='mot'):
method load_annotations (line 19) | def load_annotations(self):
method reset_accumulator (line 26) | def reset_accumulator(self):
method eval_frame (line 29) | def eval_frame(self, frame_id, trk_tlwhs, trk_ids, rtn_events=False):
method eval_file (line 69) | def eval_file(self, filename):
method get_summary (line 82) | def get_summary(accs, names, metrics=('mota', 'num_switches', 'idp', '...
method save_summary (line 99) | def save_summary(summary, filename):
FILE: eval/eval_pck.py
function computePCK (line 130) | def computePCK(distAll,distThresh):
FILE: eval/mots/Evaluator.py
class Evaluator (line 16) | class Evaluator(object):
method __init__ (line 18) | def __init__(self):
method run (line 21) | def run(self, benchmark_name = None , gt_dir = None, res_dir = None, ...
method eval (line 165) | def eval(self):
method accumulate_df (line 169) | def accumulate_df(self, type = None):
method render_summary (line 184) | def render_summary( self, buf = None):
function run_metrics (line 217) | def run_metrics( metricObject, args ):
FILE: eval/mots/MOTSVisualization.py
function apply_mask (line 11) | def apply_mask(image, mask, color, alpha=0.5):
class MOTSVisualizer (line 20) | class MOTSVisualizer(Visualizer):
method load (line 22) | def load(self, FilePath):
method drawResults (line 27) | def drawResults(self, im = None, t = 0):
FILE: eval/mots/MOTS_metrics.py
function mask_iou (line 17) | def mask_iou(a, b, criterion="union"):
class MOTSMetrics (line 24) | class MOTSMetrics(Metrics):
method __init__ (line 25) | def __init__(self, seqName = None):
method compute_clearmot (line 85) | def compute_clearmot(self):
method compute_metrics_per_sequence (line 166) | def compute_metrics_per_sequence(self, sequence, pred_file, gt_file, g...
function compute_idf1_and_idtp_for_sequence (line 388) | def compute_idf1_and_idtp_for_sequence(frame_to_gt, frame_to_pred, gt_id...
function cost_between_gt_pred (line 477) | def cost_between_gt_pred(groundtruth, prediction):
function cost_between_trajectories (line 491) | def cost_between_trajectories(traj1, traj2):
function corresponding_frame (line 539) | def corresponding_frame(traj1, len1, traj2, len2):
function compute_overlap (line 559) | def compute_overlap(traj1, traj2, matched_pos):
FILE: eval/mots/Metrics.py
class Metrics (line 7) | class Metrics(object):
method __init__ (line 8) | def __init__(self):
method register (line 13) | def register(self, name=None, value=None, formatter=None,
method cache (line 46) | def cache(self, name=None, value=None, func=None):
method __call__ (line 60) | def __call__(self, name):
method names (line 64) | def names(self):
method display_names (line 69) | def display_names(self):
method formatters (line 75) | def formatters(self):
method val_dict (line 80) | def val_dict(self, display_name = False, object = "metrics"):
method val_db (line 95) | def val_db(self, display_name = True):
method val_mail (line 103) | def val_mail(self, display_name = True):
method to_dataframe (line 111) | def to_dataframe(self, display_name = False, type = None):
method update_values (line 117) | def update_values(self, value_dict = None):
method print_type (line 125) | def print_type(self, object = "metrics"):
method print_results (line 132) | def print_results(self):
method save_dict (line 140) | def save_dict(self, path):
method compute_metrics_per_sequence (line 146) | def compute_metrics_per_sequence(self):
FILE: eval/mots/Visualize.py
class Visualizer (line 10) | class Visualizer(object):
method __init__ (line 11) | def __init__(self,
method generate_colors (line 32) | def generate_colors(self):
method generateVideo (line 45) | def generateVideo(self,
method drawResults (line 126) | def drawResults(self, image = None):
method load (line 129) | def load(self):
method convertVideo (line 132) | def convertVideo(self, extensions):
FILE: eval/mots/evalMOTS.py
class MOTSEvaluator (line 13) | class MOTSEvaluator(Evaluator):
method __init__ (line 14) | def __init__(self):
method eval (line 16) | def eval(self):
FILE: eval/mots/mots_common/io.py
class SegmentedObject (line 8) | class SegmentedObject:
method __init__ (line 9) | def __init__(self, mask, class_id, track_id):
function load_sequences (line 15) | def load_sequences(path, seqmap):
function load_txt (line 31) | def load_txt(path):
function load_images_for_folder (line 72) | def load_images_for_folder(path):
function filename_to_frame_nr (line 84) | def filename_to_frame_nr(filename):
function load_image (line 89) | def load_image(filename, id_divisor=1000):
function load_seqmap (line 110) | def load_seqmap(seqmap_filename):
function write_sequences (line 123) | def write_sequences(gt, output_folder):
function write_sequence (line 130) | def write_sequence(frames, path):
FILE: eval/poseval/evaluate.py
function parseArgs (line 14) | def parseArgs():
function main (line 26) | def main():
FILE: eval/poseval/poseval/convert.py
function json_default (line 57) | def json_default(val):
class Video (line 65) | class Video:
method __init__ (line 78) | def __init__(self, video_id):
method to_new (line 82) | def to_new(self):
method to_old (line 128) | def to_old(self):
method from_old (line 149) | def from_old(cls, track_data):
method from_new (line 170) | def from_new(cls, track_data):
class Person (line 205) | class Person:
method __init__ (line 217) | def __init__(self, track_id):
method to_new (line 224) | def to_new(self):
method to_old (line 276) | def to_old(self):
method from_old (line 311) | def from_old(cls, person_info):
method from_new (line 373) | def from_new(cls, person_info, conversion_table):
class Image (line 423) | class Image:
method __init__ (line 427) | def __init__(self, filename, frame_id):
method to_new (line 434) | def to_new(self):
method to_old (line 452) | def to_old(self):
method from_old (line 472) | def from_old(cls, json_data):
method from_new (line 506) | def from_new(cls, track_data, image_id):
function cli (line 540) | def cli(in_fp, out_fp="converted"):
function convert_videos (line 605) | def convert_videos(track_data):
FILE: eval/poseval/poseval/eval_helpers.py
class Joint (line 13) | class Joint:
method __init__ (line 14) | def __init__(self):
function getPointGTbyID (line 67) | def getPointGTbyID(points,pidx):
function getHeadSize (line 78) | def getHeadSize(x1,y1,x2,y2):
function formatCell (line 83) | def formatCell(val,delim):
function getHeader (line 87) | def getHeader():
function getMotHeader (line 100) | def getMotHeader():
function getCum (line 133) | def getCum(vals):
function getFormatRow (line 147) | def getFormatRow(cum):
function printTable (line 155) | def printTable(vals,motHeader=False):
function printTableTracking (line 168) | def printTableTracking(valsPerPart):
function computeRPC (line 178) | def computeRPC(scores,labels,totalPos):
function VOCap (line 199) | def VOCap(rec,prec):
function get_data_dir (line 218) | def get_data_dir():
function process_arguments (line 222) | def process_arguments(argv):
function process_arguments_server (line 240) | def process_arguments_server(argv):
function load_data (line 264) | def load_data(argv):
function cleanupData (line 285) | def cleanupData(gtFramesAll,prFramesAll):
function removeIgnoredPointsRects (line 303) | def removeIgnoredPointsRects(rects,polyList):
function removeIgnoredPoints (line 328) | def removeIgnoredPoints(gtFramesAll,prFramesAll):
function rectHasPoints (line 353) | def rectHasPoints(rect):
function removeRectsWithoutPoints (line 359) | def removeRectsWithoutPoints(rects):
function load_data_dir (line 368) | def load_data_dir(argv):
function writeJson (line 433) | def writeJson(val,fname):
function assignGTmulti (line 438) | def assignGTmulti(gtFrames, prFrames, distThresh):
FILE: eval/poseval/poseval/evaluateAP.py
function computeMetrics (line 9) | def computeMetrics(scoresAll, labelsAll, nGTall):
function evaluateAP (line 38) | def evaluateAP(gtFramesAll, prFramesAll, outputDir, bSaveAll=True, bSave...
FILE: eval/poseval/poseval/evaluatePCKh.py
function computeDist (line 8) | def computeDist(gtFrames,prFrames):
function computePCK (line 50) | def computePCK(distAll,distThresh):
function evaluatePCKh (line 66) | def evaluatePCKh(gtFramesAll,prFramesAll):
FILE: eval/poseval/poseval/evaluateTracking.py
function computeMetrics (line 12) | def computeMetrics(gtFramesAll, motAll, outputDir, bSaveAll, bSaveSeq):
function evaluateTracking (line 212) | def evaluateTracking(gtFramesAll, prFramesAll, outputDir, saveAll=True, ...
FILE: eval/poseval/poseval/posetrack18_id2fname.py
function idx2seqtype (line 1595) | def idx2seqtype(idx):
function seqtype2idx (line 1606) | def seqtype2idx(seqtype):
function posetrack18_id2fname (line 1618) | def posetrack18_id2fname(image_id):
function posetrack18_fname2id (line 1651) | def posetrack18_fname2id(fname, frameidx):
FILE: eval/trackeval/_timing.py
function time (line 10) | def time(f):
FILE: eval/trackeval/datasets/_base_dataset.py
class _BaseDataset (line 13) | class _BaseDataset(ABC):
method __init__ (line 15) | def __init__(self):
method get_default_dataset_config (line 26) | def get_default_dataset_config():
method _load_raw_file (line 30) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 35) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 39) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
method get_name (line 45) | def get_name(cls):
method get_output_fol (line 48) | def get_output_fol(self, tracker):
method get_display_name (line 51) | def get_display_name(self, tracker):
method get_eval_info (line 57) | def get_eval_info(self):
method get_raw_seq_data (line 62) | def get_raw_seq_data(self, tracker, seq):
method _load_simple_text_file (line 100) | def _load_simple_text_file(file, time_col=0, id_col=None, remove_negat...
method _calculate_mask_ious (line 210) | def _calculate_mask_ious(masks1, masks2, is_encoded=False, do_ioa=False):
method _calculate_box_ious (line 243) | def _calculate_box_ious(bboxes1, bboxes2, box_format='xywh', do_ioa=Fa...
method _check_unique_ids (line 284) | def _check_unique_ids(data, after_preproc=False):
FILE: eval/trackeval/datasets/bdd100k.py
class BDD100K (line 12) | class BDD100K(_BaseDataset):
method get_default_dataset_config (line 16) | def get_default_dataset_config():
method __init__ (line 35) | def __init__(self, config=None):
method get_display_name (line 95) | def get_display_name(self, tracker):
method _load_raw_file (line 98) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 185) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 300) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
FILE: eval/trackeval/datasets/davis.py
class DAVIS (line 10) | class DAVIS(_BaseDataset):
method get_default_dataset_config (line 14) | def get_default_dataset_config():
method __init__ (line 35) | def __init__(self, config=None):
method _load_raw_file (line 109) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 177) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 274) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
FILE: eval/trackeval/datasets/kitti_2d_box.py
class Kitti2DBox (line 12) | class Kitti2DBox(_BaseDataset):
method get_default_dataset_config (line 16) | def get_default_dataset_config():
method __init__ (line 34) | def __init__(self, config=None):
method get_display_name (line 117) | def get_display_name(self, tracker):
method _load_raw_file (line 120) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 237) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 386) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
FILE: eval/trackeval/datasets/kitti_mots.py
class KittiMOTS (line 11) | class KittiMOTS(_BaseDataset):
method get_default_dataset_config (line 15) | def get_default_dataset_config():
method __init__ (line 37) | def __init__(self, config=None):
method get_display_name (line 111) | def get_display_name(self, tracker):
method _get_seq_info (line 114) | def _get_seq_info(self):
method _load_raw_file (line 146) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 266) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 388) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
method _raise_index_error (line 393) | def _raise_index_error(is_gt, tracker, seq):
method _raise_value_error (line 411) | def _raise_value_error(is_gt, tracker, seq):
FILE: eval/trackeval/datasets/mot_challenge_2d_box.py
class MotChallenge2DBox (line 12) | class MotChallenge2DBox(_BaseDataset):
method get_default_dataset_config (line 16) | def get_default_dataset_config():
method __init__ (line 43) | def __init__(self, config=None):
method get_display_name (line 129) | def get_display_name(self, tracker):
method _get_seq_info (line 132) | def _get_seq_info(self):
method _load_raw_file (line 175) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 290) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 423) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
FILE: eval/trackeval/datasets/mots_challenge.py
class MOTSChallenge (line 12) | class MOTSChallenge(_BaseDataset):
method get_default_dataset_config (line 16) | def get_default_dataset_config():
method __init__ (line 41) | def __init__(self, config=None):
method get_display_name (line 121) | def get_display_name(self, tracker):
method _get_seq_info (line 124) | def _get_seq_info(self):
method _load_raw_file (line 167) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 287) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 408) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
method _raise_index_error (line 413) | def _raise_index_error(is_gt, tracker, seq):
method _raise_value_error (line 431) | def _raise_value_error(is_gt, tracker, seq):
FILE: eval/trackeval/datasets/tao.py
class TAO (line 13) | class TAO(_BaseDataset):
method get_default_dataset_config (line 17) | def get_default_dataset_config():
method __init__ (line 35) | def __init__(self, config=None):
method get_display_name (line 139) | def get_display_name(self, tracker):
method _load_raw_file (line 142) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 257) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 398) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
method _merge_categories (line 402) | def _merge_categories(self, annotations):
method _compute_vid_mappings (line 417) | def _compute_vid_mappings(self, annotations):
method _compute_image_to_timestep_mappings (line 486) | def _compute_image_to_timestep_mappings(self):
method _limit_dets_per_image (line 503) | def _limit_dets_per_image(self, annotations):
method _fill_video_ids_inplace (line 523) | def _fill_video_ids_inplace(self, annotations):
method _make_track_ids_unique (line 538) | def _make_track_ids_unique(annotations):
FILE: eval/trackeval/datasets/youtube_vis.py
class YouTubeVIS (line 10) | class YouTubeVIS(_BaseDataset):
method get_default_dataset_config (line 14) | def get_default_dataset_config():
method __init__ (line 32) | def __init__(self, config=None):
method get_display_name (line 110) | def get_display_name(self, tracker):
method _load_raw_file (line 113) | def _load_raw_file(self, tracker, seq, is_gt):
method get_preprocessed_seq_data (line 200) | def get_preprocessed_seq_data(self, raw_data, cls):
method _calculate_similarities (line 315) | def _calculate_similarities(self, gt_dets_t, tracker_dets_t):
method _prepare_gt_annotations (line 319) | def _prepare_gt_annotations(self):
method _get_tracker_seq_tracks (line 339) | def _get_tracker_seq_tracks(self, tracker, seq_id):
FILE: eval/trackeval/eval.py
class Evaluator (line 12) | class Evaluator:
method get_default_eval_config (line 16) | def get_default_eval_config():
method __init__ (line 39) | def __init__(self, config=None):
method evaluate (line 49) | def evaluate(self, dataset_list, metrics_list):
function eval_sequence (line 185) | def eval_sequence(seq, dataset, tracker, class_list, metrics_list, metri...
FILE: eval/trackeval/metrics/_base_metric.py
class _BaseMetric (line 8) | class _BaseMetric(ABC):
method __init__ (line 10) | def __init__(self):
method eval_sequence (line 26) | def eval_sequence(self, data):
method combine_sequences (line 30) | def combine_sequences(self, all_res):
method combine_classes_class_averaged (line 34) | def combine_classes_class_averaged(self, all_res):
method combine_classes_det_averaged (line 38) | def combine_classes_det_averaged(self, all_res):
method plot_single_tracker_results (line 41) | def plot_single_tracker_results(self, all_res, tracker, output_folder,...
method get_name (line 52) | def get_name(cls):
method _combine_sum (line 56) | def _combine_sum(all_res, field):
method _combine_weighted_av (line 61) | def _combine_weighted_av(all_res, field, comb_res, weight_field):
method print_table (line 66) | def print_table(self, table_res, tracker, cls):
method _summary_row (line 79) | def _summary_row(self, results_):
method _row_print (line 93) | def _row_print(*argv):
method summary_results (line 102) | def summary_results(self, table_res):
method detailed_results (line 106) | def detailed_results(self, table_res):
method _detailed_row (line 125) | def _detailed_row(self, res):
FILE: eval/trackeval/metrics/clear.py
class CLEAR (line 8) | class CLEAR(_BaseMetric):
method __init__ (line 10) | def __init__(self):
method eval_sequence (line 25) | def eval_sequence(self, data):
method combine_sequences (line 118) | def combine_sequences(self, all_res):
method combine_classes_det_averaged (line 126) | def combine_classes_det_averaged(self, all_res):
method combine_classes_class_averaged (line 134) | def combine_classes_class_averaged(self, all_res):
method _compute_final_fields (line 146) | def _compute_final_fields(res):
FILE: eval/trackeval/metrics/count.py
class Count (line 6) | class Count(_BaseMetric):
method __init__ (line 8) | def __init__(self):
method eval_sequence (line 15) | def eval_sequence(self, data):
method combine_sequences (line 25) | def combine_sequences(self, all_res):
method combine_classes_class_averaged (line 32) | def combine_classes_class_averaged(self, all_res):
method combine_classes_det_averaged (line 39) | def combine_classes_det_averaged(self, all_res):
FILE: eval/trackeval/metrics/hota.py
class HOTA (line 9) | class HOTA(_BaseMetric):
method __init__ (line 13) | def __init__(self):
method eval_sequence (line 24) | def eval_sequence(self, data):
method combine_sequences (line 118) | def combine_sequences(self, all_res):
method combine_classes_class_averaged (line 130) | def combine_classes_class_averaged(self, all_res):
method combine_classes_det_averaged (line 147) | def combine_classes_det_averaged(self, all_res):
method _compute_final_fields (line 160) | def _compute_final_fields(res):
method plot_single_tracker_results (line 175) | def plot_single_tracker_results(self, table_res, tracker, cls, output_...
FILE: eval/trackeval/metrics/identity.py
class Identity (line 8) | class Identity(_BaseMetric):
method __init__ (line 10) | def __init__(self):
method eval_sequence (line 20) | def eval_sequence(self, data):
method combine_classes_class_averaged (line 79) | def combine_classes_class_averaged(self, all_res):
method combine_classes_det_averaged (line 90) | def combine_classes_det_averaged(self, all_res):
method combine_sequences (line 98) | def combine_sequences(self, all_res):
method _compute_final_fields (line 107) | def _compute_final_fields(res):
FILE: eval/trackeval/metrics/j_and_f.py
class JAndF (line 10) | class JAndF(_BaseMetric):
method __init__ (line 12) | def __init__(self):
method eval_sequence (line 21) | def eval_sequence(self, data):
method combine_sequences (line 124) | def combine_sequences(self, all_res):
method combine_classes_class_averaged (line 131) | def combine_classes_class_averaged(self, all_res):
method combine_classes_det_averaged (line 138) | def combine_classes_det_averaged(self, all_res):
method _seg2bmap (line 146) | def _seg2bmap(seg, width=None, height=None):
method _compute_f (line 205) | def _compute_f(gt_data, tracker_data, tracker_data_id, gt_id, bound_th):
method _compute_j (line 273) | def _compute_j(gt_data, tracker_data, num_gt_ids, num_tracker_ids, num...
FILE: eval/trackeval/metrics/track_map.py
class TrackMAP (line 9) | class TrackMAP(_BaseMetric):
method get_default_metric_config (line 13) | def get_default_metric_config():
method __init__ (line 33) | def __init__(self, config=None):
method eval_sequence (line 62) | def eval_sequence(self, data):
method combine_sequences (line 170) | def combine_sequences(self, all_res):
method combine_classes_class_averaged (line 277) | def combine_classes_class_averaged(self, all_res):
method combine_classes_det_averaged (line 293) | def combine_classes_det_averaged(self, all_res):
method _compute_track_ig_masks (line 310) | def _compute_track_ig_masks(self, num_ids, track_lengths=None, track_a...
method _compute_bb_track_iou (line 348) | def _compute_bb_track_iou(dt_track, gt_track, boxformat='xywh'):
method _compute_mask_track_iou (line 399) | def _compute_mask_track_iou(dt_track, gt_track):
method _compute_track_ious (line 432) | def _compute_track_ious(dt, gt, iou_function='bbox', boxformat='xywh'):
method _row_print (line 453) | def _row_print(*argv):
FILE: eval/trackeval/metrics/vace.py
class VACE (line 7) | class VACE(_BaseMetric):
method __init__ (line 18) | def __init__(self):
method eval_sequence (line 31) | def eval_sequence(self, data):
method combine_classes_class_averaged (line 95) | def combine_classes_class_averaged(self, all_res):
method combine_classes_det_averaged (line 103) | def combine_classes_det_averaged(self, all_res):
method combine_sequences (line 111) | def combine_sequences(self, all_res):
method _compute_final_fields (line 120) | def _compute_final_fields(additive):
FILE: eval/trackeval/plotting.py
function plot_compare_trackers (line 7) | def plot_compare_trackers(tracker_folder, tracker_list, cls, output_fold...
function get_default_plots_list (line 22) | def get_default_plots_list():
function load_multiple_tracker_summaries (line 38) | def load_multiple_tracker_summaries(tracker_folder, tracker_list, cls):
function create_comparison_plot (line 53) | def create_comparison_plot(data, out_loc, y_label, x_label, sort_label, ...
function _get_boundaries (line 140) | def _get_boundaries(x_values, y_values, round_val):
function geometric_mean (line 157) | def geometric_mean(x, y):
function jaccard (line 161) | def jaccard(x, y):
function multiplication (line 167) | def multiplication(x, y):
function _plot_bg_contour (line 178) | def _plot_bg_contour(bg_function, plot_boundaries, gap_val):
function _plot_pareto_optimal_lines (line 204) | def _plot_pareto_optimal_lines(x_values, y_values):
FILE: eval/trackeval/utils.py
function init_config (line 7) | def init_config(config, default_config, name=None):
function get_code_path (line 21) | def get_code_path():
function validate_metrics_list (line 26) | def validate_metrics_list(metrics_list):
function write_summary_results (line 43) | def write_summary_results(summaries, cls, output_folder):
function write_detailed_results (line 74) | def write_detailed_results(details, cls, output_folder):
function load_detail (line 90) | def load_detail(file):
class TrackEvalException (line 110) | class TrackEvalException(Exception):
FILE: model/functional.py
function hard_prop (line 17) | def hard_prop(pred):
function context_index_bank (line 24) | def context_index_bank(n_context, long_mem, N):
function mem_efficient_batched_affinity (line 42) | def mem_efficient_batched_affinity(
function batched_affinity (line 75) | def batched_affinity(query, keys, mask, temperature, topk, long_mem, dev...
function process_pose (line 103) | def process_pose(pred, lbl_set, topk=3):
class MaskedAttention (line 127) | class MaskedAttention(nn.Module):
method __init__ (line 132) | def __init__(self, radius, flat=True):
method mask (line 139) | def mask(self, H, W):
method index (line 144) | def index(self, H, W):
method make (line 149) | def make(self, H, W):
method flatten (line 164) | def flatten(self, D):
method make_index (line 167) | def make_index(self, H, W, pad=False):
method forward (line 175) | def forward(self, x):
FILE: model/hrnet.py
function conv3x3 (line 29) | def conv3x3(in_planes, out_planes, stride=1):
class BasicBlock (line 35) | class BasicBlock(nn.Module):
method __init__ (line 38) | def __init__(self, inplanes, planes, stride=1, downsample=None):
method forward (line 48) | def forward(self, x):
class Bottleneck (line 67) | class Bottleneck(nn.Module):
method __init__ (line 70) | def __init__(self, inplanes, planes, stride=1, downsample=None):
method forward (line 85) | def forward(self, x):
class HighResolutionModule (line 108) | class HighResolutionModule(nn.Module):
method __init__ (line 109) | def __init__(self, num_branches, blocks, num_blocks, num_inchannels,
method _check_branches (line 126) | def _check_branches(self, num_branches, blocks, num_blocks,
method _make_one_branch (line 146) | def _make_one_branch(self, branch_index, block, num_blocks, num_channels,
method _make_branches (line 170) | def _make_branches(self, num_branches, block, num_blocks, num_channels):
method _make_fuse_layers (line 179) | def _make_fuse_layers(self):
method get_num_inchannels (line 227) | def get_num_inchannels(self):
method forward (line 230) | def forward(self, x):
class HighResolutionNet (line 263) | class HighResolutionNet(nn.Module):
method __init__ (line 265) | def __init__(self, cfg, **kwargs):
method _make_head (line 320) | def _make_head(self, pre_stage_channels):
method _make_transition_layer (line 369) | def _make_transition_layer(
method _make_layer (line 405) | def _make_layer(self, block, inplanes, planes, blocks, stride=1):
method _make_stage (line 422) | def _make_stage(self, layer_config, num_inchannels,
method forward (line 452) | def forward(self, x):
method init_weights (line 500) | def init_weights(self, pretrained='',):
function get_cls_net (line 601) | def get_cls_net(c, **kwargs):
FILE: model/model.py
class AppearanceModel (line 16) | class AppearanceModel(nn.Module):
method __init__ (line 17) | def __init__(self, args):
method forward (line 22) | def forward(self, x):
function partial_load (line 26) | def partial_load(pretrained_dict, model, skip_keys=[], log=False):
function load_vince_model (line 45) | def load_vince_model(path):
function load_uvc_model (line 51) | def load_uvc_model(ckpt_path):
function load_tc_model (line 62) | def load_tc_model(ckpt_path):
class From3D (line 79) | class From3D(nn.Module):
method __init__ (line 81) | def __init__(self, resnet):
method forward (line 85) | def forward(self, x):
function make_encoder (line 93) | def make_encoder(args):
FILE: model/random_feat_generator.py
class RandomFeatGenerator (line 15) | class RandomFeatGenerator(nn.Module):
method __init__ (line 16) | def __init__(self, args):
method forward (line 21) | def forward(self, x):
method __str__ (line 36) | def __str__(self):
FILE: model/resnet.py
class ResNet (line 23) | class ResNet(torch_resnet.ResNet):
method __init__ (line 24) | def __init__(self, *args, **kwargs):
method modify (line 27) | def modify(self, remove_layers=[], padding=''):
method forward (line 50) | def forward(self, x):
function _resnet (line 64) | def _resnet(arch, block, layers, pretrained, progress, **kwargs):
function resnet18 (line 72) | def resnet18(pretrained=False, progress=True, **kwargs):
function resnet50 (line 76) | def resnet50(pretrained=False, progress=True, **kwargs) -> ResNet:
function resnet101 (line 80) | def resnet101(pretrained=False, progress=True, **kwargs):
function resnet152 (line 84) | def resnet152(pretrained=False, progress=True, **kwargs):
function resnext50_32x4d (line 96) | def resnext50_32x4d(pretrained=False, progress=True, **kwargs):
function resnext101_32x8d (line 110) | def resnext101_32x8d(pretrained=False, progress=True, **kwargs):
function wide_resnet50_2 (line 124) | def wide_resnet50_2(pretrained=False, progress=True, **kwargs):
function wide_resnet101_2 (line 142) | def wide_resnet101_2(pretrained=False, progress=True, **kwargs):
FILE: test/test_mot.py
function eval_seq (line 22) | def eval_seq(opt, dataloader, result_filename, save_dir=None,
function main (line 64) | def main(opt, data_root, seqs=('MOT16-05',), exp_name='demo',
FILE: test/test_mots.py
function eval_seq (line 26) | def eval_seq(opt, dataloader, result_filename, save_dir=None,
function main (line 68) | def main(opt, data_root='/data/MOT16/train', det_root=None, seqs=('MOT16...
FILE: test/test_poseprop.py
function main (line 24) | def main(args, vis):
function test (line 44) | def test(loader, model, args):
FILE: test/test_posetrack.py
function identical (line 30) | def identical(a, b):
function fuse_result (line 38) | def fuse_result(res, jpath):
function eval_seq (line 55) | def eval_seq(opt, dataloader, save_dir=None):
function main (line 86) | def main(opt):
FILE: test/test_sot_cfnet.py
function sot_loadimg (line 31) | def sot_loadimg(path, im_mean, im_std, use_lab=False):
class TrackerConfig (line 44) | class TrackerConfig(object):
function track (line 78) | def track(net, video, args):
function main (line 180) | def main():
FILE: test/test_sot_siamfc.py
function sot_loadimg (line 30) | def sot_loadimg(path, im_mean, im_std, use_lab=False):
class TrackerConfig (line 43) | class TrackerConfig(object):
function track (line 63) | def track(net, video, args):
function main (line 159) | def main():
FILE: test/test_vis.py
function fuse_result (line 31) | def fuse_result(res, obs):
function obs_by_seq (line 63) | def obs_by_seq(obs):
function obs_by_ins (line 72) | def obs_by_ins(obs):
function eval_seq (line 78) | def eval_seq(opt, dataloader, save_dir=None):
function main (line 112) | def main(opt):
FILE: test/test_vos.py
function main (line 24) | def main(args, vis):
function test (line 58) | def test(loader, model, args):
FILE: tools/gen_mot19_det.py
function mkdirs (line 7) | def mkdirs(d):
FILE: tools/gen_mots_costa.py
function mkdirs (line 7) | def mkdirs(d):
FILE: tools/gen_mots_gt.py
function mkdirs (line 7) | def mkdirs(d):
FILE: tracker/mot/basetrack.py
class TrackState (line 10) | class TrackState(object):
class BaseTrack (line 17) | class BaseTrack(object):
method end_frame (line 36) | def end_frame(self):
method next_id (line 40) | def next_id():
method activate (line 44) | def activate(self, *args):
method predict (line 47) | def predict(self):
method update (line 50) | def update(self, *args, **kwargs):
method mark_lost (line 53) | def mark_lost(self):
method mark_removed (line 56) | def mark_removed(self):
class STrack (line 59) | class STrack(BaseTrack):
method __init__ (line 62) | def __init__(self, tlwh, score, temp_feat, buffer_size=30,
method update_features (line 84) | def update_features(self, feat):
method predict (line 94) | def predict(self):
method multi_predict (line 101) | def multi_predict(stracks):
method activate (line 114) | def activate(self, kalman_filter, frame_id):
method re_activate (line 128) | def re_activate(self, new_track, frame_id, new_id=False, update_featur...
method update (line 147) | def update(self, new_track, frame_id, update_feature=True):
method tlwh (line 181) | def tlwh(self):
method tlbr (line 193) | def tlbr(self):
method to_xyah (line 202) | def to_xyah(self):
method __repr__ (line 206) | def __repr__(self):
function joint_stracks (line 210) | def joint_stracks(tlista, tlistb):
function sub_stracks (line 223) | def sub_stracks(tlista, tlistb):
function remove_duplicate_stracks (line 233) | def remove_duplicate_stracks(stracksa, stracksb, ioudist=0.15):
FILE: tracker/mot/box.py
class BoxAssociationTracker (line 16) | class BoxAssociationTracker(AssociationTracker):
method __init__ (line 17) | def __init__(self, opt):
method extract_emb (line 20) | def extract_emb(self, img, obs):
method prepare_obs (line 29) | def prepare_obs(self, img, img0, obs):
FILE: tracker/mot/mask.py
class MaskAssociationTracker (line 17) | class MaskAssociationTracker(AssociationTracker):
method __init__ (line 18) | def __init__(self, opt):
method extract_emb (line 21) | def extract_emb(self, img, obs):
method prepare_obs (line 46) | def prepare_obs(self, img, img0, obs):
FILE: tracker/mot/multitracker.py
class AssociationTracker (line 18) | class AssociationTracker(object):
method __init__ (line 19) | def __init__(self, opt):
method extract_emb (line 39) | def extract_emb(self, img, obs):
method prepare_obs (line 42) | def prepare_obs(self, img, img0, obs):
method update (line 45) | def update(self, img, img0, obs):
FILE: tracker/mot/pose.py
class PoseAssociationTracker (line 29) | class PoseAssociationTracker(AssociationTracker):
method __init__ (line 30) | def __init__(self, opt):
method extract_emb (line 33) | def extract_emb(self, img, obs):
method prepare_obs (line 58) | def prepare_obs(self, img, img0, obs):
FILE: tracker/sot/lib/core/config.py
function _update_dict (line 90) | def _update_dict(k, v, model_name):
function update_config (line 110) | def update_config(config_file):
FILE: tracker/sot/lib/core/config_ocean.py
function _update_dict (line 90) | def _update_dict(k, v, model_name):
function update_config (line 110) | def update_config(config_file):
FILE: tracker/sot/lib/core/config_oceanplus.py
function _update_dict (line 164) | def _update_dict(k, v, model_name):
function update_config (line 184) | def update_config(config_file):
FILE: tracker/sot/lib/core/config_siamdw.py
function _update_dict (line 162) | def _update_dict(k, v, model_name):
function update_config (line 177) | def update_config(config_file):
FILE: tracker/sot/lib/core/eval_davis.py
function eval_davis (line 23) | def eval_davis(epoch):
function extract_davis (line 29) | def extract_davis(epochs):
FILE: tracker/sot/lib/core/eval_got10k.py
function overlap_ratio (line 12) | def overlap_ratio(rect1, rect2):
function compute_success_overlap (line 35) | def compute_success_overlap(gt_bb, result_bb):
function compute_success_error (line 45) | def compute_success_error(gt_center, result_center):
function get_result_bb (line 55) | def get_result_bb(arch, seq):
function convert_bb_to_center (line 61) | def convert_bb_to_center(bboxes):
function eval_auc (line 66) | def eval_auc(dataset='GOT10KVAL', result_path='./test/', tracker_reg='S*...
function eval_got10k_tune (line 106) | def eval_got10k_tune(result_path, dataset='GOT10KVAL'):
FILE: tracker/sot/lib/core/eval_lasot.py
function overlap_ratio (line 12) | def overlap_ratio(rect1, rect2):
function compute_success_overlap (line 35) | def compute_success_overlap(gt_bb, result_bb):
function compute_success_error (line 45) | def compute_success_error(gt_center, result_center):
function get_result_bb (line 55) | def get_result_bb(arch, seq):
function convert_bb_to_center (line 61) | def convert_bb_to_center(bboxes):
function eval_auc (line 66) | def eval_auc(dataset='LASOTTEST', result_path='./test/', tracker_reg='S*...
function eval_lasot_tune (line 106) | def eval_lasot_tune(result_path, dataset='LASOTTEST'):
FILE: tracker/sot/lib/core/eval_otb.py
function overlap_ratio (line 28) | def overlap_ratio(rect1, rect2):
function compute_success_overlap (line 51) | def compute_success_overlap(gt_bb, result_bb):
function compute_success_error (line 61) | def compute_success_error(gt_center, result_center):
function get_result_bb (line 71) | def get_result_bb(arch, seq):
function convert_bb_to_center (line 77) | def convert_bb_to_center(bboxes):
function eval_auc (line 82) | def eval_auc(dataset='OTB2015', result_path='./test/', tracker_reg='S*',...
function eval_auc_tune (line 147) | def eval_auc_tune(result_path, dataset='OTB2015'):
FILE: tracker/sot/lib/core/eval_visdrone.py
function overlap_ratio (line 9) | def overlap_ratio(rect1, rect2):
function compute_success_overlap (line 32) | def compute_success_overlap(gt_bb, result_bb):
function compute_success_error (line 42) | def compute_success_error(gt_center, result_center):
function get_result_bb (line 52) | def get_result_bb(arch, seq):
function convert_bb_to_center (line 58) | def convert_bb_to_center(bboxes):
function eval_auc (line 63) | def eval_auc(dataset='VISDRONVAL', result_path='./result/', tracker_reg=...
function eval_vis_tune (line 107) | def eval_vis_tune(result_path, dataset='VISDRONEVAL'):
FILE: tracker/sot/lib/core/extract_tune_logs.py
function collect_results (line 12) | def collect_results(args):
FILE: tracker/sot/lib/core/function.py
function ocean_train (line 9) | def ocean_train(train_loader, model, optimizer, epoch, cur_lr, cfg, wri...
function BNtoFixed (line 100) | def BNtoFixed(m):
function oceanplus_train (line 105) | def oceanplus_train(train_loader, model, optimizer, epoch, cur_lr, cfg, ...
function siamdw_train (line 202) | def siamdw_train(train_loader, model, optimizer, epoch, cur_lr, cfg, wr...
function is_valid_number (line 258) | def is_valid_number(x):
class AverageMeter (line 262) | class AverageMeter(object):
method __init__ (line 264) | def __init__(self):
method reset (line 267) | def reset(self):
method update (line 273) | def update(self, val, n=1):
FILE: tracker/sot/lib/dataset/crop/DAVIS/par_crop.py
function printProgress (line 26) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 47) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 59) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFCx (line 63) | def crop_like_SiamFCx(image, bbox, exemplar_size=127, context_amount=0.5...
function crop_img (line 78) | def crop_img(video_name, set_crop_base_path, set_img_base_path,
function main (line 110) | def main(exemplar_size=127, context_amount=0.5, search_size=511, enable_...
FILE: tracker/sot/lib/dataset/crop/RGBT210/RGBT210_genjson.py
function genjson (line 14) | def genjson():
FILE: tracker/sot/lib/dataset/crop/RGBT210/gen_json.py
function check_size (line 12) | def check_size(frame_sz, bbox):
function check_borders (line 21) | def check_borders(frame_sz, bbox):
FILE: tracker/sot/lib/dataset/crop/RGBT210/par_crop.py
function printProgress (line 14) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 35) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 46) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFC (line 50) | def crop_like_SiamFC(image, bbox, context_amount=0.5, exemplar_size=127,...
function crop_img (line 66) | def crop_img(im, bbox, instanc_size):
function crop_video (line 73) | def crop_video(video, crop_path, instanc_size):
function main (line 121) | def main(instanc_size=271, num_threads=24):
FILE: tracker/sot/lib/dataset/crop/RGBT234/RGBT234_genjson.py
function genjson (line 14) | def genjson():
FILE: tracker/sot/lib/dataset/crop/RGBT234/gen_json.py
function check_size (line 12) | def check_size(frame_sz, bbox):
function check_borders (line 21) | def check_borders(frame_sz, bbox):
FILE: tracker/sot/lib/dataset/crop/RGBT234/par_crop.py
function printProgress (line 14) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 35) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 46) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFC (line 50) | def crop_like_SiamFC(image, bbox, context_amount=0.5, exemplar_size=127,...
function crop_img (line 66) | def crop_img(im, bbox, instanc_size):
function crop_video (line 72) | def crop_video(video, crop_path, instanc_size):
function main (line 116) | def main(instanc_size=271, num_threads=24):
FILE: tracker/sot/lib/dataset/crop/coco/par_crop.py
function printProgress (line 12) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 33) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 44) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFC (line 48) | def crop_like_SiamFC(image, bbox, context_amount=0.5, exemplar_size=127,...
function crop_img (line 64) | def crop_img(img, anns, set_crop_base_path, set_img_base_path, instanc_s...
function main (line 80) | def main(dataDir='.', instanc_size=511, num_threads=12):
FILE: tracker/sot/lib/dataset/crop/det/par_crop.py
function printProgress (line 13) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 34) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 45) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFC (line 49) | def crop_like_SiamFC(image, bbox, context_amount=0.5, exemplar_size=127,...
function crop_xml (line 65) | def crop_xml(xml, sub_set_crop_path, instanc_size=511):
function main (line 87) | def main(VID_base_path='/data/share/ILSVRC', instanc_size=511, num_threa...
FILE: tracker/sot/lib/dataset/crop/got10k/gen_json.py
function check_size (line 10) | def check_size(frame_sz, bbox):
function check_borders (line 19) | def check_borders(frame_sz, bbox):
FILE: tracker/sot/lib/dataset/crop/got10k/par_crop.py
function printProgress (line 16) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 37) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 48) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFC (line 52) | def crop_like_SiamFC(image, bbox, context_amount=0.5, exemplar_size=127,...
function crop_video (line 68) | def crop_video(sub_set, video, crop_path, instanc_size):
function main (line 96) | def main(instanc_size=511, num_threads=24):
FILE: tracker/sot/lib/dataset/crop/lasot/gen_json.py
function check_size (line 10) | def check_size(frame_sz, bbox):
function check_borders (line 19) | def check_borders(frame_sz, bbox):
FILE: tracker/sot/lib/dataset/crop/lasot/par_crop.py
function printProgress (line 16) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 37) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 48) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFC (line 52) | def crop_like_SiamFC(image, bbox, context_amount=0.5, exemplar_size=127,...
function crop_video (line 68) | def crop_video(video_f, video, crop_path, instanc_size):
function main (line 102) | def main(instanc_size=511, num_threads=24):
FILE: tracker/sot/lib/dataset/crop/vid/gen_json.py
function check_size (line 10) | def check_size(frame_sz, bbox):
function check_borders (line 19) | def check_borders(frame_sz, bbox):
FILE: tracker/sot/lib/dataset/crop/vid/par_crop.py
function printProgress (line 23) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 44) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 55) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFC (line 59) | def crop_like_SiamFC(image, bbox, context_amount=0.5, exemplar_size=127,...
function crop_video (line 75) | def crop_video(sub_set, video, crop_path, instanc_size):
function main (line 104) | def main(instanc_size=511, num_threads=24):
FILE: tracker/sot/lib/dataset/crop/visdrone/gen_json.py
function check_size (line 10) | def check_size(frame_sz, bbox):
function check_borders (line 19) | def check_borders(frame_sz, bbox):
FILE: tracker/sot/lib/dataset/crop/visdrone/par_crop.py
function printProgress (line 16) | def printProgress(iteration, total, prefix='', suffix='', decimals=1, ba...
function crop_hwc (line 37) | def crop_hwc(image, bbox, out_sz, padding=(0, 0, 0)):
function pos_s_2_bbox (line 48) | def pos_s_2_bbox(pos, s):
function crop_like_SiamFC (line 52) | def crop_like_SiamFC(image, bbox, context_amount=0.5, exemplar_size=127,...
function crop_video (line 68) | def crop_video(sub_set, video, crop_path, instanc_size):
function main (line 96) | def main(instanc_size=511, num_threads=24):
FILE: tracker/sot/lib/dataset/ocean.py
class OceanDataset (line 25) | class OceanDataset(Dataset):
method __init__ (line 26) | def __init__(self, cfg):
method __len__ (line 76) | def __len__(self):
method __getitem__ (line 79) | def __getitem__(self, index):
method grids (line 116) | def grids(self):
method reg_label (line 133) | def reg_label(self, bbox):
method check_exists (line 153) | def check_exists(self, index, dataset, template, search):
method _shuffle (line 171) | def _shuffle(self):
method _choose_dataset (line 189) | def _choose_dataset(self, index):
method _get_image_anno (line 194) | def _get_image_anno(self, video, track, frame, RGBT_FLAG=False):
method _get_pairs (line 213) | def _get_pairs(self, index):
method _posNegRandom (line 237) | def _posNegRandom(self):
method _toBBox (line 243) | def _toBBox(self, image, shape):
method _crop_hwc (line 262) | def _crop_hwc(self, image, bbox, out_sz, padding=(0, 0, 0)):
method _draw (line 276) | def _draw(self, image, box, name):
method _draw_reg (line 287) | def _draw_reg(self, image, grid_x, grid_y, reg_label, reg_weight, save...
method _mixupRandom (line 310) | def _mixupRandom(self):
method _augmentation (line 319) | def _augmentation(self, image, bbox, size, search=False):
method _mixupShift (line 350) | def _mixupShift(self, image, size):
method _dynamic_label (line 368) | def _dynamic_label(self, fixedLabelSize, c_shift, rPos=2, rNeg=0):
method _create_dynamic_logisticloss_label (line 378) | def _create_dynamic_logisticloss_label(self, label_size, c_shift, rPos...
class subData (line 405) | class subData(object):
method __init__ (line 409) | def __init__(self, cfg, data_name, start):
method _clean (line 425) | def _clean(self):
method _shuffle (line 468) | def _shuffle(self):
method _get_image_anno (line 483) | def _get_image_anno(self, video, track, frame):
method _get_pairs (line 495) | def _get_pairs(self, index, data_name):
method _get_negative_target (line 522) | def _get_negative_target(self, index=-1):
FILE: tracker/sot/lib/dataset/siamfc.py
class SiamFCDataset (line 28) | class SiamFCDataset(Dataset):
method __init__ (line 29) | def __init__(self, cfg):
method __len__ (line 69) | def __len__(self):
method __getitem__ (line 72) | def __getitem__(self, index):
method _shuffle (line 101) | def _shuffle(self):
method _get_image_anno (line 116) | def _get_image_anno(self, video, track, frame):
method _get_pairs (line 126) | def _get_pairs(self, index):
method _posNegRandom (line 150) | def _posNegRandom(self):
method _toBBox (line 156) | def _toBBox(self, image, shape):
method _crop_hwc (line 174) | def _crop_hwc(self, image, bbox, out_sz, padding=(0, 0, 0)):
method _draw (line 188) | def _draw(self, image, box, name):
method _augmentation (line 202) | def _augmentation(self, image, bbox, size):
method _dynamic_label (line 232) | def _dynamic_label(self, fixedLabelSize, c_shift, rPos=2, rNeg=0):
method _create_dynamic_logisticloss_label (line 242) | def _create_dynamic_logisticloss_label(self, label_size, c_shift, rPos...
FILE: tracker/sot/lib/eval_toolkit/bin/_init_paths.py
function add_path (line 10) | def add_path(path):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/__init__.py
class DatasetFactory (line 9) | class DatasetFactory(object):
method create_dataset (line 11) | def create_dataset(**kwargs):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/dataset.py
class Dataset (line 3) | class Dataset(object):
method __init__ (line 4) | def __init__(self, name, dataset_root):
method __getitem__ (line 9) | def __getitem__(self, idx):
method __len__ (line 15) | def __len__(self):
method __iter__ (line 18) | def __iter__(self):
method set_tracker (line 23) | def set_tracker(self, path, tracker_names):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/got10k.py
class GOT10kVideo (line 12) | class GOT10kVideo(Video):
method __init__ (line 23) | def __init__(self, name, root, video_dir, init_rect, img_names,
class GOT10kDataset (line 52) | class GOT10kDataset(Dataset):
method __init__ (line 58) | def __init__(self, name, dataset_root, load_img=False):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/lasot.py
class LaSOTVideo (line 11) | class LaSOTVideo(Video):
method __init__ (line 22) | def __init__(self, name, root, video_dir, init_rect, img_names,
method load_tracker (line 28) | def load_tracker(self, path, tracker_names=None, store=True):
class LaSOTDataset (line 57) | class LaSOTDataset(Dataset):
method __init__ (line 64) | def __init__(self, name, dataset_root, load_img=False):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/nfs.py
class NFSVideo (line 12) | class NFSVideo(Video):
method __init__ (line 23) | def __init__(self, name, root, video_dir, init_rect, img_names,
class NFSDataset (line 52) | class NFSDataset(Dataset):
method __init__ (line 58) | def __init__(self, name, dataset_root, load_img=False):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/otb.py
class OTBVideo (line 12) | class OTBVideo(Video):
method __init__ (line 23) | def __init__(self, name, root, video_dir, init_rect, img_names,
method load_tracker (line 28) | def load_tracker(self, path, tracker_names=None, store=True):
class OTBDataset (line 77) | class OTBDataset(Dataset):
method __init__ (line 84) | def __init__(self, name, dataset_root, load_img=False):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/trackingnet.py
class TrackingNetVideo (line 11) | class TrackingNetVideo(Video):
method __init__ (line 22) | def __init__(self, name, root, video_dir, init_rect, img_names,
class TrackingNetDataset (line 51) | class TrackingNetDataset(Dataset):
method __init__ (line 57) | def __init__(self, name, dataset_root, load_img=False):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/uav.py
class UAVVideo (line 10) | class UAVVideo(Video):
method __init__ (line 21) | def __init__(self, name, root, video_dir, init_rect, img_names,
class UAVDataset (line 27) | class UAVDataset(Dataset):
method __init__ (line 34) | def __init__(self, name, dataset_root, load_img=False):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/video.py
class Video (line 9) | class Video(object):
method __init__ (line 10) | def __init__(self, name, root, video_dir, init_rect, img_names,
method load_tracker (line 32) | def load_tracker(self, path, tracker_names=None, store=True):
method load_img (line 59) | def load_img(self):
method free_img (line 66) | def free_img(self):
method __len__ (line 69) | def __len__(self):
method __getitem__ (line 72) | def __getitem__(self, idx):
method __iter__ (line 79) | def __iter__(self):
method draw_box (line 87) | def draw_box(self, roi, img, linewidth, color, name=None):
method show (line 110) | def show(self, pred_trajs={}, linewidth=2, show_name=False):
FILE: tracker/sot/lib/eval_toolkit/pysot/datasets/vot.py
class VOTVideo (line 13) | class VOTVideo(Video):
method __init__ (line 28) | def __init__(self, name, root, video_dir, init_rect, img_names, gt_rect,
method select_tag (line 59) | def select_tag(self, tag, start=0, end=0):
method load_tracker (line 64) | def load_tracker(self, path, tracker_names=None, store=True):
class VOTDataset (line 92) | class VOTDataset(Dataset):
method __init__ (line 99) | def __init__(self, name, dataset_root, load_img=False):
class VOTLTVideo (line 127) | class VOTLTVideo(Video):
method __init__ (line 137) | def __init__(self, name, root, video_dir, init_rect, img_names,
method load_tracker (line 150) | def load_tracker(self, path, tracker_names=None, store=True):
class VOTLTDataset (line 178) | class VOTLTDataset(Dataset):
method __init__ (line 185) | def __init__(self, name, dataset_root, load_img=False):
FILE: tracker/sot/lib/eval_toolkit/pysot/evaluation/ar_benchmark.py
class AccuracyRobustnessBenchmark (line 12) | class AccuracyRobustnessBenchmark:
method __init__ (line 18) | def __init__(self, dataset, burnin=10):
method eval (line 22) | def eval(self, eval_trackers=None):
method show_result (line 42) | def show_result(self, result, eao_result=None, show_video_level=False,...
method _calculate_accuracy_robustness (line 118) | def _calculate_accuracy_robustness(self, tracker_name):
FILE: tracker/sot/lib/eval_toolkit/pysot/evaluation/eao_benchmark.py
class EAOBenchmark (line 9) | class EAOBenchmark:
method __init__ (line 14) | def __init__(self, dataset, skipping=5, tags=['all']):
method eval (line 32) | def eval(self, eval_trackers=None):
method show_result (line 51) | def show_result(self, result, topk=10):
method _calculate_eao (line 89) | def _calculate_eao(self, tracker_name, tags):
FILE: tracker/sot/lib/eval_toolkit/pysot/evaluation/f1_benchmark.py
class F1Benchmark (line 10) | class F1Benchmark:
method __init__ (line 11) | def __init__(self, dataset):
method eval (line 18) | def eval(self, eval_trackers=None):
method _cal_precision_reall (line 40) | def _cal_precision_reall(self, tracker_name):
method show_result (line 70) | def show_result(self, result, show_video_level=False, helight_threshol...
FILE: tracker/sot/lib/eval_toolkit/pysot/evaluation/ope_benchmark.py
class OPEBenchmark (line 7) | class OPEBenchmark:
method __init__ (line 13) | def __init__(self, dataset):
method convert_bb_to_center (line 16) | def convert_bb_to_center(self, bboxes):
method convert_bb_to_norm_center (line 20) | def convert_bb_to_norm_center(self, bboxes, gt_wh):
method eval_success (line 23) | def eval_success(self, eval_trackers=None):
method eval_precision (line 54) | def eval_precision(self, eval_trackers=None):
method eval_norm_precision (line 89) | def eval_norm_precision(self, eval_trackers=None):
method show_result (line 124) | def show_result(self, success_ret, precision_ret=None,
FILE: tracker/sot/lib/eval_toolkit/pysot/utils/misc.py
function determine_thresholds (line 4) | def determine_thresholds(confidence, resolution=100):
FILE: tracker/sot/lib/eval_toolkit/pysot/utils/region.c
type PyObject (line 360) | typedef PyObject *(*__Pyx_PyCFunctionFast) (PyObject *self, PyObject *co...
type PyObject (line 361) | typedef PyObject *(*__Pyx_PyCFunctionFastWithKeywords) (PyObject *self, ...
type Py_tss_t (line 402) | typedef int Py_tss_t;
function CYTHON_INLINE (line 403) | static CYTHON_INLINE int PyThread_tss_create(Py_tss_t *key) {
function CYTHON_INLINE (line 407) | static CYTHON_INLINE Py_tss_t * PyThread_tss_alloc(void) {
function CYTHON_INLINE (line 412) | static CYTHON_INLINE void PyThread_tss_free(Py_tss_t *key) {
function CYTHON_INLINE (line 415) | static CYTHON_INLINE int PyThread_tss_is_created(Py_tss_t *key) {
function CYTHON_INLINE (line 418) | static CYTHON_INLINE void PyThread_tss_delete(Py_tss_t *key) {
function CYTHON_INLINE (line 422) | static CYTHON_INLINE int PyThread_tss_set(Py_tss_t *key, void *value) {
function CYTHON_INLINE (line 425) | static CYTHON_INLINE void * PyThread_tss_get(Py_tss_t *key) {
type Py_hash_t (line 549) | typedef long Py_hash_t;
type __Pyx_PyAsyncMethodsStruct (line 572) | typedef struct {
function CYTHON_INLINE (line 586) | static CYTHON_INLINE float __PYX_NAN() {
type __Pyx_StringTabEntry (line 627) | typedef struct {PyObject **p; const char *s; const Py_ssize_t n; const c...
function CYTHON_INLINE (line 648) | static CYTHON_INLINE int __Pyx_is_valid_index(Py_ssize_t i, Py_ssize_t l...
function CYTHON_INLINE (line 697) | static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u) {
function __Pyx_init_sys_getdefaultencoding_params (line 729) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function __Pyx_init_sys_getdefaultencoding_params (line 779) | static int __Pyx_init_sys_getdefaultencoding_params(void) {
function CYTHON_INLINE (line 811) | static CYTHON_INLINE void __Pyx_pretend_to_initialize(void* ptr) { (void...
type __pyx_obj_6region_RegionBounds (line 832) | struct __pyx_obj_6region_RegionBounds
type __pyx_obj_6region_Rectangle (line 833) | struct __pyx_obj_6region_Rectangle
type __pyx_obj_6region_Polygon (line 834) | struct __pyx_obj_6region_Polygon
type __pyx_obj___Pyx_EnumMeta (line 835) | struct __pyx_obj___Pyx_EnumMeta
type __pyx_t_6region_RegionType (line 844) | enum __pyx_t_6region_RegionType {
type __pyx_obj_6region_RegionBounds (line 859) | struct __pyx_obj_6region_RegionBounds {
type __pyx_obj_6region_Rectangle (line 872) | struct __pyx_obj_6region_Rectangle {
type __pyx_obj_6region_Polygon (line 885) | struct __pyx_obj_6region_Polygon {
type __pyx_obj___Pyx_EnumMeta (line 898) | struct __pyx_obj___Pyx_EnumMeta {
type __Pyx_RefNannyAPIStruct (line 909) | typedef struct {
function CYTHON_INLINE (line 1178) | static CYTHON_INLINE int __Pyx_PyList_Append(PyObject* list, PyObject* x) {
function CYTHON_INLINE (line 1204) | static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16(const char *s...
function CYTHON_INLINE (line 1208) | static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16LE(const char ...
function CYTHON_INLINE (line 1212) | static CYTHON_INLINE PyObject *__Pyx_PyUnicode_DecodeUTF16BE(const char ...
type __pyx_CyFunctionObject (line 1337) | typedef struct {
type __Pyx_CodeObjectCacheEntry (line 1395) | typedef struct {
type __Pyx_CodeObjectCache (line 1399) | struct __Pyx_CodeObjectCache {
type __Pyx_CodeObjectCache (line 1404) | struct __Pyx_CodeObjectCache
type __pyx_t_6region_RegionType (line 1426) | enum __pyx_t_6region_RegionType
type __pyx_obj___Pyx_EnumMeta (line 1464) | struct __pyx_obj___Pyx_EnumMeta
type __pyx_obj_6region_RegionBounds (line 1705) | struct __pyx_obj_6region_RegionBounds
type __pyx_obj_6region_RegionBounds (line 1706) | struct __pyx_obj_6region_RegionBounds
type __pyx_obj_6region_RegionBounds (line 1707) | struct __pyx_obj_6region_RegionBounds
type __pyx_obj_6region_RegionBounds (line 1708) | struct __pyx_obj_6region_RegionBounds
type __pyx_obj_6region_RegionBounds (line 1709) | struct __pyx_obj_6region_RegionBounds
type __pyx_obj_6region_RegionBounds (line 1710) | struct __pyx_obj_6region_RegionBounds
type __pyx_obj_6region_Rectangle (line 1713) | struct __pyx_obj_6region_Rectangle
type __pyx_obj_6region_Rectangle (line 1714) | struct __pyx_obj_6region_Rectangle
type __pyx_obj_6region_Rectangle (line 1715) | struct __pyx_obj_6region_Rectangle
type __pyx_obj_6region_Rectangle (line 1716) | struct __pyx_obj_6region_Rectangle
type __pyx_obj_6region_Rectangle (line 1717) | struct __pyx_obj_6region_Rectangle
type __pyx_obj_6region_Rectangle (line 1718) | struct __pyx_obj_6region_Rectangle
type __pyx_obj_6region_Polygon (line 1721) | struct __pyx_obj_6region_Polygon
type __pyx_obj_6region_Polygon (line 1722) | struct __pyx_obj_6region_Polygon
type __pyx_obj_6region_Polygon (line 1723) | struct __pyx_obj_6region_Polygon
type __pyx_obj___Pyx_EnumMeta (line 1729) | struct __pyx_obj___Pyx_EnumMeta
type __pyx_obj___Pyx_EnumMeta (line 1730) | struct __pyx_obj___Pyx_EnumMeta
type __pyx_obj___Pyx_EnumMeta (line 1731) | struct __pyx_obj___Pyx_EnumMeta
type __pyx_obj___Pyx_EnumMeta (line 1732) | struct __pyx_obj___Pyx_EnumMeta
type __pyx_obj___Pyx_EnumMeta (line 1733) | struct __pyx_obj___Pyx_EnumMeta
function __pyx_pw_6region_12RegionBounds_1__cinit__ (line 1779) | static int __pyx_pw_6region_12RegionBounds_1__cinit__(PyObject *__pyx_v_...
function __pyx_pf_6region_12RegionBounds___cinit__ (line 1793) | static int __pyx_pf_6region_12RegionBounds___cinit__(struct __pyx_obj_6r...
function __pyx_pw_6region_12RegionBounds_3__init__ (line 1874) | static int __pyx_pw_6region_12RegionBounds_3__init__(PyObject *__pyx_v_s...
function __pyx_pf_6region_12RegionBounds_2__init__ (line 1955) | static int __pyx_pf_6region_12RegionBounds_2__init__(struct __pyx_obj_6r...
function __pyx_pw_6region_12RegionBounds_5__dealloc__ (line 2060) | static void __pyx_pw_6region_12RegionBounds_5__dealloc__(PyObject *__pyx...
function __pyx_pf_6region_12RegionBounds_4__dealloc__ (line 2069) | static void __pyx_pf_6region_12RegionBounds_4__dealloc__(struct __pyx_ob...
function PyObject (line 2133) | static PyObject *__pyx_pw_6region_12RegionBounds_7__str__(PyObject *__py...
function PyObject (line 2144) | static PyObject *__pyx_pf_6region_12RegionBounds_6__str__(struct __pyx_o...
function PyObject (line 2307) | static PyObject *__pyx_pw_6region_12RegionBounds_9get(PyObject *__pyx_v_...
function PyObject (line 2318) | static PyObject *__pyx_pf_6region_12RegionBounds_8get(struct __pyx_obj_6...
function PyObject (line 2427) | static PyObject *__pyx_pw_6region_12RegionBounds_11set(PyObject *__pyx_v...
function PyObject (line 2508) | static PyObject *__pyx_pf_6region_12RegionBounds_10set(struct __pyx_obj_...
function PyObject (line 2582) | static PyObject *__pyx_pw_6region_12RegionBounds_13__reduce_cython__(PyO...
function PyObject (line 2593) | static PyObject *__pyx_pf_6region_12RegionBounds_12__reduce_cython__(CYT...
function PyObject (line 2636) | static PyObject *__pyx_pw_6region_12RegionBounds_15__setstate_cython__(P...
function PyObject (line 2647) | static PyObject *__pyx_pf_6region_12RegionBounds_14__setstate_cython__(C...
function __pyx_pw_6region_9Rectangle_1__cinit__ (line 2691) | static int __pyx_pw_6region_9Rectangle_1__cinit__(PyObject *__pyx_v_self...
function __pyx_pf_6region_9Rectangle___cinit__ (line 2705) | static int __pyx_pf_6region_9Rectangle___cinit__(struct __pyx_obj_6regio...
function __pyx_pw_6region_9Rectangle_3__init__ (line 2786) | static int __pyx_pw_6region_9Rectangle_3__init__(PyObject *__pyx_v_self,...
function __pyx_pf_6region_9Rectangle_2__init__ (line 2867) | static int __pyx_pf_6region_9Rectangle_2__init__(struct __pyx_obj_6regio...
function __pyx_pw_6region_9Rectangle_5__dealloc__ (line 2972) | static void __pyx_pw_6region_9Rectangle_5__dealloc__(PyObject *__pyx_v_s...
function __pyx_pf_6region_9Rectangle_4__dealloc__ (line 2981) | static void __pyx_pf_6region_9Rectangle_4__dealloc__(struct __pyx_obj_6r...
function PyObject (line 3045) | static PyObject *__pyx_pw_6region_9Rectangle_7__str__(PyObject *__pyx_v_...
function PyObject (line 3056) | static PyObject *__pyx_pf_6region_9Rectangle_6__str__(struct __pyx_obj_6...
function PyObject (line 3219) | static PyObject *__pyx_pw_6region_9Rectangle_9set(PyObject *__pyx_v_self...
function PyObject (line 3300) | static PyObject *__pyx_pf_6region_9Rectangle_8set(struct __pyx_obj_6regi...
function PyObject (line 3377) | static PyObject *__pyx_pw_6region_9Rectangle_11get(PyObject *__pyx_v_sel...
function PyObject (line 3388) | static PyObject *__pyx_pf_6region_9Rectangle_10get(struct __pyx_obj_6reg...
function PyObject (line 3495) | static PyObject *__pyx_pw_6region_9Rectangle_13__reduce_cython__(PyObjec...
function PyObject (line 3506) | static PyObject *__pyx_pf_6region_9Rectangle_12__reduce_cython__(CYTHON_...
function PyObject (line 3549) | static PyObject *__pyx_pw_6region_9Rectangle_15__setstate_cython__(PyObj...
function PyObject (line 3560) | static PyObject *__pyx_pf_6region_9Rectangle_14__setstate_cython__(CYTHO...
function __pyx_pw_6region_7Polygon_1__cinit__ (line 3604) | static int __pyx_pw_6region_7Polygon_1__cinit__(PyObject *__pyx_v_self, ...
function __pyx_pf_6region_7Polygon___cinit__ (line 3652) | static int __pyx_pf_6region_7Polygon___cinit__(struct __pyx_obj_6region_...
function __pyx_pw_6region_7Polygon_3__dealloc__ (line 3959) | static void __pyx_pw_6region_7Polygon_3__dealloc__(PyObject *__pyx_v_sel...
function __pyx_pf_6region_7Polygon_2__dealloc__ (line 3968) | static void __pyx_pf_6region_7Polygon_2__dealloc__(struct __pyx_obj_6reg...
function PyObject (line 4106) | static PyObject *__pyx_pw_6region_7Polygon_5__str__(PyObject *__pyx_v_se...
function PyObject (line 4117) | static PyObject *__pyx_pf_6region_7Polygon_4__str__(struct __pyx_obj_6re...
function PyObject (line 4370) | static PyObject *__pyx_pw_6region_7Polygon_7__reduce_cython__(PyObject *...
function PyObject (line 4381) | static PyObject *__pyx_pf_6region_7Polygon_6__reduce_cython__(CYTHON_UNU...
function PyObject (line 4424) | static PyObject *__pyx_pw_6region_7Polygon_9__setstate_cython__(PyObject...
function PyObject (line 4435) | static PyObject *__pyx_pf_6region_7Polygon_8__setstate_cython__(CYTHON_U...
function PyObject (line 4481) | static PyObject *__pyx_pw_6region_1vot_overlap(PyObject *__pyx_self, PyO...
function PyObject (line 4555) | static PyObject *__pyx_pf_6region_vot_overlap(CYTHON_UNUSED PyObject *__...
function PyObject (line 5215) | static PyObject *__pyx_pw_6region_3vot_overlap_traj(PyObject *__pyx_self...
function PyObject (line 5289) | static PyObject *__pyx_pf_6region_2vot_overlap_traj(CYTHON_UNUSED PyObje...
function PyObject (line 5437) | static PyObject *__pyx_pw_6region_5vot_float2str(PyObject *__pyx_self, P...
function PyObject (line 5496) | static PyObject *__pyx_pf_6region_4vot_float2str(CYTHON_UNUSED PyObject ...
function __pyx_pw_8EnumBase_14__Pyx_EnumMeta_1__init__ (line 5720) | static int __pyx_pw_8EnumBase_14__Pyx_EnumMeta_1__init__(PyObject *__pyx...
function __pyx_pf_8EnumBase_14__Pyx_EnumMeta___init__ (line 5790) | static int __pyx_pf_8EnumBase_14__Pyx_EnumMeta___init__(struct __pyx_obj...
function PyObject (line 5921) | static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_3__iter__(PyObject ...
function PyObject (line 5932) | static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_2__iter__(struct __...
function PyObject (line 6006) | static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_5__getitem__(PyObje...
function PyObject (line 6017) | static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_4__getitem__(struct...
function PyObject (line 6069) | static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_7__reduce_cython__(...
function PyObject (line 6080) | static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_6__reduce_cython__(...
function PyObject (line 6295) | static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumMeta_9__setstate_cython_...
function PyObject (line 6306) | static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumMeta_8__setstate_cython_...
function PyObject (line 6353) | static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_1__new__(PyObject *...
function PyObject (line 6427) | static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase___new__(CYTHON_UNUS...
function PyObject (line 6707) | static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_3__repr__(PyObject ...
function PyObject (line 6718) | static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase_2__repr__(CYTHON_UN...
function PyObject (line 6791) | static PyObject *__pyx_pw_8EnumBase_14__Pyx_EnumBase_5__str__(PyObject *...
function PyObject (line 6802) | static PyObject *__pyx_pf_8EnumBase_14__Pyx_EnumBase_4__str__(CYTHON_UNU...
function PyObject (line 6870) | static PyObject *__pyx_pw_8EnumBase_1__pyx_unpickle___Pyx_EnumMeta(PyObj...
function PyObject (line 6940) | static PyObject *__pyx_pf_8EnumBase___pyx_unpickle___Pyx_EnumMeta(CYTHON...
function PyObject (line 7128) | static PyObject *__pyx_unpickle___Pyx_EnumMeta__set_state(struct __pyx_o...
function PyObject (line 7230) | static PyObject *__pyx_tp_new_6region_RegionBounds(PyTypeObject *t, CYTH...
function __pyx_tp_dealloc_6region_RegionBounds (line 7245) | static void __pyx_tp_dealloc_6region_RegionBounds(PyObject *o) {
type __pyx_obj_6region_RegionBounds (line 7273) | struct __pyx_obj_6region_RegionBounds
function PyObject (line 7339) | static PyObject *__pyx_tp_new_6region_Rectangle(PyTypeObject *t, CYTHON_...
function __pyx_tp_dealloc_6region_Rectangle (line 7354) | static void __pyx_tp_dealloc_6region_Rectangle(PyObject *o) {
type __pyx_obj_6region_Rectangle (line 7382) | struct __pyx_obj_6region_Rectangle
function PyObject (line 7448) | static PyObject *__pyx_tp_new_6region_Polygon(PyTypeObject *t, PyObject ...
function __pyx_tp_dealloc_6region_Polygon (line 7463) | static void __pyx_tp_dealloc_6region_Polygon(PyObject *o) {
type __pyx_obj_6region_Polygon (line 7489) | struct __pyx_obj_6region_Polygon
function PyObject (line 7555) | static PyObject *__pyx_tp_new___Pyx_EnumMeta(PyTypeObject *t, PyObject *...
function __pyx_tp_dealloc___Pyx_EnumMeta (line 7561) | static void __pyx_tp_dealloc___Pyx_EnumMeta(PyObject *o) {
function __pyx_tp_traverse___Pyx_EnumMeta (line 7572) | static int __pyx_tp_traverse___Pyx_EnumMeta(PyObject *o, visitproc v, vo...
function __pyx_tp_clear___Pyx_EnumMeta (line 7578) | static int __pyx_tp_clear___Pyx_EnumMeta(PyObject *o) {
function PyObject (line 7582) | static PyObject *__pyx_sq_item___Pyx_EnumMeta(PyObject *o, Py_ssize_t i) {
type __pyx_obj___Pyx_EnumMeta (line 7618) | struct __pyx_obj___Pyx_EnumMeta
type PyModuleDef (line 7699) | struct PyModuleDef
function CYTHON_SMALL_CODE (line 7847) | static CYTHON_SMALL_CODE int __Pyx_InitCachedBuiltins(void) {
function CYTHON_SMALL_CODE (line 7857) | static CYTHON_SMALL_CODE int __Pyx_InitCachedConstants(void) {
function CYTHON_SMALL_CODE (line 8009) | static CYTHON_SMALL_CODE int __Pyx_InitGlobals(void) {
function __Pyx_modinit_global_init_code (line 8028) | static int __Pyx_modinit_global_init_code(void) {
function __Pyx_modinit_variable_export_code (line 8039) | static int __Pyx_modinit_variable_export_code(void) {
function __Pyx_modinit_function_export_code (line 8047) | static int __Pyx_modinit_function_export_code(void) {
function __Pyx_modinit_type_init_code (line 8055) | static int __Pyx_modinit_type_init_code(void) {
function __Pyx_modinit_type_import_code (line 8106) | static int __Pyx_modinit_type_import_code(void) {
function __Pyx_modinit_variable_import_code (line 8114) | static int __Pyx_modinit_variable_import_code(void) {
function __Pyx_modinit_function_import_code (line 8122) | static int __Pyx_modinit_function_import_code(void) {
function __Pyx_PyMODINIT_FUNC (line 8151) | __Pyx_PyMODINIT_FUNC PyInit_region(void)
function CYTHON_SMALL_CODE (line 8156) | static CYTHON_SMALL_CODE int __Pyx_check_single_interpreter(void) {
function CYTHON_SMALL_CODE (line 8179) | static CYTHON_SMALL_CODE int __Pyx_copy_spec_to_module(PyObject *spec, P...
function CYTHON_SMALL_CODE (line 8194) | static CYTHON_SMALL_CODE PyObject* __pyx_pymod_create(PyObject *spec, CY...
function __Pyx_RefNannyAPIStruct (line 9036) | static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modn...
function CYTHON_INLINE (line 9053) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, ...
function PyObject (line 9066) | static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
function __Pyx_RaiseArgtupleInvalid (line 9080) | static void __Pyx_RaiseArgtupleInvalid(
function __Pyx_CheckKeywordStrings (line 9106) | static int __Pyx_CheckKeywordStrings(
function __Pyx_RaiseDoubleKeywordsError (line 9146) | static void __Pyx_RaiseDoubleKeywordsError(
function __Pyx_ParseOptionalKeywords (line 9160) | static int __Pyx_ParseOptionalKeywords(
function PyObject (line 9263) | static PyObject* __Pyx_PyFunction_FastCallNoKw(PyCodeObject *co, PyObjec...
function CYTHON_INLINE (line 9382) | static CYTHON_INLINE PyObject * __Pyx_PyCFunction_FastCall(PyObject *fun...
function CYTHON_INLINE (line 9405) | static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObj...
function CYTHON_INLINE (line 9425) | static CYTHON_INLINE void __Pyx_ErrRestoreInState(PyThreadState *tstate,...
function CYTHON_INLINE (line 9437) | static CYTHON_INLINE void __Pyx_ErrFetchInState(PyThreadState *tstate, P...
function __Pyx_Raise (line 9449) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
function __Pyx_Raise (line 9500) | static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, P...
function CYTHON_INLINE (line 9607) | static CYTHON_INLINE Py_ssize_t __Pyx_div_Py_ssize_t(Py_ssize_t a, Py_ss...
function CYTHON_INLINE (line 9616) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, ...
function PyObject (line 9636) | static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *ar...
function CYTHON_INLINE (line 9646) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,...
function CYTHON_INLINE (line 9664) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func,...
function PyObject (line 9675) | static PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
function CYTHON_INLINE (line 9682) | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, P...
function CYTHON_INLINE (line 9700) | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, ...
function CYTHON_INLINE (line 9718) | static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssi...
function PyObject (line 9763) | static PyObject *__Pyx_PyObject_GetIndex(PyObject *obj, PyObject* index) {
function PyObject (line 9781) | static PyObject *__Pyx_PyObject_GetItem(PyObject *obj, PyObject* key) {
function PyObject (line 9792) | static PyObject* __Pyx_PyInt_AddObjC(PyObject *op1, PyObject *op2, CYTHO...
function __Pyx__PyObject_AsDouble (line 9915) | static double __Pyx__PyObject_AsDouble(PyObject* obj) {
function CYTHON_INLINE (line 9956) | static CYTHON_INLINE PY_UINT64_T __Pyx_get_tp_dict_version(PyObject *obj) {
function CYTHON_INLINE (line 9960) | static CYTHON_INLINE PY_UINT64_T __Pyx_get_object_dict_version(PyObject ...
function CYTHON_INLINE (line 9972) | static CYTHON_INLINE int __Pyx_object_dict_version_matches(PyObject* obj...
function CYTHON_INLINE (line 9984) | static CYTHON_INLINE PyObject *__Pyx__GetModuleGlobalName(PyObject *name)
function CYTHON_INLINE (line 10017) | static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
function CYTHON_INLINE (line 10038) | static CYTHON_INLINE PyObject* __Pyx_decode_c_string(
function __Pyx_GetException (line 10074) | static int __Pyx_GetException(PyObject **type, PyObject **value, PyObjec...
function CYTHON_INLINE (line 10146) | static CYTHON_INLINE void __Pyx__ExceptionSwap(PyThreadState *tstate, Py...
function CYTHON_INLINE (line 10169) | static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject ...
function _PyErr_StackItem (line 10181) | static _PyErr_StackItem *
function CYTHON_INLINE (line 10196) | static CYTHON_INLINE void __Pyx__ExceptionSave(PyThreadState *tstate, Py...
function CYTHON_INLINE (line 10211) | static CYTHON_INLINE void __Pyx__ExceptionReset(PyThreadState *tstate, P...
function CYTHON_INLINE (line 10237) | static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObje...
function __Pyx_PyErr_ExceptionMatchesTuple (line 10251) | static int __Pyx_PyErr_ExceptionMatchesTuple(PyObject *exc_type, PyObjec...
function CYTHON_INLINE (line 10264) | static CYTHON_INLINE int __Pyx_PyErr_ExceptionMatchesInState(PyThreadSta...
function CYTHON_INLINE (line 10275) | static CYTHON_INLINE PyObject *__Pyx_GetAttr(PyObject *o, PyObject *n) {
function PyObject (line 10288) | static PyObject *__Pyx_GetAttr3Default(PyObject *d) {
function CYTHON_INLINE (line 10297) | static CYTHON_INLINE PyObject *__Pyx_GetAttr3(PyObject *o, PyObject *n, ...
function PyObject (line 10303) | static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int l...
function PyObject (line 10368) | static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
function CYTHON_UNUSED (line 10382) | static CYTHON_UNUSED PyObject* __Pyx_PyObject_Call2Args(PyObject* functi...
function CYTHON_INLINE (line 10411) | static CYTHON_INLINE int __Pyx_HasAttr(PyObject *o, PyObject *n) {
function PyObject (line 10430) | static PyObject *__Pyx_RaiseGenericGetAttributeError(PyTypeObject *tp, P...
function CYTHON_INLINE (line 10441) | static CYTHON_INLINE PyObject* __Pyx_PyObject_GenericGetAttrNoDict(PyObj...
function PyObject (line 10470) | static PyObject* __Pyx_PyObject_GenericGetAttr(PyObject* obj, PyObject* ...
function __Pyx_setup_reduce_is_named (line 10479) | static int __Pyx_setup_reduce_is_named(PyObject* meth, PyObject* name) {
function __Pyx_setup_reduce (line 10495) | static int __Pyx_setup_reduce(PyObject* type_obj) {
function PyObject (line 10555) | static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObj...
function PyTypeObject (line 10594) | static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
function PyObject (line 10634) | static PyObject *
function __Pyx_CyFunction_set_doc (line 10654) | static int
function PyObject (line 10666) | static PyObject *
function __Pyx_CyFunction_set_name (line 10681) | static int
function PyObject (line 10701) | static PyObject *
function __Pyx_CyFunction_set_qualname (line 10707) | static int
function PyObject (line 10727) | static PyObject *
function PyObject (line 10737) | static PyObject *
function __Pyx_CyFunction_set_dict (line 10748) | static int
function PyObject (line 10768) | static PyObject *
function PyObject (line 10774) | static PyObject *
function PyObject (line 10780) | static PyObject *
function __Pyx_CyFunction_init_defaults (line 10787) | static int
function __Pyx_CyFunction_set_defaults (line 10809) | static int
function PyObject (line 10825) | static PyObject *
function __Pyx_CyFunction_set_kwdefaults (line 10839) | static int
function PyObject (line 10855) | static PyObject *
function __Pyx_CyFunction_set_annotations (line 10869) | static int
function PyObject (line 10885) | static PyObject *
function PyObject (line 10921) | static PyObject *
function PyObject (line 10939) | static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *m...
function __Pyx_CyFunction_clear (line 10971) | static int
function __Pyx__CyFunction_dealloc (line 10996) | static void __Pyx__CyFunction_dealloc(__pyx_CyFunctionObject *m)
function __Pyx_CyFunction_dealloc (line 11003) | static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
function __Pyx_CyFunction_traverse (line 11008) | static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitpro...
function PyObject (line 11029) | static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *ob...
function PyObject (line 11045) | static PyObject*
function PyObject (line 11056) | static PyObject * __Pyx_CyFunction_CallMethod(PyObject *func, PyObject *...
function CYTHON_INLINE (line 11110) | static CYTHON_INLINE PyObject *__Pyx_CyFunction_Call(PyObject *func, PyO...
function PyObject (line 11113) | static PyObject *__Pyx_CyFunction_CallAsMethod(PyObject *func, PyObject ...
function __pyx_CyFunction_init (line 11202) | static int __pyx_CyFunction_init(void) {
function CYTHON_INLINE (line 11209) | static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func,...
function CYTHON_INLINE (line 11218) | static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *fu...
function CYTHON_INLINE (line 11223) | static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *f...
function CYTHON_INLINE (line 11228) | static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *...
function PyObject (line 11235) | static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject...
function PyObject (line 11268) | static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *nam...
function PyObject (line 11302) | static PyObject* __Pyx_Globals(void) {
function __Pyx_CLineForTraceback (line 11348) | static int __Pyx_CLineForTraceback(PyThreadState *tstate, int c_line) {
function __pyx_bisect_code_objects (line 11389) | static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries...
function PyCodeObject (line 11410) | static PyCodeObject *__pyx_find_code_object(int code_line) {
function __pyx_insert_code_object (line 11424) | static void __pyx_insert_code_object(int code_line, PyCodeObject* code_o...
function PyCodeObject (line 11472) | static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
function __Pyx_AddTraceback (line 11524) | static void __Pyx_AddTraceback(const char *funcname, int c_line,
function CYTHON_INLINE (line 11576) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
function CYTHON_INLINE (line 12174) | static CYTHON_INLINE PyObject* __Pyx_PyInt_From_enum____pyx_t_6region_Re...
function __Pyx_InBases (line 12206) | static int __Pyx_InBases(PyTypeObject *a, PyTypeObject *b) {
function CYTHON_INLINE (line 12214) | static CYTHON_INLINE int __Pyx_IsSubtype(PyTypeObject *a, PyTypeObject *...
function __Pyx_inner_PyErr_GivenExceptionMatches2 (line 12230) | static int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObject *err, PyObj...
function CYTHON_INLINE (line 12252) | static CYTHON_INLINE int __Pyx_inner_PyErr_GivenExceptionMatches2(PyObje...
function __Pyx_PyErr_GivenExceptionMatchesTuple (line 12260) | static int __Pyx_PyErr_GivenExceptionMatchesTuple(PyObject *exc_type, Py...
function CYTHON_INLINE (line 12281) | static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches(PyObject *err...
function CYTHON_INLINE (line 12293) | static CYTHON_INLINE int __Pyx_PyErr_GivenExceptionMatches2(PyObject *er...
function __Pyx_check_binary_version (line 12305) | static int __Pyx_check_binary_version(void) {
function __Pyx_InitStrings (line 12321) | static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
function CYTHON_INLINE (line 12353) | static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_...
function CYTHON_INLINE (line 12356) | static CYTHON_INLINE const char* __Pyx_PyObject_AsString(PyObject* o) {
function CYTHON_INLINE (line 12383) | static CYTHON_INLINE const char* __Pyx_PyUnicode_AsStringAndSize(PyObjec...
function CYTHON_INLINE (line 12425) | static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
function CYTHON_INLINE (line 12430) | static CYTHON_INLINE int __Pyx_PyObject_IsTrueAndDecref(PyObject* x) {
function PyObject (line 12437) | static PyObject* __Pyx_PyNumber_IntOrLongWrongResultType(PyObject* resul...
function CYTHON_INLINE (line 12506) | static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
function CYTHON_INLINE (line 12568) | static CYTHON_INLINE PyObject * __Pyx_PyBool_FromLong(long b) {
function CYTHON_INLINE (line 12571) | static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
FILE: tracker/sot/lib/eval_toolkit/pysot/utils/src/buffer.h
type string_buffer (line 18) | typedef struct string_buffer {
type string_list (line 24) | typedef struct string_list {
function __INLINE (line 32) | static __INLINE string_buffer* buffer_create(int L) {
function __INLINE (line 40) | static __INLINE void buffer_reset(string_buffer* B) {
function __INLINE (line 44) | static __INLINE void buffer_destroy(string_buffer** B) {
function __INLINE (line 54) | static __INLINE char* buffer_extract(const string_buffer* B) {
function __INLINE (line 61) | static __INLINE int buffer_size(const string_buffer* B) {
function __INLINE (line 65) | static __INLINE void buffer_push(string_buffer* B, char C) {
function __INLINE (line 75) | static __INLINE void buffer_append(string_buffer* B, const char *format,...
function __INLINE (line 110) | static __INLINE string_list* list_create(int L) {
function __INLINE (line 119) | static __INLINE void list_reset(string_list* B) {
function __INLINE (line 128) | static __INLINE void list_destroy(string_list **B) {
function __INLINE (line 145) | static __INLINE char* list_get(const string_list *B, int I) {
function __INLINE (line 161) | static __INLINE int list_size(const string_list *B) {
function __INLINE (line 165) | static __INLINE void list_append(string_list *B, char* S) {
function __INLINE (line 178) | static __INLINE void list_append_direct(string_list *B, char* S) {
FILE: tracker/sot/lib/eval_toolkit/pysot/utils/src/region.c
function region_set_flags (line 38) | int region_set_flags(int mask) {
function region_clear_flags (line 46) | int region_clear_flags(int mask) {
function __is_valid_sequence (line 54) | int __is_valid_sequence(float* sequence, int len) {
function region_container (line 95) | region_container* __create_region(region_type type) {
function _parse_sequence (line 116) | int _parse_sequence(const char* buffer, float** data) {
function region_parse (line 154) | int region_parse(const char* buffer, region_container** region) {
function region_print (line 318) | void region_print(FILE* out, region_container* region) {
function region_container (line 329) | region_container* region_convert(const region_container* region, region_...
function region_release (line 461) | void region_release(region_container** region) {
function region_container (line 486) | region_container* region_create_special(int code) {
function region_container (line 496) | region_container* region_create_rectangle(float x, float y, float width,...
function region_container (line 509) | region_container* region_create_polygon(int count) {
function free_polygon (line 528) | void free_polygon(region_polygon* polygon) {
function region_polygon (line 540) | region_polygon* allocate_polygon(int count) {
function region_polygon (line 555) | region_polygon* clone_polygon(const region_polygon* polygon) {
function region_polygon (line 565) | region_polygon* offset_polygon(const region_polygon* polygon, float x, f...
function region_polygon (line 578) | region_polygon* round_polygon(const region_polygon* polygon) {
function point_in_polygon (line 591) | int point_in_polygon(const region_polygon* polygon, float x, float y) {
function print_polygon (line 601) | void print_polygon(const region_polygon* polygon) {
function region_bounds (line 614) | region_bounds compute_bounds(const region_polygon* polygon) {
function region_bounds (line 634) | region_bounds bounds_round(region_bounds bounds) {
function region_bounds (line 645) | region_bounds bounds_intersection(region_bounds a, region_bounds b) {
function region_bounds (line 658) | region_bounds bounds_union(region_bounds a, region_bounds b) {
function bounds_overlap (line 671) | float bounds_overlap(region_bounds a, region_bounds b) {
function region_bounds (line 680) | region_bounds region_create_bounds(float left, float top, float right, f...
function region_bounds (line 692) | region_bounds region_compute_bounds(const region_container* region) {
function rasterize_polygon (line 723) | int rasterize_polygon(const region_polygon* polygon_input, char* mask, i...
function compute_polygon_overlap (line 848) | float compute_polygon_overlap(const region_polygon* p1, const region_pol...
function region_overlap (line 949) | region_overlap region_compute_overlap(const region_container* ra, const ...
function region_contains_point (line 985) | int region_contains_point(region_container* r, float x, float y) {
function region_get_mask (line 1001) | void region_get_mask(region_container* r, char* mask, int width, int hei...
function region_get_mask_offset (line 1015) | void region_get_mask_offset(region_container* r, char* mask, int x, int ...
FILE: tracker/sot/lib/eval_toolkit/pysot/utils/src/region.h
type region_type (line 46) | typedef enum region_type {EMPTY, SPECIAL, RECTANGLE, POLYGON, MASK} regi...
type region_bounds (line 48) | typedef struct region_bounds {
type region_polygon (line 57) | typedef struct region_polygon {
type region_mask (line 66) | typedef struct region_mask {
type region_rectangle (line 78) | typedef struct region_rectangle {
type region_container (line 87) | typedef struct region_container {
type region_overlap (line 97) | typedef struct region_overlap {
FILE: tracker/sot/lib/eval_toolkit/pysot/utils/statistics.py
function calculate_failures (line 4) | def calculate_failures(trajectory):
function calculate_accuracy (line 17) | def calculate_accuracy(pred_trajectory, gt_trajectory,
function overlap_ratio (line 75) | def overlap_ratio(rect1, rect2):
function success_overlap (line 98) | def success_overlap(gt_bb, result_bb, n_frame):
function success_error (line 109) | def success_error(gt_center, result_center, thresholds, n_frame):
function determine_thresholds (line 121) | def determine_thresholds(scores, resolution=100):
function calculate_f1 (line 136) | def calculate_f1(overlaps, score, bound, thresholds, N):
function calculate_expected_overlap (line 158) | def calculate_expected_overlap(fragments, fweights):
FILE: tracker/sot/lib/eval_toolkit/pysot/visualization/draw_eao.py
function draw_eao (line 11) | def draw_eao(result):
FILE: tracker/sot/lib/eval_toolkit/pysot/visualization/draw_f1.py
function draw_f1 (line 10) | def draw_f1(result, bold_name=None):
FILE: tracker/sot/lib/eval_toolkit/pysot/visualization/draw_success_precision.py
function draw_success_precision (line 6) | def draw_success_precision(success_ret, name, videos, attr, precision_re...
FILE: tracker/sot/lib/models/backbones.py
class ResNet50 (line 15) | class ResNet50(nn.Module):
method __init__ (line 16) | def __init__(self, used_layers=[2, 3, 4], online=False):
method forward (line 20) | def forward(self, x, online=False):
class ResNet22W (line 31) | class ResNet22W(nn.Module):
method __init__ (line 35) | def __init__(self):
method forward (line 40) | def forward(self, x):
FILE: tracker/sot/lib/models/cfnet.py
function complex_mul (line 7) | def complex_mul(x, z):
function complex_mulconj (line 13) | def complex_mulconj(x, z):
class CFNet (line 18) | class CFNet(nn.Module):
method __init__ (line 19) | def __init__(self, config, **kwargs):
method feature_extractor (line 33) | def feature_extractor(self, x):
method track (line 36) | def track(self, x):
method forward (line 41) | def forward(self, x):
method update (line 48) | def update(self, z, lr=0):
FILE: tracker/sot/lib/models/connect.py
class Corr_Up (line 6) | class Corr_Up(nn.Module):
method __init__ (line 10) | def __init__(self):
method _conv2d_group (line 13) | def _conv2d_group(self, x, kernel):
method forward (line 21) | def forward(self, z_f, x_f):
function xcorr_depthwise (line 28) | def xcorr_depthwise(x, kernel):
class DepthwiseXCorr (line 40) | class DepthwiseXCorr(nn.Module):
method __init__ (line 41) | def __init__(self, in_channels, hidden, out_channels, kernel_size=3, h...
method forward (line 60) | def forward(self, kernel, search):
class MultiDiCorr (line 68) | class MultiDiCorr(nn.Module):
method __init__ (line 72) | def __init__(self, inchannels=512, outchannels=256):
method forward (line 78) | def forward(self, search, kernal):
class OceanCorr (line 89) | class OceanCorr(nn.Module):
method __init__ (line 93) | def __init__(self, inchannels=512):
method forward (line 99) | def forward(self, cls_z, cls_x, reg_z, reg_x):
class AdjustLayer (line 106) | class AdjustLayer(nn.Module):
method __init__ (line 107) | def __init__(self, in_channels, out_channels):
method forward (line 114) | def forward(self, x, crop=False):
class matrix (line 129) | class matrix(nn.Module):
method __init__ (line 133) | def __init__(self, in_channels, out_channels):
method forward (line 172) | def forward(self, z, x):
class AdaptiveConv (line 185) | class AdaptiveConv(nn.Module):
method __init__ (line 189) | def __init__(self, in_channels, out_channels):
method forward (line 193) | def forward(self, x, offset):
class AlignHead (line 204) | class AlignHead(nn.Module):
method __init__ (line 207) | def __init__(self, in_channels, feat_channels):
method forward (line 214) | def forward(self, x, offset):
class GroupDW (line 221) | class GroupDW(nn.Module):
method __init__ (line 225) | def __init__(self, in_channels=256):
method forward (line 229) | def forward(self, z, x):
class SingleDW (line 248) | class SingleDW(nn.Module):
method __init__ (line 253) | def __init__(self, in_channels=256):
method forward (line 256) | def forward(self, z, x):
class box_tower (line 263) | class box_tower(nn.Module):
method __init__ (line 267) | def __init__(self, inchannels=512, outchannels=256, towernum=1):
method forward (line 309) | def forward(self, search, kernal, update=None):
FILE: tracker/sot/lib/models/modules.py
function conv3x3 (line 15) | def conv3x3(in_planes, out_planes, stride=1):
function conv3x3NP (line 20) | def conv3x3NP(in_planes, out_planes, stride=1):
function conv1x1 (line 26) | def conv1x1(in_planes, out_planes, stride=1):
function down (line 31) | def down(in_planes, out_planes):
function down_spatial (line 36) | def down_spatial(in_planes, out_planes):
class Bottleneck (line 46) | class Bottleneck(nn.Module):
method __init__ (line 49) | def __init__(self, inplanes, planes, stride=1, downsample=None, dilati...
method forward (line 72) | def forward(self, x):
class Bottleneck_BIG_CI (line 95) | class Bottleneck_BIG_CI(nn.Module):
method __init__ (line 101) | def __init__(self, inplanes, planes, last_relu, stride=1, downsample=N...
method forward (line 119) | def forward(self, x):
method center_crop (line 145) | def center_crop(self, x):
class ResNet_plus2 (line 156) | class ResNet_plus2(nn.Module):
method __init__ (line 157) | def __init__(self, block, layers, used_layers, online=False):
method _make_layer (line 198) | def _make_layer(self, block, planes, blocks, stride=1, dilation=1, upd...
method forward (line 232) | def forward(self, x, online=False):
class ResNet (line 247) | class ResNet(nn.Module):
method __init__ (line 253) | def __init__(self, block, layers, last_relus, s2p_flags, firstchannels...
method _make_layer (line 281) | def _make_layer(self, block, planes, blocks, last_relu, stride=1, stri...
method forward (line 311) | def forward(self, x):
method center_crop7 (line 323) | def center_crop7(self, x):
class FeatureBase (line 334) | class FeatureBase:
method __init__ (line 344) | def __init__(self, fparams = None, pool_stride = None, output_size = N...
method initialize (line 352) | def initialize(self):
method free_memory (line 355) | def free_memory(self):
method dim (line 358) | def dim(self):
method stride (line 361) | def stride(self):
method size (line 364) | def size(self, im_sz):
method extract (line 371) | def extract(self, im):
method get_feature (line 375) | def get_feature(self, im: torch.Tensor):
class MultiFeatureBase (line 403) | class MultiFeatureBase(FeatureBase):
method size (line 407) | def size(self, im_sz):
method get_feature (line 413) | def get_feature(self, im: torch.Tensor):
class Identity (line 450) | class Identity(nn.Module):
method __init__ (line 451) | def __init__(self, ):
method forward (line 454) | def forward(self, input):
class Conv2dStaticSamePadding (line 457) | class Conv2dStaticSamePadding(nn.Conv2d):
method __init__ (line 460) | def __init__(self, in_channels, out_channels, kernel_size, image_size=...
method forward (line 477) | def forward(self, x):
function get_same_padding_conv2d (line 483) | def get_same_padding_conv2d(image_size=None):
class Conv2dDynamicSamePadding (line 492) | class Conv2dDynamicSamePadding(nn.Conv2d):
method __init__ (line 495) | def __init__(self, in_channels, out_channels, kernel_size, stride=1, d...
method forward (line 499) | def forward(self, x):
function round_filters (line 510) | def round_filters(filters, global_params):
function round_repeats (line 524) | def round_repeats(repeats, global_params):
class SwishImplementation (line 531) | class SwishImplementation(torch.autograd.Function):
method forward (line 533) | def forward(ctx, i):
method backward (line 539) | def backward(ctx, grad_output):
class MemoryEfficientSwish (line 545) | class MemoryEfficientSwish(nn.Module):
method forward (line 546) | def forward(self, x):
function drop_connect (line 549) | def drop_connect(inputs, p, training):
class MBConvBlock (line 562) | class MBConvBlock(nn.Module):
method __init__ (line 572) | def __init__(self, block_args, global_params):
method forward (line 610) | def forward(self, inputs, drop_connect_rate=None):
method set_swish (line 639) | def set_swish(self, memory_efficient=True):
class BlockDecoder (line 644) | class BlockDecoder(object):
method _decode_block_string (line 648) | def _decode_block_string(block_string):
method _encode_block_string (line 675) | def _encode_block_string(block):
method decode (line 692) | def decode(string_list):
method encode (line 705) | def encode(blocks_args):
FILE: tracker/sot/lib/models/online/backbone/resnet.py
class ResNet (line 8) | class ResNet(nn.Module):
method __init__ (line 10) | def __init__(self, block, layers, output_layers, num_classes=1000, inp...
method _make_layer (line 35) | def _make_layer(self, block, planes, blocks, stride=1):
method _add_output_and_check (line 52) | def _add_output_and_check(self, name, x, outputs, output_layers):
method forward (line 57) | def forward(self, x, output_layers=None):
function resnet18 (line 106) | def resnet18(output_layers=None, pretrained=False):
function resnet50 (line 124) | def resnet50(output_layers=None, pretrained=False):
FILE: tracker/sot/lib/models/online/backbone/resnet18_vggm.py
class SpatialCrossMapLRN (line 8) | class SpatialCrossMapLRN(nn.Module):
method __init__ (line 9) | def __init__(self, local_size=1, alpha=1.0, beta=0.75, k=1, ACROSS_CHA...
method forward (line 24) | def forward(self, x):
class ResNetVGGm1 (line 37) | class ResNetVGGm1(nn.Module):
method __init__ (line 39) | def __init__(self, block, layers, output_layers, num_classes=1000):
method _make_layer (line 66) | def _make_layer(self, block, planes, blocks, stride=1):
method _add_output_and_check (line 84) | def _add_output_and_check(self, name, x, outputs, output_layers):
method forward (line 90) | def forward(self, x, output_layers=None):
function resnet18_vggmconv1 (line 143) | def resnet18_vggmconv1(output_layers=None, path=None):
FILE: tracker/sot/lib/models/online/bbreg/iou_net.py
function conv (line 8) | def conv(in_planes, out_planes, kernel_size=3, stride=1, padding=1, dila...
function valid_roi (line 16) | def valid_roi(roi: torch.Tensor, image_size: torch.Tensor):
class IoUNet (line 22) | class IoUNet(nn.Module):
method __init__ (line 24) | def __init__(self, input_dim=(128,256), pred_input_dim=(256,256), pred...
method forward (line 60) | def forward(self, feat1, feat2, bb1, proposals2):
method predict_iou (line 82) | def predict_iou(self, filter, feat2, proposals):
method get_filter (line 118) | def get_filter(self, feat1, bb1):
method get_iou_feat (line 147) | def get_iou_feat(self, feat2):
FILE: tracker/sot/lib/models/online/classifier/features.py
function residual_basic_block (line 9) | def residual_basic_block(feature_dim=256, num_blocks=1, l2norm=True, fin...
function residual_basic_block_pool (line 27) | def residual_basic_block_pool(feature_dim=256, num_blocks=1, l2norm=True...
function residual_bottleneck (line 46) | def residual_bottleneck(feature_dim=256, num_blocks=1, l2norm=True, fina...
FILE: tracker/sot/lib/models/online/classifier/initializer.py
class FilterPool (line 13) | class FilterPool(nn.Module):
method __init__ (line 20) | def __init__(self, filter_size=1, feature_stride=16, pool_square=False):
method forward (line 25) | def forward(self, feat, bb):
class FilterInitializer (line 53) | class FilterInitializer(nn.Module):
method __init__ (line 64) | def __init__(self, filter_size=1, feature_dim=256, feature_stride=16, ...
method forward (line 96) | def forward(self, feat, bb):
class FilterInitializerLinear (line 122) | class FilterInitializerLinear(nn.Module):
method __init__ (line 132) | def __init__(self, filter_size=1, feature_dim=256, feature_stride=16, ...
method forward (line 152) | def forward(self, feat, bb):
class FilterInitializerZero (line 178) | class FilterInitializerZero(nn.Module):
method __init__ (line 184) | def __init__(self, filter_size=1, feature_dim=256):
method forward (line 189) | def forward(self, feat, bb):
class FilterInitializerSiamese (line 203) | class FilterInitializerSiamese(nn.Module):
method __init__ (line 211) | def __init__(self, filter_size=1, feature_stride=16, pool_square=False...
method forward (line 229) | def forward(self, feat, bb):
FILE: tracker/sot/lib/models/online/classifier/linear_filter.py
class LinearFilter (line 8) | class LinearFilter(nn.Module):
method __init__ (line 16) | def __init__(self, filter_size, filter_initializer, filter_optimizer=N...
method forward (line 37) | def forward(self, train_feat, test_feat, train_bb, *args, **kwargs):
method extract_classification_feat (line 70) | def extract_classification_feat(self, feat, num_sequences=None):
method classify (line 80) | def classify(self, weights, feat):
method get_filter (line 87) | def get_filter(self, feat, bb, *args, **kwargs):
FILE: tracker/sot/lib/models/online/classifier/optimizer.py
class ONLINESteepestDescentGN (line 11) | class ONLINESteepestDescentGN(nn.Module):
method __init__ (line 30) | def __init__(self, num_iter=1, feat_stride=16, init_step_length=1.0,
method forward (line 83) | def forward(self, weights, feat, bb, sample_weight=None, num_iter=None...
FILE: tracker/sot/lib/models/online/layers/activation.py
class MLU (line 6) | class MLU(nn.Module):
method __init__ (line 9) | def __init__(self, min_val, inplace=False):
method forward (line 14) | def forward(self, input):
class LeakyReluPar (line 18) | class LeakyReluPar(nn.Module):
method forward (line 22) | def forward(self, x, a):
class LeakyReluParDeriv (line 25) | class LeakyReluParDeriv(nn.Module):
method forward (line 29) | def forward(self, x, a):
class BentIdentPar (line 33) | class BentIdentPar(nn.Module):
method __init__ (line 36) | def __init__(self, b=1.0):
method forward (line 40) | def forward(self, x, a):
class BentIdentParDeriv (line 44) | class BentIdentParDeriv(nn.Module):
method __init__ (line 47) | def __init__(self, b=1.0):
method forward (line 51) | def forward(self, x, a):
FILE: tracker/sot/lib/models/online/layers/blocks.py
function conv_block (line 4) | def conv_block(in_planes, out_planes, kernel_size=3, stride=1, padding=1...
class LinearBlock (line 15) | class LinearBlock(nn.Module):
method __init__ (line 16) | def __init__(self, in_planes, out_planes, input_sz, bias=True, batch_n...
method forward (line 22) | def forward(self, x):
FILE: tracker/sot/lib/models/online/layers/distance.py
class DistanceMap (line 6) | class DistanceMap(nn.Module):
method __init__ (line 12) | def __init__(self, num_bins, bin_displacement=1.0):
method forward (line 17) | def forward(self, center, output_sz):
FILE: tracker/sot/lib/models/online/layers/filter.py
function apply_filter (line 5) | def apply_filter(feat, filter):
function apply_feat_transpose (line 33) | def apply_feat_transpose(feat, input, filter_ksz, training=True):
function _apply_feat_transpose_v1 (line 49) | def _apply_feat_transpose_v1(feat, input, filter_ksz):
function _apply_feat_transpose_v2 (line 68) | def _apply_feat_transpose_v2(feat, input, filter_ksz):
function _apply_feat_transpose_v3 (line 97) | def _apply_feat_transpose_v3(feat, input, filter_ksz):
function _apply_feat_transpose_v4 (line 124) | def _apply_feat_transpose_v4(feat, input, filter_ksz):
function filter_gradient (line 142) | def filter_gradient(feat, filter, label=None, training=True):
FILE: tracker/sot/lib/models/online/layers/normalization.py
class InstanceL2Norm (line 6) | class InstanceL2Norm(nn.Module):
method __init__ (line 9) | def __init__(self, size_average=True, eps=1e-5, scale=1.0):
method forward (line 15) | def forward(self, input):
FILE: tracker/sot/lib/models/online/layers/transform.py
function interpolate (line 7) | def interpolate(x, sz):
class InterpCat (line 13) | class InterpCat(nn.Module):
method forward (line 16) | def forward(self, input):
FILE: tracker/sot/lib/models/siamfc.py
class SiamFC (line 8) | class SiamFC(nn.Module):
method __init__ (line 9) | def __init__(self, config, **kwargs):
method feature_extractor (line 23) | def feature_extractor(self, x):
method forward (line 26) | def forward(self, x):
method update (line 32) | def update(self, z, lr=0):
FILE: tracker/sot/lib/online/augmentation.py
class Transform (line 9) | class Transform:
method __init__ (line 12) | def __init__(self, output_sz = None, shift = None):
method __call__ (line 16) | def __call__(self, image):
method crop_to_output (line 19) | def crop_to_output(self, image):
class Identity (line 38) | class Identity(Transform):
method __call__ (line 40) | def __call__(self, image):
class FlipHorizontal (line 43) | class FlipHorizontal(Transform):
method __call__ (line 45) | def __call__(self, image):
class FlipVertical (line 51) | class FlipVertical(Transform):
method __call__ (line 53) | def __call__(self, image: torch.Tensor):
class Translation (line 59) | class Translation(Transform):
method __init__ (line 61) | def __init__(self, translation, output_sz = None, shift = None):
method __call__ (line 65) | def __call__(self, image):
class Scale (line 71) | class Scale(Transform):
method __init__ (line 73) | def __init__(self, scale_factor, output_sz = None, shift = None):
method __call__ (line 77) | def __call__(self, image):
class Affine (line 97) | class Affine(Transform):
method __init__ (line 99) | def __init__(self, transform_matrix, output_sz = None, shift = None):
method __call__ (line 103) | def __call__(self, image):
class Rotate (line 110) | class Rotate(Transform):
method __init__ (line 112) | def __init__(self, angle, output_sz = None, shift = None):
method __call__ (line 116) | def __call__(self, image):
class Blur (line 127) | class Blur(Transform):
method __init__ (line 129) | def __init__(self, sigma, output_sz = None, shift = None):
method __call__ (line 140) | def __call__(self, image):
FILE: tracker/sot/lib/online/base_actor.py
class BaseActor (line 5) | class BaseActor:
method __init__ (line 8) | def __init__(self, net, objective):
method __call__ (line 17) | def __call__(self, data: TensorDict):
method to (line 29) | def to(self, device):
method train (line 36) | def train(self, mode=True):
method eval (line 65) | def eval(self):
method check_trainable (line 69) | def check_trainable(self, model):
FILE: tracker/sot/lib/online/base_trainer.py
class BaseTrainer (line 8) | class BaseTrainer:
method __init__ (line 12) | def __init__(self, actor, loaders, optimizer, settings, lr_scheduler=N...
method train (line 54) | def train(self, max_epochs, load_latest=False, fail_safe=True):
method train_epoch (line 97) | def train_epoch(self):
method save_model (line 100) | def save_model(self, model, epoch, optimizer, model_name, cfg, isbest=...
method save_checkpoint (line 117) | def save_checkpoint(self, states, is_best, output_dir, filename='check...
FILE: tracker/sot/lib/online/complex.py
function is_complex (line 5) | def is_complex(a: torch.Tensor) -> bool:
function is_real (line 9) | def is_real(a: torch.Tensor) -> bool:
function mult (line 14) | def mult(a: torch.Tensor, b: torch.Tensor):
function mult_conj (line 36) | def mult_conj(a: torch.Tensor, b: torch.Tensor):
function mult_real_cplx (line 58) | def mult_real_cplx(a: torch.Tensor, b: torch.Tensor):
function div (line 68) | def div(a: torch.Tensor, b: torch.Tensor):
function div_cplx_real (line 81) | def div_cplx_real(a: torch.Tensor, b: torch.Tensor):
function abs_sqr (line 91) | def abs_sqr(a: torch.Tensor):
function abs (line 101) | def abs(a: torch.Tensor):
function conj (line 111) | def conj(a: torch.Tensor):
function real (line 122) | def real(a: torch.Tensor):
function imag (line 132) | def imag(a: torch.Tensor):
function complex (line 142) | def complex(a: torch.Tensor, b: torch.Tensor = None):
function mtimes (line 154) | def mtimes(a: torch.Tensor, b: torch.Tensor, conj_a=False, conj_b=False):
function mtimes_real_complex (line 182) | def mtimes_real_complex(a: torch.Tensor, b: torch.Tensor, conj_b=False):
function mtimes_complex_real (line 193) | def mtimes_complex_real(a: torch.Tensor, b: torch.Tensor, conj_a=False):
function exp_imag (line 204) | def exp_imag(a: torch.Tensor):
FILE: tracker/sot/lib/online/dcf.py
function hann1d (line 8) | def hann1d(sz: int, centered = True) -> torch.Tensor:
function hann2d (line 16) | def hann2d(sz: torch.Tensor, centered = True) -> torch.Tensor:
function hann2d_clipped (line 26) | def hann2d_clipped(sz: torch.Tensor, effective_sz: torch.Tensor, centere...
function gauss_fourier (line 45) | def gauss_fourier(sz: int, sigma: float, half: bool = False) -> torch.Te...
function gauss_spatial (line 53) | def gauss_spatial(sz, sigma, center=0, end_pad=0):
function label_function (line 58) | def label_function(sz: torch.Tensor, sigma: torch.Tensor):
function label_function_spatial (line 61) | def label_function_spatial(sz: torch.Tensor, sigma: torch.Tensor, center...
function cubic_spline_fourier (line 72) | def cubic_spline_fourier(f, a):
function get_interp_fourier (line 84) | def get_interp_fourier(sz: torch.Tensor, method='ideal', bicubic_param=0...
function interpolate_dft (line 107) | def interpolate_dft(a: torch.Tensor, interp_fs) -> torch.Tensor:
function get_reg_filter (line 116) | def get_reg_filter(sz: torch.Tensor, target_sz: torch.Tensor, params):
function max2d (line 166) | def max2d(a: torch.Tensor) -> (torch.Tensor, torch.Tensor):
FILE: tracker/sot/lib/online/extractor.py
class ExtractorBase (line 5) | class ExtractorBase:
method __init__ (line 10) | def __init__(self, features):
method initialize (line 13) | def initialize(self, siam_net):
method free_memory (line 17) | def free_memory(self):
class SingleResolutionExtractor (line 22) | class SingleResolutionExtractor(ExtractorBase):
method __init__ (line 27) | def __init__(self, features):
method stride (line 34) | def stride(self):
method size (line 37) | def size(self, input_sz):
method extract (line 40) | def extract(self, im, pos, scales, image_sz):
class MultiResolutionExtractor (line 53) | class MultiResolutionExtractor(ExtractorBase):
method __init__ (line 58) | def __init__(self, features):
method stride (line 62) | def stride(self):
method size (line 65) | def size(self, input_sz):
method dim (line 68) | def dim(self):
method get_fparams (line 71) | def get_fparams(self, name: str = None):
method get_attribute (line 76) | def get_attribute(self, name: str, ignore_missing: bool = False):
method get_unique_attribute (line 82) | def get_unique_attribute(self, name: str):
method _return_feature (line 93) | def _return_feature(self, f):
method set_is_color (line 96) | def set_is_color(self, is_color: bool):
method extract (line 99) | def extract(self, im, pos, scales, image_sz):
method extract_transformed (line 118) | def extract_transformed(self, im, pos, scale, image_sz, transforms):
FILE: tracker/sot/lib/online/fourier.py
function rfftshift2 (line 8) | def rfftshift2(a: torch.Tensor):
function irfftshift2 (line 14) | def irfftshift2(a: torch.Tensor):
function cfft2 (line 20) | def cfft2(a):
function cifft2 (line 28) | def cifft2(a, signal_sizes=None):
function sample_fs (line 35) | def sample_fs(a: torch.Tensor, grid_sz: torch.Tensor = None, rescale = T...
function get_frequency_coord (line 64) | def get_frequency_coord(sz, add_complex_dim = False, device='cpu'):
function shift_fs (line 78) | def shift_fs(a: torch.Tensor, shift: torch.Tensor):
function sum_fs (line 95) | def sum_fs(a: TensorList) -> torch.Tensor:
function sum_fs12 (line 117) | def sum_fs12(a: TensorList) -> torch.Tensor:
function inner_prod_fs (line 140) | def inner_prod_fs(a: torch.Tensor, b: torch.Tensor):
FILE: tracker/sot/lib/online/loading.py
function check_keys (line 8) | def check_keys(model, pretrained_state_dict):
function load_pretrain (line 26) | def load_pretrain(model, pretrained_dict):
function load_network (line 35) | def load_network(ckpt_path=None, constructor_fun_name='online_resnet18',...
function load_weights (line 51) | def load_weights(net, path, strict=True):
function torch_load_legacy (line 58) | def torch_load_legacy(path):
function _setup_legacy_env (line 73) | def _setup_legacy_env():
function _cleanup_legacy_env (line 82) | def _cleanup_legacy_env():
FILE: tracker/sot/lib/online/ltr_trainer.py
class LTRTrainer (line 10) | class LTRTrainer(BaseTrainer):
method __init__ (line 11) | def __init__(self, actor, loaders, optimizer, settings, lr_scheduler=N...
method _set_default_settings (line 32) | def _set_default_settings(self):
method cycle_dataset (line 42) | def cycle_dataset(self, loader):
method train_epoch (line 72) | def train_epoch(self):
method _init_timing (line 81) | def _init_timing(self):
method _update_stats (line 86) | def _update_stats(self, new_stats: OrderedDict, batch_size, loader):
method _print_stats (line 96) | def _print_stats(self, i, loader, batch_size):
method _stats_new_epoch (line 110) | def _stats_new_epoch(self):
method _write_tensorboard (line 128) | def _write_tensorboard(self):
FILE: tracker/sot/lib/online/model_constructor.py
function model_constructor (line 5) | def model_constructor(f):
class NetConstructor (line 24) | class NetConstructor:
method __init__ (line 28) | def __init__(self, fun_name, fun_module):
method get (line 41) | def get(self):
FILE: tracker/sot/lib/online/operation.py
function conv2d (line 7) | def conv2d(input: torch.Tensor, weight: torch.Tensor, bias: torch.Tensor...
function conv1x1 (line 36) | def conv1x1(input: torch.Tensor, weight: torch.Tensor):
FILE: tracker/sot/lib/online/optim.py
class FactorizedConvProblem (line 7) | class FactorizedConvProblem(optimization.L2Problem):
method __init__ (line 8) | def __init__(self, training_samples: TensorList, y: TensorList, filter...
method __call__ (line 21) | def __call__(self, x: TensorList):
method ip_input (line 50) | def ip_input(self, a: TensorList, b: TensorList):
method M1 (line 68) | def M1(self, x: TensorList):
class ConvProblem (line 72) | class ConvProblem(optimization.L2Problem):
method __init__ (line 73) | def __init__(self, training_samples: TensorList, y: TensorList, filter...
method __call__ (line 80) | def __call__(self, x: TensorList):
method ip_input (line 97) | def ip_input(self, a: TensorList, b: TensorList):
FILE: tracker/sot/lib/online/optimization.py
class L2Problem (line 7) | class L2Problem:
method __call__ (line 10) | def __call__(self, x: TensorList) -> TensorList:
method ip_input (line 14) | def ip_input(self, a, b):
method ip_output (line 18) | def ip_output(self, a, b):
method M1 (line 22) | def M1(self, x):
method M2 (line 26) | def M2(self, x):
class MinimizationProblem (line 31) | class MinimizationProblem:
method __call__ (line 33) | def __call__(self, x: TensorList) -> TensorList:
method ip_input (line 37) | def ip_input(self, a, b):
method M1 (line 41) | def M1(self, x):
method M2 (line 44) | def M2(self, x):
class ConjugateGradientBase (line 49) | class ConjugateGradientBase:
method __init__ (line 52) | def __init__(self, fletcher_reeves = True, standard_alpha = True, dire...
method reset_state (line 66) | def reset_state(self):
method run_CG (line 72) | def run_CG(self, num_iter, x=None, eps=0.0):
method A (line 166) | def A(self, x):
method ip (line 170) | def ip(self, a, b):
method residual_norm (line 174) | def residual_norm(self, r):
method check_zero (line 180) | def check_zero(self, s, eps = 0.0):
method M1 (line 186) | def M1(self, x):
method M2 (line 190) | def M2(self, x):
method evaluate_CG_iteration (line 194) | def evaluate_CG_iteration(self, x):
class ConjugateGradient (line 199) | class ConjugateGradient(ConjugateGradientBase):
method __init__ (line 202) | def __init__(self, problem: L2Problem, variable: TensorList, cg_eps = ...
method clear_temp (line 220) | def clear_temp(self):
method run (line 226) | def run(self, num_cg_iter):
method A (line 274) | def A(self, x):
method ip (line 278) | def ip(self, a, b):
method M1 (line 281) | def M1(self, x):
method M2 (line 284) | def M2(self, x):
class GaussNewtonCG (line 289) | class GaussNewtonCG(ConjugateGradientBase):
method __init__ (line 292) | def __init__(self, problem: L2Problem, variable: TensorList, cg_eps = ...
method clear_temp (line 313) | def clear_temp(self):
method run_GN (line 319) | def run_GN(self, *args, **kwargs):
method run (line 323) | def run(self, num_cg_iter, num_gn_iter=None):
method run_GN_iter (line 366) | def run_GN_iter(self, num_cg_iter):
method A (line 399) | def A(self, x):
method ip (line 403) | def ip(self, a, b):
method M1 (line 406) | def M1(self, x):
method M2 (line 409) | def M2(self, x):
method evaluate_CG_iteration (line 412) | def evaluate_CG_iteration(self, delta_x):
class GradientDescentL2 (line 427) | class GradientDescentL2:
method __init__ (line 430) | def __init__(self, problem: L2Problem, variable: TensorList, step_leng...
method clear_temp (line 449) | def clear_temp(self):
method run (line 454) | def run(self, num_iter, dummy = None):
class NewtonCG (line 507) | class NewtonCG(ConjugateGradientBase):
method __init__ (line 510) | def __init__(self, problem: MinimizationProblem, variable: TensorList,...
method clear_temp (line 532) | def clear_temp(self):
method run (line 537) | def run(self, num_cg_iter, num_newton_iter=None):
method run_newton_iter (line 574) | def run_newton_iter(self, num_cg_iter):
method A (line 600) | def A(self, x):
method ip (line 603) | def ip(self, a, b):
method M1 (line 607) | def M1(self, x):
method M2 (line 610) | def M2(self, x):
method evaluate_CG_iteration (line 613) | def evaluate_CG_iteration(self, delta_x):
class GradientDescent (line 627) | class GradientDescent:
method __init__ (line 630) | def __init__(self, problem: MinimizationProblem, variable: TensorList,...
method clear_temp (line 650) | def clear_temp(self):
method run (line 654) | def run(self, num_iter, dummy = None):
FILE: tracker/sot/lib/online/preprocessing.py
function numpy_to_torch (line 6) | def numpy_to_torch(a: np.ndarray):
function torch_to_numpy (line 10) | def torch_to_numpy(a: torch.Tensor):
function sample_patch_transformed (line 14) | def sample_patch_transformed(im, pos, scale, image_sz, transforms):
function sample_patch_multiscale (line 33) | def sample_patch_multiscale(im, pos, scales, image_sz, mode: str='replic...
function sample_patch (line 52) | def sample_patch(im: torch.Tensor, pos: torch.Tensor, sample_sz: torch.T...
function sample_patch_online (line 100) | def sample_patch_online(im: torch.Tensor, pos: torch.Tensor, sample_sz: ...
FILE: tracker/sot/lib/online/tensordict.py
class TensorDict (line 5) | class TensorDict(OrderedDict):
method concat (line 8) | def concat(self, other):
method copy (line 12) | def copy(self):
method __getattr__ (line 15) | def __getattr__(self, name):
method attribute (line 23) | def attribute(self, attr: str, *args):
method apply (line 26) | def apply(self, fn, *args, **kwargs):
method _iterable (line 30) | def _iterable(a):
FILE: tracker/sot/lib/online/tensorlist.py
class TensorList (line 5) | class TensorList(list):
method __init__ (line 8) | def __init__(self, list_of_tensors = list()):
method __getitem__ (line 11) | def __getitem__(self, item):
method __add__ (line 19) | def __add__(self, other):
method __radd__ (line 24) | def __radd__(self, other):
method __iadd__ (line 29) | def __iadd__(self, other):
method __sub__ (line 38) | def __sub__(self, other):
method __rsub__ (line 43) | def __rsub__(self, other):
method __isub__ (line 48) | def __isub__(self, other):
method __mul__ (line 57) | def __mul__(self, other):
method __rmul__ (line 62) | def __rmul__(self, other):
method __imul__ (line 67) | def __imul__(self, other):
method __truediv__ (line 76) | def __truediv__(self, other):
method __rtruediv__ (line 84) | def __rtruediv__(self, other):
method __itruediv__ (line 89) | def __itruediv__(self, other):
method __matmul__ (line 98) | def __matmul__(self, other):
method __rmatmul__ (line 103) | def __rmatmul__(self, other):
method __imatmul__ (line 108) | def __imatmul__(self, other):
method __mod__ (line 117) | def __mod__(self, other):
method __rmod__ (line 122) | def __rmod__(self, other):
method __pos__ (line 127) | def __pos__(self):
method __neg__ (line 130) | def __neg__(self):
method __le__ (line 133) | def __le__(self, other):
method __ge__ (line 138) | def __ge__(self, other):
method concat (line 143) | def concat(self, other):
method copy (line 146) | def copy(self):
method unroll (line 149) | def unroll(self):
method attribute (line 161) | def attribute(self, attr: str, *args):
method apply (line 164) | def apply(self, fn):
method __getattr__ (line 170) | def __getattr__(self, name):
method _iterable (line 180) | def _iterable(a):
function tensor_operation (line 185) | def tensor_operation(op):
FILE: tracker/sot/lib/online/tracking.py
class ONLINEActor (line 4) | class ONLINEActor(BaseActor):
method __init__ (line 6) | def __init__(self, net, objective, loss_weight=None):
method __call__ (line 12) | def __call__(self, data):
FILE: tracker/sot/lib/tracker/ocean.py
class Ocean (line 11) | class Ocean(object):
method __init__ (line 12) | def __init__(self, info):
method init (line 20) | def init(self, im, target_pos, target_sz, model, hp=None):
method update (line 101) | def update(self, net, x_crops, target_pos, target_sz, window, scale_z,...
method track (line 174) | def track(self, state, im, online_score=None, gt=None):
method grids (line 210) | def grids(self, p):
method IOUgroup (line 228) | def IOUgroup(self, pred_x1, pred_y1, pred_x2, pred_y2, gt_xyxy):
method change (line 250) | def change(self, r):
method sz (line 253) | def sz(self, w, h):
method sz_wh (line 258) | def sz_wh(self, wh):
class OceanConfig (line 264) | class OceanConfig(object):
method update (line 277) | def update(self, newparam=None):
method renew (line 283) | def renew(self):
FILE: tracker/sot/lib/tracker/oceanplus.py
class OceanPlus (line 12) | class OceanPlus(object):
method __init__ (line 13) | def __init__(self, info):
method init (line 23) | def init(self, im, target_pos, target_sz, model, hp=None, online=False...
method update (line 119) | def update(self, net, x_crops, target_pos, target_sz, window, scale_z,...
method track (line 241) | def track(self, state, im, online_score=None, gt=None, name=None):
method mask2box (line 291) | def mask2box(self, mask, method='cv2poly'):
method draw_mask (line 322) | def draw_mask(self, mask, im, polygon=None, box=None, mask_ratio=0.2, ...
method grids (line 386) | def grids(self, p):
method IOUgroup (line 404) | def IOUgroup(self, pred_x1, pred_y1, pred_x2, pred_y2, gt_xyxy):
method change (line 426) | def change(self, r):
method sz (line 429) | def sz(self, w, h):
method sz_wh (line 434) | def sz_wh(self, wh):
class AdaConfig (line 440) | class AdaConfig(object):
method update (line 460) | def update(self, newparam=None):
method renew (line 466) | def renew(self):
FILE: tracker/sot/lib/tracker/online.py
class ONLINE (line 33) | class ONLINE(object):
method __init__ (line 37) | def __init__(self, info):
method init (line 45) | def init(self, bgr_image, image, siam_net, target_pos, target_sz, load...
method track (line 131) | def track(self, bgr_im, image, siam_tracker, siam_state) -> dict:
method get_sample_location (line 201) | def get_sample_location(self, sample_coord):
method get_centered_sample_pos (line 208) | def get_centered_sample_pos(self):
method classify_target (line 213) | def classify_target(self, sample_x: TensorList):
method localize_target (line 219) | def localize_target(self, scores, sample_scales):
method localize_advanced (line 241) | def localize_advanced(self, scores, sample_scales):
method extract_backbone_features (line 301) | def extract_backbone_features(self, im: torch.Tensor, pos: torch.Tenso...
method get_classification_features (line 307) | def get_classification_features(self, backbone_feat):
method get_iou_backbone_features (line 311) | def get_iou_backbone_features(self, backbone_feat):
method get_iou_features (line 314) | def get_iou_features(self, backbone_feat):
method get_iou_modulation (line 318) | def get_iou_modulation(self, iou_backbone_feat, target_boxes):
method generate_init_samples (line 323) | def generate_init_samples(self, im: torch.Tensor) -> TensorList:
method init_target_boxes (line 387) | def init_target_boxes(self):
method init_memory (line 398) | def init_memory(self, train_x: TensorList):
method update_memory (line 418) | def update_memory(self, sample_x: TensorList, target_box, learning_rat...
method update_sample_weights (line 433) | def update_sample_weights(self, sample_weights, previous_replace_ind, ...
method update_state (line 474) | def update_state(self, new_pos, new_scale = None):
method get_iounet_box (line 491) | def get_iounet_box(self, pos, sz, sample_pos, sample_scale):
method init_iou_net (line 500) | def init_iou_net(self, backbone_feat):
method init_classifier (line 528) | def init_classifier(self, init_backbone_feat):
method update_classifier (line 579) | def update_classifier(self, train_x, target_box, learning_rate=None, s...
method refine_target_box (line 622) | def refine_target_box(self, backbone_feat, sample_pos, sample_scale, s...
method optimize_boxes (line 682) | def optimize_boxes(self, iou_features, init_boxes):
method params_convert (line 712) | def params_convert(self):
class ONLINEConfig (line 725) | class ONLINEConfig(object):
method update (line 727) | def update(self, newparam=None):
FILE: tracker/sot/lib/tracker/siamfc.py
class SiamFC (line 17) | class SiamFC(object):
method __init__ (line 18) | def __init__(self, info):
method init (line 22) | def init(self, im, target_pos, target_sz, model, hp=None):
method update (line 88) | def update(self, net, s_x, x_crops, target_pos, window, p):
method track (line 118) | def track(self, state, im):
class FCConfig (line 150) | class FCConfig(object):
method update (line 167) | def update(self, newparam=None):
method renew (line 173) | def renew(self):
FILE: tracker/sot/lib/utils/cutout.py
class Cutout (line 5) | class Cutout(object):
method __init__ (line 12) | def __init__(self, n_holes, length):
method __call__ (line 16) | def __call__(self, img):
FILE: tracker/sot/lib/utils/extract_tpejson_fc.py
function collect_results (line 18) | def collect_results(args):
FILE: tracker/sot/lib/utils/extract_tpejson_ocean.py
function collect_results (line 18) | def collect_results(args):
FILE: tracker/sot/lib/utils/extract_tpelog.py
function collect_results (line 15) | def collect_results(args):
FILE: tracker/sot/lib/utils/extract_tpelog_fc.py
function collect_results (line 16) | def collect_results(args):
FILE: tracker/sot/lib/utils/utils.py
function _rebuild_tensor_v2 (line 24) | def _rebuild_tensor_v2(storage, storage_offset, size, stride, requires_g...
function visdom_draw_tracking (line 34) | def visdom_draw_tracking(visdom, image, box, segmentation=None):
function _visdom_ui_handler (line 44) | def _visdom_ui_handler(self, data):
function _init_visdom (line 53) | def _init_visdom(visdom_info, debug=False):
function load_yaml (line 74) | def load_yaml(path, subset=True):
function to_torch (line 86) | def to_torch(ndarray):
function im_to_torch (line 90) | def im_to_torch(img):
function get_subwindow_tracking_mask (line 97) | def get_subwindow_tracking_mask(im, pos, model_sz, original_sz, out_mode...
function get_subwindow_tracking (line 158) | def get_subwindow_tracking(im, pos, model_sz, original_sz, avg_chans, ou...
function make_scale_pyramid (line 219) | def make_scale_pyramid(im, pos, in_side_scaled, out_side, avg_chans):
function python2round (line 242) | def python2round(f):
function generate_anchor (line 251) | def generate_anchor(total_stride, scales, ratios, score_size):
class ImageNormalizer (line 290) | class ImageNormalizer(object):
method __init__ (line 292) | def __init__(self, mean, std, in_type='opencv', out_type='pil'):
method __call__ (line 314) | def __call__(self, img_tensor):
function crop_with_boxes (line 326) | def crop_with_boxes(img_tensor, x_crop_boxes, out_height, out_width, cro...
function load_dataset (line 394) | def load_dataset(dataset, base_path):
function load_video_info_im_gt (line 601) | def load_video_info_im_gt(dataset, video_name):
function check_keys (line 631) | def check_keys(model, pretrained_state_dict, print_unuse=True):
function remove_prefix (line 650) | def remove_prefix(state_dict, prefix):
function load_pretrain (line 658) | def load_pretrain(model, pretrained_path, print_unuse=True):
function trans_model (line 676) | def trans_model(model_path, save_path):
function corner2center (line 699) | def corner2center(corner):
function center2corner (line 714) | def center2corner(center):
function IoU (line 729) | def IoU(rect1, rect2):
function aug_apply (line 752) | def aug_apply(bbox, param, shape, inv=False, rd=False):
function cxy_wh_2_rect (line 818) | def cxy_wh_2_rect(pos, sz):
function get_axis_aligned_bbox (line 822) | def get_axis_aligned_bbox(region):
function poly_iou (line 847) | def poly_iou(polys1, polys2, bound=None):
function _to_polygon (line 882) | def _to_polygon(polys):
function restore_from (line 904) | def restore_from(model, optimizer, ckpt_path):
function print_speed (line 918) | def print_speed(i, i_time, n, logger):
function create_logger (line 929) | def create_logger(cfg, modelFlag='OCEAN', phase='train'):
function save_checkpoint (line 961) | def save_checkpoint(states, is_best, output_dir, filename='checkpoint.pt...
function save_model (line 971) | def save_model(model, epoch, optimizer, model_name, cfg, isbest=False):
function extract_eaos (line 989) | def extract_eaos(lines):
function extract_logs (line 1009) | def extract_logs(logfile, prefix):
class LRScheduler (line 1026) | class LRScheduler(_LRScheduler):
method __init__ (line 1027) | def __init__(self, optimizer, last_epoch=-1):
method get_cur_lr (line 1032) | def get_cur_lr(self):
method get_lr (line 1035) | def get_lr(self):
method __repr__ (line 1040) | def __repr__(self):
class LogScheduler (line 1045) | class LogScheduler(LRScheduler):
method __init__ (line 1046) | def __init__(self, optimizer, start_lr=0.03, end_lr=5e-4,
class StepScheduler (line 1058) | class StepScheduler(LRScheduler):
method __init__ (line 1059) | def __init__(self, optimizer, start_lr=0.01, end_lr=None,
class MultiStepScheduler (line 1074) | class MultiStepScheduler(LRScheduler):
method __init__ (line 1075) | def __init__(self, optimizer, start_lr=0.01, end_lr=None,
method _build_lr (line 1090) | def _build_lr(self, start_lr, steps, mult, epochs):
class LinearStepScheduler (line 1100) | class LinearStepScheduler(LRScheduler):
method __init__ (line 1101) | def __init__(self, optimizer, start_lr=0.01, end_lr=0.005,
class CosStepScheduler (line 1109) | class CosStepScheduler(LRScheduler):
method __init__ (line 1110) | def __init__(self, optimizer, start_lr=0.01, end_lr=0.005,
method _build_lr (line 1118) | def _build_lr(self, start_lr, end_lr, epochs):
class WarmUPScheduler (line 1125) | class WarmUPScheduler(LRScheduler):
method __init__ (line 1126) | def __init__(self, optimizer, warmup, normal, epochs=50, last_epoch=-1):
function _build_lr_scheduler (line 1143) | def _build_lr_scheduler(optimizer, config, epochs=50, last_epoch=-1):
function _build_warm_up_scheduler (line 1148) | def _build_warm_up_scheduler(optimizer, cfg, epochs=50, last_epoch=-1, m...
function build_lr_scheduler (line 1158) | def build_lr_scheduler(optimizer, cfg, epochs=50, last_epoch=-1, modelFL...
class TrackerParams (line 1172) | class TrackerParams:
method free_memory (line 1174) | def free_memory(self):
class FeatureParams (line 1180) | class FeatureParams:
method __init__ (line 1182) | def __init__(self, *args, **kwargs):
function Choice (line 1193) | def Choice(*args):
function cxy_wh_2_rect1 (line 1202) | def cxy_wh_2_rect1(pos, sz):
function rect1_2_cxy_wh (line 1206) | def rect1_2_cxy_wh(rect):
function cxy_wh_2_bbox (line 1210) | def cxy_wh_2_bbox(cxy, wh):
function gaussian_shaped_labels (line 1214) | def gaussian_shaped_labels(sigma, sz):
function crop_chw (line 1223) | def crop_chw(image, bbox, out_sz, padding=(0, 0, 0)):
FILE: utils/__init__.py
function to_numpy (line 21) | def to_numpy(tensor):
function to_torch (line 29) | def to_torch(ndarray):
function im_to_numpy (line 37) | def im_to_numpy(img):
function im_to_torch (line 42) | def im_to_torch(img):
FILE: utils/box.py
function xyxy2xywh (line 13) | def xyxy2xywh(x):
function xywh2xyxy (line 23) | def xywh2xyxy(x):
function tlwh2xyxy (line 33) | def tlwh2xyxy(x):
function tlwh_to_xywh (line 41) | def tlwh_to_xywh(tlwh):
function tlwh_to_xyah (line 47) | def tlwh_to_xyah(tlwh):
function tlbr_to_tlwh (line 57) | def tlbr_to_tlwh(tlbr):
function tlwh_to_tlbr (line 63) | def tlwh_to_tlbr(tlwh):
function scale_box (line 69) | def scale_box(scale, coords):
function scale_box_letterbox_size (line 76) | def scale_box_letterbox_size(img_size, coords, img0_shape):
function scale_box_input_size (line 88) | def scale_box_input_size(img_size, coords, img0_shape):
function clip_boxes (line 101) | def clip_boxes(boxes, im_shape):
function clip_box (line 120) | def clip_box(bbox, im_shape):
function int_box (line 131) | def int_box(box):
function remove_duplicated_box (line 137) | def remove_duplicated_box(boxes, iou_th=0.5):
function skltn2box (line 153) | def skltn2box(skltn):
FILE: utils/io.py
function mkdir_if_missing (line 8) | def mkdir_if_missing(d):
function write_mots_results (line 12) | def write_mots_results(filename, results, data_type='mot'):
function write_mot_results (line 35) | def write_mot_results(filename, results, data_type='mot'):
function read_mot_results (line 63) | def read_mot_results(filename, data_type='mot', is_gt=False, is_ignore=F...
function _read_mot_results (line 90) | def _read_mot_results(filename, is_gt, is_ignore):
function unzip_objs (line 132) | def unzip_objs(objs):
FILE: utils/log.py
function get_logger (line 4) | def get_logger(name='root'):
FILE: utils/mask.py
function coords2bbox (line 21) | def coords2bbox(coords, extend=2):
function mask2box (line 42) | def mask2box(masks):
function temp_interp_mask (line 54) | def temp_interp_mask(maskseq, T):
function mask_seq_jac (line 68) | def mask_seq_jac(sa, sb):
function skltn2mask (line 78) | def skltn2mask(skltn, size):
function pts2array (line 121) | def pts2array(pts):
FILE: utils/meter.py
class Timer (line 14) | class Timer(object):
method __init__ (line 16) | def __init__(self):
method tic (line 25) | def tic(self):
method toc (line 30) | def toc(self, average=True):
method clear (line 41) | def clear(self):
FILE: utils/visualize.py
function dump_predictions (line 14) | def dump_predictions(pred, lbl_set, img, prefix):
function make_gif (line 57) | def make_gif(video, outname='/tmp/test.gif', sz=256):
function get_color (line 73) | def get_color(idx):
function plot_tracking (line 78) | def plot_tracking(image, obs, obj_ids, scores=None, frame_id=0, fps=0.):
function vis_pose (line 109) | def vis_pose(oriImg, points):
function draw_skeleton (line 149) | def draw_skeleton(aa, kp, color, show_skeleton_labels=False, dataset= "P...
Condensed preview — 379 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (2,504K chars).
[
{
"path": ".gitignore",
"chars": 2018,
"preview": "docs/test_video.mp4\ntest/test_tao.py\nconfig/tao*\ntracker/mot/tao.py\neval/error_log.txt\nconfig/got10k*\nconfig/lasot*\nconf"
},
{
"path": "LICENSE",
"chars": 1069,
"preview": "MIT License\n\nCopyright (c) 2021 ZhongdaoWang\n\nPermission is hereby granted, free of charge, to any person obtaining a co"
},
{
"path": "README.md",
"chars": 5847,
"preview": "<p align=\"center\"> <img src=\"docs/logo.png\" width=\"500\"/> \n\n------------------------------------------------------------"
},
{
"path": "config/crw_resnet18_s3.yaml",
"chars": 2153,
"preview": "common:\n exp_name: crw_resnet18_s3\n \n # Model related\n model_type: crw\n remove_layers: ['layer4']\n im_m"
},
{
"path": "config/crw_resnet18_s3_womotion.yaml",
"chars": 2155,
"preview": "common:\n exp_name: crw_resnet18_s3_womotion\n \n # Model related\n model_type: crw\n remove_layers: ['layer4']"
},
{
"path": "config/imagenet_resnet18_s3.yaml",
"chars": 2128,
"preview": "common:\n exp_name: imagenet_resnet18_s3 \n \n # Model related\n model_type: imagenet18\n remove_layers: ['laye"
},
{
"path": "config/imagenet_resnet18_s3_womotion.yaml",
"chars": 2624,
"preview": "common:\n exp_name: imagenet_resnet18_s3_womotion\n \n # Model related\n model_type: imagenet18\n remove_layers"
},
{
"path": "core/association/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "core/association/matching.py",
"chars": 9619,
"preview": "import pdb\r\nimport cv2\r\nimport torch\r\nimport torch.nn.functional as F\r\nimport numpy as np\r\nimport scipy\r\nfrom scipy.spat"
},
{
"path": "core/motion/kalman_filter.py",
"chars": 9816,
"preview": "# vim: expandtab:ts=4:sw=4\r\nimport numpy as np\r\nimport scipy.linalg\r\n\r\n\r\n\"\"\"\r\nTable for the 0.95 quantile of the chi-squ"
},
{
"path": "core/propagation/__init__.py",
"chars": 884,
"preview": "###################################################################\n# File Name: __init__.py\n# Author: Zhongdao Wang\n# m"
},
{
"path": "core/propagation/propagate_box.py",
"chars": 435,
"preview": "###################################################################\n# File Name: propagate_box.py\n# Author: Zhongdao Wan"
},
{
"path": "core/propagation/propagate_mask.py",
"chars": 437,
"preview": "###################################################################\n# File Name: propagate_box.py\n# Author: Zhongdao Wan"
},
{
"path": "core/propagation/propagate_pose.py",
"chars": 437,
"preview": "###################################################################\n# File Name: propagate_box.py\n# Author: Zhongdao Wan"
},
{
"path": "data/jhmdb.py",
"chars": 8650,
"preview": "from __future__ import print_function, absolute_import\n\nimport os\nimport numpy as np\nimport math\nimport scipy.io as sio\n"
},
{
"path": "data/kinetics.py",
"chars": 3103,
"preview": "import torchvision.datasets.video_utils\n\nfrom torchvision.datasets.video_utils import VideoClips\nfrom torchvision.datase"
},
{
"path": "data/video.py",
"chars": 13402,
"preview": "import os\r\nimport pdb\r\nimport glob\r\nimport json\r\nimport os.path as osp\r\n\r\nimport cv2\r\nimport numpy as np\r\n\r\nimport pycoc"
},
{
"path": "data/vos.py",
"chars": 8308,
"preview": "from __future__ import print_function, absolute_import\n\nimport os\nimport pdb\nimport os.path as osp\nimport numpy as np\nim"
},
{
"path": "demo/mot_demo.py",
"chars": 6791,
"preview": "###################################################################\n# File Name: mot_demo.py\n# Author: Zhongdao Wang\n# m"
},
{
"path": "demo/sot_demo.py",
"chars": 6846,
"preview": "# ------------------------------------------------------------------------------\r\n# Copyright (c) Microsoft\r\n# Licensed "
},
{
"path": "detector/YOLOX/.gitignore",
"chars": 3032,
"preview": "### Linux ###\n*~\n\n# temporary files which can be created if a process still has a handle open of a deleted file\n.fuse_hi"
},
{
"path": "detector/YOLOX/LICENSE",
"chars": 11352,
"preview": " Apache License\n Version 2.0, January 2004\n "
},
{
"path": "detector/YOLOX/README.md",
"chars": 7654,
"preview": "<div align=\"center\"><img src=\"assets/logo.png\" width=\"350\"></div>\n<img src=\"assets/demo.png\" >\n\n## Introduction\nYOLOX is"
},
{
"path": "detector/YOLOX/datasets/README.md",
"chars": 767,
"preview": "# Prepare datasets\n\nIf you have a dataset directory, you could use os environment variable named `YOLOX_DATADIR`. Under "
},
{
"path": "detector/YOLOX/demo/ONNXRuntime/README.md",
"chars": 3818,
"preview": "## YOLOX-ONNXRuntime in Python\n\nThis doc introduces how to convert your pytorch model into onnx, and how to run an onnxr"
},
{
"path": "detector/YOLOX/demo/ONNXRuntime/onnx_inference.py",
"chars": 2791,
"preview": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport argparse\nimport "
},
{
"path": "detector/YOLOX/demo/OpenVINO/README.md",
"chars": 68,
"preview": "## YOLOX for OpenVINO\n\n* [C++ Demo](./cpp)\n* [Python Demo](./python)"
},
{
"path": "detector/YOLOX/demo/OpenVINO/cpp/CMakeLists.txt",
"chars": 483,
"preview": "cmake_minimum_required(VERSION 3.4.1)\nset(CMAKE_CXX_STANDARD 14)\n\nproject(yolox_openvino_demo)\n\nfind_package(OpenCV REQU"
},
{
"path": "detector/YOLOX/demo/OpenVINO/cpp/README.md",
"chars": 4033,
"preview": "# YOLOX-OpenVINO in C++\n\nThis toturial includes a C++ demo for OpenVINO, as well as some converted models.\n\n### Download"
},
{
"path": "detector/YOLOX/demo/OpenVINO/cpp/yolox_openvino.cpp",
"chars": 18847,
"preview": "// Copyright (C) 2018-2021 Intel Corporation\n// SPDX-License-Identifier: Apache-2.0\n//\n\n#include <iterator>\n#include <me"
},
{
"path": "detector/YOLOX/demo/OpenVINO/python/README.md",
"chars": 4138,
"preview": "# YOLOX-OpenVINO in Python\n\nThis toturial includes a Python demo for OpenVINO, as well as some converted models.\n\n### Do"
},
{
"path": "detector/YOLOX/demo/OpenVINO/python/openvino_inference.py",
"chars": 5776,
"preview": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# Copyright (C) 2018-2021 Intel Corporation\n# SPDX-License-Identifier: Ap"
},
{
"path": "detector/YOLOX/demo/TensorRT/cpp/CMakeLists.txt",
"chars": 1108,
"preview": "cmake_minimum_required(VERSION 2.6)\n\nproject(yolox)\n\nadd_definitions(-std=c++11)\n\noption(CUDA_USE_STATIC_CUDA_RUNTIME OF"
},
{
"path": "detector/YOLOX/demo/TensorRT/cpp/README.md",
"chars": 966,
"preview": "# YOLOX-TensorRT in C++\n\nAs YOLOX models is easy to converted to tensorrt using [torch2trt gitrepo](https://github.com/N"
},
{
"path": "detector/YOLOX/demo/TensorRT/cpp/logging.h",
"chars": 16550,
"preview": "/*\n * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved.\n *\n * Licensed under the Apache License, Version 2.0 "
},
{
"path": "detector/YOLOX/demo/TensorRT/cpp/yolox.cpp",
"chars": 17184,
"preview": "#include <fstream>\n#include <iostream>\n#include <sstream>\n#include <numeric>\n#include <chrono>\n#include <vector>\n#includ"
},
{
"path": "detector/YOLOX/demo/TensorRT/python/README.md",
"chars": 1519,
"preview": "# YOLOX-TensorRT in Python\n\nThis toturial includes a Python demo for TensorRT.\n\n## Install TensorRT Toolkit\n\nPlease foll"
},
{
"path": "detector/YOLOX/demo/ncnn/android/README.md",
"chars": 1110,
"preview": "# YOLOX-Android-ncnn\n\nAndoird app of YOLOX object detection base on [ncnn](https://github.com/Tencent/ncnn)\n\n\n## Tutoria"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/build.gradle",
"chars": 496,
"preview": "apply plugin: 'com.android.application'\n\nandroid {\n compileSdkVersion 24\n buildToolsVersion \"29.0.2\"\n\n defaultC"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/AndroidManifest.xml",
"chars": 613,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest xmlns:android=\"http://schemas.android.com/apk/res/android\"\n packag"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/assets/yolox.param",
"chars": 17475,
"preview": "7767517\n220 250\nInput images 0 1 images\nYoloV5Focus focus "
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/java/com/megvii/yoloXncnn/MainActivity.java",
"chars": 8188,
"preview": "// Some code in this file is based on:\n// https://github.com/nihui/ncnn-android-yolov5/blob/master/app/src/main/java/com"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/java/com/megvii/yoloXncnn/YOLOXncnn.java",
"chars": 566,
"preview": "// Copyright (C) Megvii, Inc. and its affiliates. All rights reserved.\n\npackage com.megvii.yoloXncnn;\n\nimport android.co"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/java/com/megvii/yoloXncnn/yoloXncnn.java",
"chars": 566,
"preview": "// Copyright (C) Megvii, Inc. and its affiliates. All rights reserved.\n\npackage com.megvii.yoloXncnn;\n\nimport android.co"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/jni/CMakeLists.txt",
"chars": 290,
"preview": "project(yoloXncnn)\n\ncmake_minimum_required(VERSION 3.4.1)\n\nset(ncnn_DIR ${CMAKE_SOURCE_DIR}/ncnn-20210525-android-vulkan"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/jni/yoloXncnn_jni.cpp",
"chars": 14469,
"preview": "// Some code in this file is based on:\n// https://github.com/nihui/ncnn-android-yolov5/blob/master/app/src/main/jni/yolo"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/res/layout/main.xml",
"chars": 1116,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "detector/YOLOX/demo/ncnn/android/app/src/main/res/values/strings.xml",
"chars": 111,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <string name=\"app_name\">yoloXncnn</string>\n</resources>\n"
},
{
"path": "detector/YOLOX/demo/ncnn/android/build.gradle",
"chars": 335,
"preview": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\nbuildscript {\n re"
},
{
"path": "detector/YOLOX/demo/ncnn/android/gradle/wrapper/gradle-wrapper.properties",
"chars": 232,
"preview": "#Sun Aug 25 10:34:48 CST 2019\ndistributionBase=GRADLE_USER_HOME\ndistributionPath=wrapper/dists\nzipStoreBase=GRADLE_USER_"
},
{
"path": "detector/YOLOX/demo/ncnn/android/gradlew",
"chars": 5296,
"preview": "#!/usr/bin/env sh\n\n##############################################################################\n##\n## Gradle start up"
},
{
"path": "detector/YOLOX/demo/ncnn/android/gradlew.bat",
"chars": 2176,
"preview": "@if \"%DEBUG%\" == \"\" @echo off\n@rem ##########################################################################\n@rem\n@rem "
},
{
"path": "detector/YOLOX/demo/ncnn/android/settings.gradle",
"chars": 15,
"preview": "include ':app'\n"
},
{
"path": "detector/YOLOX/demo/ncnn/cpp/README.md",
"chars": 3074,
"preview": "# YOLOX-CPP-ncnn\n\nCpp file compile of YOLOX object detection base on [ncnn](https://github.com/Tencent/ncnn).\n\n## Tutori"
},
{
"path": "detector/YOLOX/demo/ncnn/cpp/yolox.cpp",
"chars": 12890,
"preview": "// This file is wirtten base on the following file:\n// https://github.com/Tencent/ncnn/blob/master/examples/yolov5.cpp\n/"
},
{
"path": "detector/YOLOX/demo.py",
"chars": 9275,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport argparse\nimport o"
},
{
"path": "detector/YOLOX/docs/train_custom_data.md",
"chars": 5550,
"preview": "# Train Custom Data.\nThis page explains how to train your own custom data with YOLOX.\n\nWe take an example of fine-tuning"
},
{
"path": "detector/YOLOX/exps/default/nano.py",
"chars": 1320,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\nimport torch.n"
},
{
"path": "detector/YOLOX/exps/default/yolov3.py",
"chars": 3006,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\nimport torch\ni"
},
{
"path": "detector/YOLOX/exps/default/yolox_l.py",
"chars": 355,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\n\nfrom yolox.ex"
},
{
"path": "detector/YOLOX/exps/default/yolox_m.py",
"chars": 357,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\n\nfrom yolox.ex"
},
{
"path": "detector/YOLOX/exps/default/yolox_s.py",
"chars": 357,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\n\nfrom yolox.ex"
},
{
"path": "detector/YOLOX/exps/default/yolox_tiny.py",
"chars": 496,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\n\nfrom yolox.ex"
},
{
"path": "detector/YOLOX/exps/default/yolox_x.py",
"chars": 357,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\n\nfrom yolox.ex"
},
{
"path": "detector/YOLOX/exps/example/yolox_voc/yolox_voc_s.py",
"chars": 3886,
"preview": "# encoding: utf-8\nimport os\nimport random\nimport torch\nimport torch.nn as nn\nimport torch.distributed as dist\n\nfrom yolo"
},
{
"path": "detector/YOLOX/requirements.txt",
"chars": 121,
"preview": "numpy\ntorch>=1.7\nopencv_python\nloguru\nscikit-image\ntqdm\ntorchvision\nPillow\nthop\nninja\ntabulate\ntensorboard\nonnxruntime\n\n"
},
{
"path": "detector/YOLOX/setup.cfg",
"chars": 615,
"preview": "[isort]\nline_length = 100\nmulti_line_output = 3\nbalanced_wrapping = True\nknown_standard_library = setuptools\nknown_third"
},
{
"path": "detector/YOLOX/setup.py",
"chars": 1648,
"preview": "#!/usr/bin/env python\n# Copyright (c) Megvii, Inc. and its affiliates. All Rights Reserved\n\nimport re\nimport setuptools\n"
},
{
"path": "detector/YOLOX/tools/__init__.py",
"chars": 372,
"preview": "###################################################################\n# File Name: __init__.py\n# Author: Zhongdao Wang\n# m"
},
{
"path": "detector/YOLOX/tools/demo.py",
"chars": 9265,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport argparse\nimport o"
},
{
"path": "detector/YOLOX/tools/eval.py",
"chars": 6318,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport argparse\nimport o"
},
{
"path": "detector/YOLOX/tools/export_onnx.py",
"chars": 2884,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport argparse\nimport o"
},
{
"path": "detector/YOLOX/tools/train.py",
"chars": 3536,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport argparse\nimport r"
},
{
"path": "detector/YOLOX/tools/trt.py",
"chars": 2236,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport argparse\nimport o"
},
{
"path": "detector/YOLOX/yolox/__init__.py",
"chars": 126,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n\nfrom .utils import configure_module\n\nconfigure_module()\n\n__version__ = \"0"
},
{
"path": "detector/YOLOX/yolox/core/__init__.py",
"chars": 152,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nfrom .launch import laun"
},
{
"path": "detector/YOLOX/yolox/core/launch.py",
"chars": 3558,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Code are based on\n# https://github.com/facebookresearch/detectron2/blob/"
},
{
"path": "detector/YOLOX/yolox/core/trainer.py",
"chars": 11326,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport datetime\nimport o"
},
{
"path": "detector/YOLOX/yolox/data/__init__.py",
"chars": 330,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nfrom .data_augment impor"
},
{
"path": "detector/YOLOX/yolox/data/data_augment.py",
"chars": 9963,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\"\"\"\nData augmentation fun"
},
{
"path": "detector/YOLOX/yolox/data/data_prefetcher.py",
"chars": 2294,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport random\n\nimport to"
},
{
"path": "detector/YOLOX/yolox/data/dataloading.py",
"chars": 6231,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\nimport random\n"
},
{
"path": "detector/YOLOX/yolox/data/datasets/__init__.py",
"chars": 313,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nfrom .coco import COCODa"
},
{
"path": "detector/YOLOX/yolox/data/datasets/coco.py",
"chars": 4322,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport os\n\nimport cv2\nim"
},
{
"path": "detector/YOLOX/yolox/data/datasets/coco_classes.py",
"chars": 1296,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nCOCO_CLASSES = (\n \"pe"
},
{
"path": "detector/YOLOX/yolox/data/datasets/datasets_wrapper.py",
"chars": 4238,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport bisect\nfrom funct"
},
{
"path": "detector/YOLOX/yolox/data/datasets/mosaicdetection.py",
"chars": 9255,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport random\n\nimport cv"
},
{
"path": "detector/YOLOX/yolox/data/datasets/voc.py",
"chars": 9905,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Code are based on\n# https://github.com/fmassa/vision/blob/voc_dataset/to"
},
{
"path": "detector/YOLOX/yolox/data/datasets/voc_classes.py",
"chars": 442,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\n# VOC_CLASSES = ( '__bac"
},
{
"path": "detector/YOLOX/yolox/data/samplers.py",
"chars": 3356,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport itertools\nfrom ty"
},
{
"path": "detector/YOLOX/yolox/evaluators/__init__.py",
"chars": 178,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nfrom .coco_evaluator imp"
},
{
"path": "detector/YOLOX/yolox/evaluators/coco_evaluator.py",
"chars": 7317,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport contextlib\nimport"
},
{
"path": "detector/YOLOX/yolox/evaluators/voc_eval.py",
"chars": 5739,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Code are based on\n# https://github.com/rbgirshick/py-faster-rcnn/blob/ma"
},
{
"path": "detector/YOLOX/yolox/evaluators/voc_evaluator.py",
"chars": 6439,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) Megvii, Inc. and its affiliates.\n\nimport sys\nimport tempfi"
},
{
"path": "detector/YOLOX/yolox/exp/__init__.py",
"chars": 191,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nfrom .base_exp"
},
{
"path": "detector/YOLOX/yolox/exp/base_exp.py",
"chars": 1981,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport ast\nimp"
},
{
"path": "detector/YOLOX/yolox/exp/build.py",
"chars": 1349,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport importl"
},
{
"path": "detector/YOLOX/yolox/exp/yolox_base.py",
"chars": 8248,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport os\nimpo"
},
{
"path": "detector/YOLOX/yolox/layers/__init__.py",
"chars": 151,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nfrom .fast_coc"
},
{
"path": "detector/YOLOX/yolox/layers/csrc/cocoeval/cocoeval.cpp",
"chars": 20824,
"preview": "// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\n#include \"cocoeval.h\"\n#include <time.h>\n#include"
},
{
"path": "detector/YOLOX/yolox/layers/csrc/cocoeval/cocoeval.h",
"chars": 3485,
"preview": "// Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\n#pragma once\n\n#include <pybind11/numpy.h>\n#inclu"
},
{
"path": "detector/YOLOX/yolox/layers/csrc/vision.cpp",
"chars": 524,
"preview": "#include \"cocoeval/cocoeval.h\"\n\nPYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {\n m.def(\"COCOevalAccumulate\", &COCOeval::Ac"
},
{
"path": "detector/YOLOX/yolox/layers/fast_coco_eval_api.py",
"chars": 5719,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# This file comes from\n# https://github.com/facebookresearch/detectron2/bl"
},
{
"path": "detector/YOLOX/yolox/models/__init__.py",
"chars": 297,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nfrom .darknet "
},
{
"path": "detector/YOLOX/yolox/models/darknet.py",
"chars": 5696,
"preview": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nfrom torch i"
},
{
"path": "detector/YOLOX/yolox/models/losses.py",
"chars": 1663,
"preview": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport torch"
},
{
"path": "detector/YOLOX/yolox/models/network_blocks.py",
"chars": 5734,
"preview": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport torch"
},
{
"path": "detector/YOLOX/yolox/models/yolo_fpn.py",
"chars": 2472,
"preview": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport torch"
},
{
"path": "detector/YOLOX/yolox/models/yolo_head.py",
"chars": 21440,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport math\nfr"
},
{
"path": "detector/YOLOX/yolox/models/yolo_pafpn.py",
"chars": 3500,
"preview": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport torch"
},
{
"path": "detector/YOLOX/yolox/models/yolox.py",
"chars": 1374,
"preview": "#!/usr/bin/env python\n# -*- encoding: utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport torch"
},
{
"path": "detector/YOLOX/yolox/utils/__init__.py",
"chars": 450,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nfrom .allreduc"
},
{
"path": "detector/YOLOX/yolox/utils/allreduce_norm.py",
"chars": 2842,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport pickle\n"
},
{
"path": "detector/YOLOX/yolox/utils/boxes.py",
"chars": 4021,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport numpy a"
},
{
"path": "detector/YOLOX/yolox/utils/checkpoint.py",
"chars": 1330,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\nimport os\nimpor"
},
{
"path": "detector/YOLOX/yolox/utils/demo_utils.py",
"chars": 2764,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport os\n\nimp"
},
{
"path": "detector/YOLOX/yolox/utils/dist.py",
"chars": 7066,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# This file mainly comes from\n# https://github.com/facebookresearch/detect"
},
{
"path": "detector/YOLOX/yolox/utils/ema.py",
"chars": 2607,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\nimport math\nfro"
},
{
"path": "detector/YOLOX/yolox/utils/logger.py",
"chars": 2749,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport inspect"
},
{
"path": "detector/YOLOX/yolox/utils/lr_scheduler.py",
"chars": 6561,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport math\nfr"
},
{
"path": "detector/YOLOX/yolox/utils/metric.py",
"chars": 3020,
"preview": "#!/usr/bin/env python3\n# -*- coding: utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\nimport functoo"
},
{
"path": "detector/YOLOX/yolox/utils/model_utils.py",
"chars": 3256,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nfrom copy impo"
},
{
"path": "detector/YOLOX/yolox/utils/setup_env.py",
"chars": 1573,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport os\nimpo"
},
{
"path": "detector/YOLOX/yolox/utils/visualize.py",
"chars": 3609,
"preview": "#!/usr/bin/env python3\n# -*- coding:utf-8 -*-\n# Copyright (c) 2014-2021 Megvii Inc. All rights reserved.\n\nimport cv2\nimp"
},
{
"path": "docs/DATA.md",
"chars": 5948,
"preview": "# Dataset preparation\n\n### Introduction\n\nIn this documentation we introduce how to prepara standard datasets to benchmar"
},
{
"path": "docs/INSTALL.md",
"chars": 712,
"preview": "# Installation\n\n### Requirements\n* Nvidia device with CUDA \n* Python 3.7+\n* PyTorch 1.7.0+\n* torchvision 0.8.0+\n* Other "
},
{
"path": "docs/MODELZOO.md",
"chars": 3775,
"preview": "# MODEL ZOO\n\n\n### Prepare apperance models\nOne beneficial usage of UniTrack is that it allows easy evaluation of pre-tra"
},
{
"path": "docs/RESULTS.md",
"chars": 2134,
"preview": "### Quantitative results\n\n**Single Object Tracking (SOT) on OTB-2015**\n\n| Method | SiamFC | SiamRPN | SiamRPN++ | UDT* |"
},
{
"path": "docs/RUN.md",
"chars": 3178,
"preview": "# Run evaluation on multiple tasks\n\n### Prepare config file\n\nTo evaluate an apperance model on multiple tasks, first you"
},
{
"path": "eval/convert_davis.py",
"chars": 2333,
"preview": "import os\nimport numpy as np\nimport cv2\nimport os.path as osp\nimport pdb\n\nfrom PIL import Image\n\njpglist = []\n\nimport pa"
},
{
"path": "eval/davis_dummy.txt",
"chars": 2572,
"preview": "/home/wangzd/datasets/uvc/DAVIS/JPEGImages/480p/dance-twirl /home/wangzd/datasets/uvc/DAVIS/Annotations/480p/dance-twirl"
},
{
"path": "eval/eval_mot.py",
"chars": 3657,
"preview": "import os\r\nimport numpy as np\r\nimport copy\r\nimport motmetrics as mm\r\nmm.lap.default_solver = 'lap'\r\nfrom utils.io import"
},
{
"path": "eval/eval_pck.py",
"chars": 3711,
"preview": "from scipy.io import loadmat\nfrom numpy import transpose\nimport skimage.io as sio\nimport numpy as np\nimport os\nimport cv"
},
{
"path": "eval/mots/Evaluator.py",
"chars": 7199,
"preview": "import pdb\nimport sys, os\nsys.path.append(os.getcwd())\nimport argparse\n\nimport traceback\nimport time\nimport pickle\nimpor"
},
{
"path": "eval/mots/LICENSE",
"chars": 1083,
"preview": "MIT License\n\nCopyright (c) 2019 Visual Computing Institute\n\nPermission is hereby granted, free of charge, to any person "
},
{
"path": "eval/mots/MOTSVisualization.py",
"chars": 1811,
"preview": "import sys\nfrom Visualize import Visualizer\nfrom mots_common.io import load_sequences, load_seqmap, load_txt\nimport pyco"
},
{
"path": "eval/mots/MOTS_metrics.py",
"chars": 19449,
"preview": "import math\nfrom collections import defaultdict\nimport pycocotools.mask as rletools\nfrom mots_common.io import Segmented"
},
{
"path": "eval/mots/Metrics.py",
"chars": 4673,
"preview": "from __future__ import division\nfrom collections import OrderedDict, Iterable\nimport pandas as pd\nimport numpy as np\nimp"
},
{
"path": "eval/mots/README.md",
"chars": 3332,
"preview": "# MOTS\r\n\r\n\r\n## Requirements\r\n* Python 3.6.9\r\n* inst"
},
{
"path": "eval/mots/Visualize.py",
"chars": 4621,
"preview": "\nimport cv2\nimport numpy as np\nimport os, sys\nimport glob\nimport colorsys\nimport traceback\n\n\nclass Visualizer(object):\n "
},
{
"path": "eval/mots/__init__.py",
"chars": 75,
"preview": "import os, sys\nsys.path.append(os.path.dirname(os.path.abspath(__file__)))\n"
},
{
"path": "eval/mots/evalMOTS.py",
"chars": 1501,
"preview": "import sys, os\nimport pdb\nsys.path.append(os.path.abspath(os.getcwd()))\nimport math\nfrom collections import defaultdict\n"
},
{
"path": "eval/mots/mots_common/images_to_txt.py",
"chars": 554,
"preview": "import sys\nfrom mots_common.io import load_sequences, load_seqmap, write_sequences\n\n\nif __name__ == \"__main__\":\n if len"
},
{
"path": "eval/mots/mots_common/io.py",
"chars": 4379,
"preview": "import PIL.Image as Image\nimport numpy as np\nimport pycocotools.mask as rletools\nimport glob\nimport os\n\n\nclass Segmented"
},
{
"path": "eval/mots/requirements.txt",
"chars": 230,
"preview": "cycler==0.10.0\nCython==0.29.20\nkiwisolver==1.2.0\nmatplotlib==3.2.2\nnumpy==1.19.0\nopencv-python==4.2.0.34\npandas==1.0.5\nP"
},
{
"path": "eval/palette.py",
"chars": 2903,
"preview": "palette_str = '''0 0 0\n128 0 0\n0 128 0\n128 128 0\n0 0 128\n128 0 128\n0 128 128\n128 128 128\n64 0 0\n191 0 0\n64 128 0\n191 128"
},
{
"path": "eval/poseval/.gitignore",
"chars": 72,
"preview": "# python\nvenv*/\n__pycache__\n*.egg-info/\n\n# editor\n.vscode/\n\n# data\nout/\n"
},
{
"path": "eval/poseval/.gitmodules",
"chars": 0,
"preview": ""
},
{
"path": "eval/poseval/.pylintrc",
"chars": 1305,
"preview": "[BASIC]\n\nvariable-rgx=[a-z0-9_]{1,30}$\ngood-names=ap,ar,ax,b,d,f,g,gt,h,i,im,lr,n,p,r,s,t,t1,t2,th,v,vs,w,wh,x,x1,x2,xs,"
},
{
"path": "eval/poseval/README.md",
"chars": 6226,
"preview": "# Poseval\n\nCreated by Leonid Pishchulin.\nAdapted by Sven Kreiss.\n\nInstall directly from GitHub:\n\n```\npip install https:/"
},
{
"path": "eval/poseval/evaluate.py",
"chars": 3279,
"preview": "import json\r\nimport pdb\r\nimport os\r\nimport sys\r\nimport numpy as np\r\nimport argparse\r\n\r\nfrom poseval.evaluateAP import ev"
},
{
"path": "eval/poseval/license.txt",
"chars": 1521,
"preview": "Copyright (c) 2018, Leonid Pishchulin\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or w"
},
{
"path": "eval/poseval/matlab/external/jsonlab/AUTHORS.txt",
"chars": 1998,
"preview": "The author of \"jsonlab\" toolbox is Qianqian Fang. Qianqian\nis currently an Assistant Professor in the Department of Bioe"
},
{
"path": "eval/poseval/matlab/external/jsonlab/ChangeLog.txt",
"chars": 5232,
"preview": "============================================================================\n\n JSONlab - a toolbox to encode/decode JS"
},
{
"path": "eval/poseval/matlab/external/jsonlab/LICENSE_BSD.txt",
"chars": 1551,
"preview": "Copyright 2011-2015 Qianqian Fang <fangq at nmr.mgh.harvard.edu>. All rights reserved.\n\nRedistribution and use in source"
},
{
"path": "eval/poseval/matlab/external/jsonlab/README.txt",
"chars": 19980,
"preview": "===============================================================================\n= JSONLa"
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/demo_jsonlab_basic.m",
"chars": 6445,
"preview": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Demonstration of Basic Utilities of JSONl"
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/demo_ubjson_basic.m",
"chars": 6509,
"preview": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Demonstration of Basic Utilities of JSONl"
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/example1.json",
"chars": 436,
"preview": " {\n \"firstName\": \"John\",\n \"lastName\": \"Smith\",\n \"age\": 25,\n \"address\":\n {\n \"streetAddress\": "
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/example2.json",
"chars": 583,
"preview": "{\n \"glossary\": {\n \"title\": \"example glossary\",\n\t\t\"GlossDiv\": {\n \"title\": \"S\",\n\t\t\t\"GlossList\": {\n "
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/example3.json",
"chars": 272,
"preview": "{\"menu\": {\n \"id\": \"file\",\n \"value\": \"_&File\",\n \"popup\": {\n \"menuitem\": [\n {\"value\": \"_&New\", \"onclick\": \"Crea"
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/example4.json",
"chars": 563,
"preview": "[\n {\n \"sample\" : {\n \"rho\" : 1\n }\n },\n {\n \"sample\" : {\n \"rho\" : 2\n }\n },\n [\n "
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/jsonlab_basictest.matlab",
"chars": 10001,
"preview": "\n < M A T L A B (R) >\n Copyright 1984-2010 The MathWorks, Inc.\n "
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/jsonlab_selftest.m",
"chars": 995,
"preview": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Regression Test Unit of loadjson and save"
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/jsonlab_selftest.matlab",
"chars": 4387,
"preview": "\n < M A T L A B (R) >\n Copyright 1984-2010 The MathWorks, Inc.\n "
},
{
"path": "eval/poseval/matlab/external/jsonlab/examples/jsonlab_speedtest.m",
"chars": 675,
"preview": "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%\n% Benchmarking processing speed of savejson"
},
{
"path": "eval/poseval/matlab/external/jsonlab/jsonopt.m",
"chars": 977,
"preview": "function val=jsonopt(key,default,varargin)\n%\n% val=jsonopt(key,default,optstruct)\n%\n% setting options based on a struct."
},
{
"path": "eval/poseval/matlab/external/jsonlab/loadjson.m",
"chars": 16144,
"preview": "function data = loadjson(fname,varargin)\n%\n% data=loadjson(fname,opt)\n% or\n% data=loadjson(fname,'param1',value1,'par"
},
{
"path": "eval/poseval/matlab/external/jsonlab/loadubjson.m",
"chars": 13300,
"preview": "function data = loadubjson(fname,varargin)\n%\n% data=loadubjson(fname,opt)\n% or\n% data=loadubjson(fname,'param1',value"
},
{
"path": "eval/poseval/matlab/external/jsonlab/mergestruct.m",
"chars": 779,
"preview": "function s=mergestruct(s1,s2)\n%\n% s=mergestruct(s1,s2)\n%\n% merge two struct objects into one\n%\n% authors:Qianqian Fang ("
},
{
"path": "eval/poseval/matlab/external/jsonlab/savejson.m",
"chars": 18981,
"preview": "function json=savejson(rootname,obj,varargin)\n%\n% json=savejson(rootname,obj,filename)\n% or\n% json=savejson(rootname,"
},
{
"path": "eval/poseval/matlab/external/jsonlab/saveubjson.m",
"chars": 17723,
"preview": "function json=saveubjson(rootname,obj,varargin)\n%\n% json=saveubjson(rootname,obj,filename)\n% or\n% json=saveubjson(roo"
},
{
"path": "eval/poseval/matlab/external/jsonlab/struct2jdata.m",
"chars": 3519,
"preview": "function newdata=struct2jdata(data,varargin)\n%\n% newdata=struct2jdata(data,opt,...)\n%\n% convert a JData object (in the f"
},
{
"path": "eval/poseval/matlab/external/jsonlab/varargin2struct.m",
"chars": 1109,
"preview": "function opt=varargin2struct(varargin)\n%\n% opt=varargin2struct('param1',value1,'param2',value2,...)\n% or\n% opt=varargi"
},
{
"path": "eval/poseval/matlab/mat2json.m",
"chars": 719,
"preview": "function mat2json(dataDir)\n% The function is part of PoseTrack dataset. \n%\n% It converts labels from matlab structure lo"
},
{
"path": "eval/poseval/matlab/startup.m",
"chars": 29,
"preview": "addpath('./external/jsonlab')"
},
{
"path": "eval/poseval/poseval/__init__.py",
"chars": 0,
"preview": ""
},
{
"path": "eval/poseval/poseval/convert.py",
"chars": 23150,
"preview": "#!/usr/bin/env python\n\"\"\"Convert between COCO and PoseTrack2017 format.\"\"\"\nfrom __future__ import print_function\n\nimport"
},
{
"path": "eval/poseval/poseval/eval_helpers.py",
"chars": 23629,
"preview": "import numpy as np\nfrom shapely import geometry\nimport pdb\nimport sys\nimport os\nimport json\nimport glob\nfrom .convert im"
},
{
"path": "eval/poseval/poseval/evaluateAP.py",
"chars": 3460,
"preview": "import numpy as np\nimport json\nimport os\nimport sys\n\nfrom . import eval_helpers\nfrom .eval_helpers import Joint\n\ndef com"
},
{
"path": "eval/poseval/poseval/evaluatePCKh.py",
"chars": 2739,
"preview": "import numpy as np\nimport json\nimport os\nimport sys\n\nimport eval_helpers\n\ndef computeDist(gtFrames,prFrames):\n assert"
},
{
"path": "eval/poseval/poseval/evaluateTracking.py",
"chars": 9497,
"preview": "import numpy as np\nimport json\nimport pdb\nimport os\nimport sys\n\nfrom . import eval_helpers\nfrom .eval_helpers import Joi"
},
{
"path": "eval/poseval/poseval/posetrack18_id2fname.py",
"chars": 34269,
"preview": "import os\n\nposetrack17_train_sequences = set(\n [\n (1, 8838),\n (1, 12218),\n (1, 6852),\n (1"
},
{
"path": "eval/trackeval/__init__.py",
"chars": 116,
"preview": "from .eval import Evaluator\nfrom . import datasets\nfrom . import metrics\nfrom . import plotting\nfrom . import utils\n"
},
{
"path": "eval/trackeval/_timing.py",
"chars": 2161,
"preview": "from functools import wraps\nfrom time import perf_counter\nimport inspect\n\nDO_TIMING = False\nDISPLAY_LESS_PROGRESS = Fals"
},
{
"path": "eval/trackeval/datasets/__init__.py",
"chars": 276,
"preview": "from .kitti_2d_box import Kitti2DBox\nfrom .kitti_mots import KittiMOTS\nfrom .mot_challenge_2d_box import MotChallenge2DB"
},
{
"path": "eval/trackeval/datasets/_base_dataset.py",
"chars": 16188,
"preview": "import csv\nimport io\nimport zipfile\nimport os\nimport traceback\nimport numpy as np\nfrom copy import deepcopy\nfrom abc imp"
},
{
"path": "eval/trackeval/datasets/bdd100k.py",
"chars": 16589,
"preview": "\nimport os\nimport json\nimport numpy as np\nfrom scipy.optimize import linear_sum_assignment\nfrom ..utils import TrackEval"
},
{
"path": "eval/trackeval/datasets/davis.py",
"chars": 14167,
"preview": "import os\nimport csv\nimport numpy as np\nfrom ._base_dataset import _BaseDataset\nfrom ..utils import TrackEvalException\nf"
},
{
"path": "eval/trackeval/datasets/kitti_2d_box.py",
"chars": 21505,
"preview": "\nimport os\nimport csv\nimport numpy as np\nfrom scipy.optimize import linear_sum_assignment\nfrom ._base_dataset import _Ba"
},
{
"path": "eval/trackeval/datasets/kitti_mots.py",
"chars": 22334,
"preview": "import os\nimport csv\nimport numpy as np\nfrom scipy.optimize import linear_sum_assignment\nfrom ._base_dataset import _Bas"
},
{
"path": "eval/trackeval/datasets/mot_challenge_2d_box.py",
"chars": 22998,
"preview": "import os\nimport csv\nimport configparser\nimport numpy as np\nfrom scipy.optimize import linear_sum_assignment\nfrom ._base"
},
{
"path": "eval/trackeval/datasets/mots_challenge.py",
"chars": 23565,
"preview": "import os\nimport csv\nimport configparser\nimport numpy as np\nfrom scipy.optimize import linear_sum_assignment\nfrom ._base"
},
{
"path": "eval/trackeval/datasets/tao.py",
"chars": 29842,
"preview": "import os\nimport numpy as np\nimport json\nimport itertools\nfrom collections import defaultdict\nfrom scipy.optimize import"
},
{
"path": "eval/trackeval/datasets/youtube_vis.py",
"chars": 19632,
"preview": "import os\nimport numpy as np\nimport json\nfrom ._base_dataset import _BaseDataset\nfrom ..utils import TrackEvalException\n"
},
{
"path": "eval/trackeval/eval.py",
"chars": 10885,
"preview": "import time\nimport traceback\nfrom multiprocessing.pool import Pool\nfrom functools import partial\nimport os\nfrom . import"
},
{
"path": "eval/trackeval/metrics/__init__.py",
"chars": 186,
"preview": "from .hota import HOTA\nfrom .clear import CLEAR\nfrom .identity import Identity\nfrom .count import Count\nfrom .j_and_f im"
},
{
"path": "eval/trackeval/metrics/_base_metric.py",
"chars": 4997,
"preview": "\nimport numpy as np\nfrom abc import ABC, abstractmethod\nfrom .. import _timing\nfrom ..utils import TrackEvalException\n\n\n"
},
{
"path": "eval/trackeval/metrics/clear.py",
"chars": 8164,
"preview": "\nimport numpy as np\nfrom scipy.optimize import linear_sum_assignment\nfrom ._base_metric import _BaseMetric\nfrom .. impor"
},
{
"path": "eval/trackeval/metrics/count.py",
"chars": 1544,
"preview": "\nfrom ._base_metric import _BaseMetric\nfrom .. import _timing\n\n\nclass Count(_BaseMetric):\n \"\"\"Class which simply coun"
}
]
// ... and 179 more files (download for full content)
About this extraction
This page contains the full source code of the Zhongdao/UniTrack GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 379 files (2.3 MB), approximately 617.0k tokens, and a symbol index with 2141 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.