├── .github
└── pull_request_template.md
├── .gitignore
├── DEVELOPMENT.md
├── Dockerfile
├── LICENSE
├── README.md
├── alodataset
├── __init__.py
├── base_dataset.py
├── chairssdhom_dataset.py
├── coco_base_dataset.py
├── coco_detection_dataset.py
├── coco_panoptic_dataset.py
├── crowd_human_dataset.py
├── flying_chairs2_dataset.py
├── flyingthings3D_subset_dataset.py
├── from_directory_dataset.py
├── io
│ ├── __init__.py
│ └── fs.py
├── kitti_depth.py
├── kitti_object.py
├── kitti_odometry.py
├── kitti_road.py
├── kitti_semantic.py
├── kitti_split_dataset.py
├── kitti_stereo_flow2012.py
├── kitti_stereo_flow_sflow2015.py
├── kitti_tracking.py
├── lvis_dataset.py
├── merge_dataset.py
├── mot17.py
├── prepare
│ ├── __init__.py
│ ├── waymo-requirements.txt
│ ├── waymo_converter.py
│ └── waymo_prepare.py
├── sequence_mixin.py
├── sintel_base_dataset.py
├── sintel_disparity_dataset.py
├── sintel_flow_dataset.py
├── sintel_multi_dataset.py
├── split_mixin.py
├── transforms.py
├── utils
│ ├── __init__.py
│ ├── kitti.py
│ └── panoptic_utils.py
├── waymo_dataset.py
├── woodScape_dataset.py
└── woodScape_split_dataset.py
├── alonet
├── __init__.py
├── callbacks
│ ├── __init__.py
│ ├── base_metrics_callback.py
│ ├── map_metrics_callback.py
│ ├── metrics_callback.py
│ ├── object_detector_callback.py
│ └── pq_metrics_callback.py
├── common
│ ├── __init__.py
│ ├── abstract_classes.py
│ ├── base_datamodule.py
│ ├── base_lightningmodule.py
│ ├── logger.py
│ ├── pl_helpers.py
│ └── weights.py
├── deformable_detr
│ ├── README.md
│ ├── __init__.py
│ ├── backbone.py
│ ├── callbacks.py
│ ├── criterion.py
│ ├── deformable_detr.py
│ ├── deformable_detr_r50.py
│ ├── deformable_detr_r50_finetune.py
│ ├── deformable_detr_r50_refinement.py
│ ├── deformable_transformer.py
│ ├── eval_on_coco.py
│ ├── matcher.py
│ ├── ops
│ │ ├── __init__.py
│ │ ├── functions
│ │ │ ├── __init__.py
│ │ │ └── ms_deform_attn_func.py
│ │ ├── make.sh
│ │ ├── modules
│ │ │ ├── __init__.py
│ │ │ └── ms_deform_attn.py
│ │ ├── setup.py
│ │ ├── src
│ │ │ ├── __init__.py
│ │ │ ├── cpu
│ │ │ │ ├── ms_deform_attn_cpu.cpp
│ │ │ │ └── ms_deform_attn_cpu.h
│ │ │ ├── cuda
│ │ │ │ ├── ms_deform_attn_cuda.cu
│ │ │ │ ├── ms_deform_attn_cuda.h
│ │ │ │ └── ms_deform_im2col_cuda.cuh
│ │ │ ├── ms_deform_attn.h
│ │ │ └── vision.cpp
│ │ └── test.py
│ ├── production
│ │ ├── README.md
│ │ ├── export_to_pt.py
│ │ └── setup_config.json
│ ├── train.py
│ ├── train_on_coco.py
│ ├── trt_exporter.py
│ └── utils.py
├── deformable_detr_panoptic
│ ├── README.md
│ ├── __init__.py
│ ├── callbacks.py
│ ├── criterion.py
│ ├── deformable_detr_r50_panoptic.py
│ ├── deformable_detr_r50_panoptic_finetune.py
│ ├── eval_on_coco.py
│ ├── train.py
│ ├── train_on_coco.py
│ └── trt_exporter.py
├── detr
│ ├── README.md
│ ├── __init__.py
│ ├── backbone.py
│ ├── callbacks.py
│ ├── criterion.py
│ ├── data_modules
│ │ ├── __init__.py
│ │ ├── coco_detection2detr.py
│ │ ├── coco_panoptic2detr.py
│ │ └── data2detr.py
│ ├── detr.py
│ ├── detr_r50.py
│ ├── detr_r50_finetune.py
│ ├── eval_on_coco.py
│ ├── matcher.py
│ ├── misc.py
│ ├── production
│ │ ├── README.md
│ │ ├── __init__.py
│ │ ├── export_to_pt.py
│ │ ├── index_to_name_things.json
│ │ ├── model_handler.py
│ │ └── setup_config.json
│ ├── train.py
│ ├── train_on_coco.py
│ ├── transformer.py
│ └── trt_exporter.py
├── detr_panoptic
│ ├── README.md
│ ├── __init__.py
│ ├── callbacks.py
│ ├── criterion.py
│ ├── detr_panoptic.py
│ ├── detr_r50_panoptic.py
│ ├── detr_r50_panoptic_finetune.py
│ ├── eval_on_coco.py
│ ├── misc.py
│ ├── nn
│ │ ├── FPNstyle.py
│ │ ├── MHAttention.py
│ │ └── __init__.py
│ ├── train.py
│ ├── train_on_coco.py
│ ├── trt_exporter.py
│ └── utils.py
├── metrics
│ ├── __init__.py
│ ├── compute_map.py
│ ├── compute_map_3d.py
│ ├── compute_pq.py
│ ├── depth_metrics.py
│ └── utils.py
├── multi_gpu.py
├── raft
│ ├── README.md
│ ├── __init__.py
│ ├── callbacks
│ │ ├── __init__.py
│ │ ├── epe.py
│ │ ├── flow_image.py
│ │ └── flow_video.py
│ ├── corr.py
│ ├── criterion.py
│ ├── data_modules
│ │ ├── __init__.py
│ │ ├── chairs2raft.py
│ │ ├── chairssdhom2raft.py
│ │ ├── data2raft.py
│ │ ├── sintel2raft.py
│ │ └── things2raft.py
│ ├── eval_on_sintel.py
│ ├── extractor.py
│ ├── raft.py
│ ├── raft_small.py
│ ├── raft_transforms.py
│ ├── train.py
│ ├── train_on_chairs.py
│ ├── update.py
│ └── utils
│ │ ├── __init__.py
│ │ └── utils.py
├── torch2trt
│ ├── README.md
│ ├── TRTEngineBuilder.py
│ ├── TRTExecutor.py
│ ├── __init__.py
│ ├── base_exporter.py
│ ├── calibrator.py
│ ├── onnx_hack.py
│ ├── plugins
│ │ ├── make.sh
│ │ └── ms_deform_im2col
│ │ │ ├── CMakeLists.txt
│ │ │ ├── README.txt
│ │ │ ├── sources
│ │ │ ├── ms_deform_im2col_kernel.cu
│ │ │ ├── ms_deform_im2col_kernel.h
│ │ │ ├── ms_deform_im2col_plugin.cpp
│ │ │ └── ms_deform_im2col_plugin.h
│ │ │ └── test.py
│ ├── quantization.py
│ ├── requirements.txt
│ └── utils.py
└── transformers
│ ├── __init__.py
│ ├── mlp.py
│ └── position_encoding.py
├── aloscene
├── __init__.py
├── bounding_boxes_2d.py
├── bounding_boxes_3d.py
├── camera_calib.py
├── depth.py
├── disparity.py
├── flow.py
├── frame.py
├── io
│ ├── __init__.py
│ ├── depth.py
│ ├── disparity.py
│ ├── flow.py
│ ├── image.py
│ ├── mask.py
│ └── utils
│ │ ├── __init__.py
│ │ └── errors.py
├── labels.py
├── mask.py
├── matched_indices.py
├── oriented_boxes_2d.py
├── points_2d.py
├── points_3d.py
├── pose.py
├── renderer
│ ├── __init__.py
│ ├── bbox3d.py
│ └── renderer.py
├── scene_flow.py
├── tensors
│ ├── __init__.py
│ ├── augmented_tensor.py
│ └── spatial_augmented_tensor.py
└── utils
│ ├── __init__.py
│ ├── data_utils.py
│ ├── depth_utils.py
│ ├── flow_utils.py
│ ├── math_utils.py
│ └── rotated_iou
│ ├── README.md
│ ├── _test_box_intersection_2d.py
│ ├── _test_corner_cases.py
│ ├── box_intersection_2d.py
│ ├── cuda_op
│ ├── build
│ │ ├── lib.linux-x86_64-3.8
│ │ │ └── sort_vertices.cpython-38-x86_64-linux-gnu.so
│ │ └── temp.linux-x86_64-3.8
│ │ │ ├── .ninja_deps
│ │ │ ├── .ninja_log
│ │ │ ├── build.ninja
│ │ │ ├── sort_vert.o
│ │ │ └── sort_vert_kernel.o
│ ├── cuda_ext.py
│ ├── cuda_utils.h
│ ├── dist
│ │ └── sort_vertices-0.0.0-py3.8-linux-x86_64.egg
│ ├── make.sh
│ ├── setup.py
│ ├── sort_vert.cpp
│ ├── sort_vert.h
│ ├── sort_vert_kernel.cu
│ ├── sort_vertices.egg-info
│ │ ├── PKG-INFO
│ │ ├── SOURCES.txt
│ │ ├── dependency_links.txt
│ │ └── top_level.txt
│ └── utils.h
│ ├── demo.py
│ ├── min_enclosing_box.py
│ ├── oriented_iou_loss.py
│ └── utiles.py
├── dev_requirements.txt
├── docs
├── .buildinfo
├── .nojekyll
├── _images
│ ├── aloception.png
│ ├── aloscene_notebooks_bounding_boxes_3d_11_0.png
│ ├── aloscene_notebooks_bounding_boxes_3d_16_0.png
│ ├── aloscene_notebooks_bounding_boxes_3d_17_0.png
│ ├── aloscene_notebooks_bounding_boxes_3d_9_0.png
│ ├── disp_hflip.jpg
│ ├── disp_view.jpg
│ ├── flow_hflip.jpg
│ ├── flow_view.jpg
│ ├── getting_started_alodataset_10_0.png
│ ├── getting_started_alodataset_14_1.png
│ ├── getting_started_alodataset_3_0.png
│ ├── getting_started_alodataset_3_1.png
│ ├── getting_started_alodataset_3_2.png
│ ├── getting_started_alodataset_7_0.png
│ ├── getting_started_aloscene_11_0.png
│ ├── getting_started_aloscene_19_0.png
│ ├── getting_started_aloscene_21_0.png
│ ├── getting_started_aloscene_23_0.png
│ ├── getting_started_aloscene_2_0.png
│ ├── getting_started_augmented_tensor_10_0.png
│ ├── getting_started_augmented_tensor_14_0.png
│ ├── getting_started_augmented_tensor_19_0.png
│ ├── getting_started_augmented_tensor_1_0.png
│ ├── getting_started_augmented_tensor_21_0.png
│ ├── getting_started_augmented_tensor_24_0.png
│ ├── getting_started_augmented_tensor_30_0.png
│ ├── getting_started_augmented_tensor_7_1.png
│ ├── panoptic_head.png
│ └── points2d_header.png
├── _sources
│ ├── alodataset
│ │ ├── alodataset.rst.txt
│ │ ├── base_dataset.rst.txt
│ │ ├── chairssdhom_dataset.rst.txt
│ │ ├── coco_detection_dataset.rst.txt
│ │ ├── crowd_human_dataset.rst.txt
│ │ ├── flying_chairs2_dataset.rst.txt
│ │ ├── flyingthings3D_subset_dataset.rst.txt
│ │ ├── merge_dataset.rst.txt
│ │ ├── mot17.rst.txt
│ │ ├── sintel_disparity_dataset.rst.txt
│ │ ├── sintel_flow_dataset.rst.txt
│ │ ├── sintel_multi_dataset.rst.txt
│ │ ├── transform.rst.txt
│ │ └── waymo_dataset.rst.txt
│ ├── alonet
│ │ ├── alonet.callbacks.rst.txt
│ │ ├── alonet.metrics.rst.txt
│ │ ├── alonet.rst.txt
│ │ ├── alonet.transformers.rst.txt
│ │ ├── deformable.rst.txt
│ │ ├── deformable_architecture.rst.txt
│ │ ├── deformable_models.rst.txt
│ │ ├── deformable_training.rst.txt
│ │ ├── detr.rst.txt
│ │ ├── detr_architecture.rst.txt
│ │ ├── detr_connectors.rst.txt
│ │ ├── detr_models.rst.txt
│ │ ├── detr_training.rst.txt
│ │ ├── panoptic.rst.txt
│ │ ├── panoptic_models.rst.txt
│ │ └── panoptic_training.rst.txt
│ ├── aloscene
│ │ ├── aloscene.rst.txt
│ │ ├── augmented_tensor.rst.txt
│ │ ├── bounding_boxes_2d.rst.txt
│ │ ├── bounding_boxes_3d.rst.txt
│ │ ├── camera_calib.rst.txt
│ │ ├── disparity.rst.txt
│ │ ├── flow.rst.txt
│ │ ├── frame.rst.txt
│ │ ├── labels.rst.txt
│ │ ├── mask.rst.txt
│ │ ├── notebooks
│ │ │ └── bounding_boxes_3d.ipynb.txt
│ │ ├── oriented_boxes_2d.rst.txt
│ │ ├── points2d.rst.txt
│ │ └── spatial_augmented_tensor.rst.txt
│ ├── getting_started
│ │ ├── alodataset.ipynb.txt
│ │ ├── alodataset.rst.txt
│ │ ├── alonet.ipynb.txt
│ │ ├── alonet.rst.txt
│ │ ├── aloscene.ipynb.txt
│ │ ├── augmented_tensor.ipynb.txt
│ │ ├── augmented_tensor.rst.txt
│ │ └── getting_started.rst.txt
│ ├── index.rst.txt
│ └── tutorials
│ │ ├── data_setup.rst.txt
│ │ ├── export_tensorrt
│ │ ├── Tutorial - Export DETR to TensorRT and inference.ipynb.txt
│ │ └── Tutorial - Export Deformable DETR to TensorRT and inference.ipynb.txt
│ │ ├── finetuning_deformable_detr.ipynb.txt
│ │ ├── finetuning_detr.ipynb.txt
│ │ ├── tensort_inference.rst.txt
│ │ ├── training_deformable_detr.ipynb.txt
│ │ ├── training_detr.ipynb.txt
│ │ ├── training_panoptic.ipynb.txt
│ │ └── training_raft.rst.txt
├── _static
│ ├── basic.css
│ ├── css
│ │ ├── badge_only.css
│ │ ├── fonts
│ │ │ ├── Roboto-Slab-Bold.woff
│ │ │ ├── Roboto-Slab-Bold.woff2
│ │ │ ├── Roboto-Slab-Regular.woff
│ │ │ ├── Roboto-Slab-Regular.woff2
│ │ │ ├── fontawesome-webfont.eot
│ │ │ ├── fontawesome-webfont.svg
│ │ │ ├── fontawesome-webfont.ttf
│ │ │ ├── fontawesome-webfont.woff
│ │ │ ├── fontawesome-webfont.woff2
│ │ │ ├── lato-bold-italic.woff
│ │ │ ├── lato-bold-italic.woff2
│ │ │ ├── lato-bold.woff
│ │ │ ├── lato-bold.woff2
│ │ │ ├── lato-normal-italic.woff
│ │ │ ├── lato-normal-italic.woff2
│ │ │ ├── lato-normal.woff
│ │ │ └── lato-normal.woff2
│ │ └── theme.css
│ ├── doctools.js
│ ├── documentation_options.js
│ ├── file.png
│ ├── fonts
│ │ ├── Inconsolata-Bold.ttf
│ │ ├── Inconsolata-Regular.ttf
│ │ ├── Inconsolata.ttf
│ │ ├── Lato-Bold.ttf
│ │ ├── Lato-Regular.ttf
│ │ ├── Lato
│ │ │ ├── lato-bold.eot
│ │ │ ├── lato-bold.ttf
│ │ │ ├── lato-bold.woff
│ │ │ ├── lato-bold.woff2
│ │ │ ├── lato-bolditalic.eot
│ │ │ ├── lato-bolditalic.ttf
│ │ │ ├── lato-bolditalic.woff
│ │ │ ├── lato-bolditalic.woff2
│ │ │ ├── lato-italic.eot
│ │ │ ├── lato-italic.ttf
│ │ │ ├── lato-italic.woff
│ │ │ ├── lato-italic.woff2
│ │ │ ├── lato-regular.eot
│ │ │ ├── lato-regular.ttf
│ │ │ ├── lato-regular.woff
│ │ │ └── lato-regular.woff2
│ │ ├── RobotoSlab-Bold.ttf
│ │ ├── RobotoSlab-Regular.ttf
│ │ ├── RobotoSlab
│ │ │ ├── roboto-slab-v7-bold.eot
│ │ │ ├── roboto-slab-v7-bold.ttf
│ │ │ ├── roboto-slab-v7-bold.woff
│ │ │ ├── roboto-slab-v7-bold.woff2
│ │ │ ├── roboto-slab-v7-regular.eot
│ │ │ ├── roboto-slab-v7-regular.ttf
│ │ │ ├── roboto-slab-v7-regular.woff
│ │ │ └── roboto-slab-v7-regular.woff2
│ │ ├── fontawesome-webfont.eot
│ │ ├── fontawesome-webfont.svg
│ │ ├── fontawesome-webfont.ttf
│ │ ├── fontawesome-webfont.woff
│ │ └── fontawesome-webfont.woff2
│ ├── jquery-3.5.1.js
│ ├── jquery.js
│ ├── js
│ │ ├── badge_only.js
│ │ ├── html5shiv-printshiv.min.js
│ │ ├── html5shiv.min.js
│ │ ├── modernizr.min.js
│ │ └── theme.js
│ ├── language_data.js
│ ├── minus.png
│ ├── plus.png
│ ├── pygments.css
│ ├── searchtools.js
│ ├── underscore-1.13.1.js
│ └── underscore.js
├── alodataset
│ ├── alodataset.html
│ ├── base_dataset.html
│ ├── chairssdhom_dataset.html
│ ├── coco_detection_dataset.html
│ ├── crowd_human_dataset.html
│ ├── flying_chairs2_dataset.html
│ ├── flyingthings3D_subset_dataset.html
│ ├── merge_dataset.html
│ ├── mot17.html
│ ├── sintel_disparity_dataset.html
│ ├── sintel_flow_dataset.html
│ ├── sintel_multi_dataset.html
│ ├── transform.html
│ └── waymo_dataset.html
├── alonet
│ ├── alonet.callbacks.html
│ ├── alonet.html
│ ├── alonet.metrics.html
│ ├── alonet.transformers.html
│ ├── deformable.html
│ ├── deformable_architecture.html
│ ├── deformable_models.html
│ ├── deformable_training.html
│ ├── detr.html
│ ├── detr_architecture.html
│ ├── detr_connectors.html
│ ├── detr_models.html
│ ├── detr_training.html
│ ├── panoptic.html
│ ├── panoptic_models.html
│ └── panoptic_training.html
├── aloscene
│ ├── aloscene.html
│ ├── augmented_tensor.html
│ ├── bounding_boxes_2d.html
│ ├── bounding_boxes_3d.html
│ ├── camera_calib.html
│ ├── disparity.html
│ ├── flow.html
│ ├── frame.html
│ ├── labels.html
│ ├── mask.html
│ ├── notebooks
│ │ ├── bounding_boxes_3d.html
│ │ └── bounding_boxes_3d.ipynb
│ ├── oriented_boxes_2d.html
│ ├── points2d.html
│ └── spatial_augmented_tensor.html
├── genindex.html
├── getting_started
│ ├── alodataset.html
│ ├── alodataset.ipynb
│ ├── alonet.html
│ ├── alonet.ipynb
│ ├── aloscene.html
│ ├── aloscene.ipynb
│ ├── augmented_tensor.html
│ ├── augmented_tensor.ipynb
│ └── getting_started.html
├── index.html
├── objects.inv
├── py-modindex.html
├── search.html
├── searchindex.js
└── tutorials
│ ├── data_setup.html
│ ├── export_tensorrt
│ ├── Tutorial - Export DETR to TensorRT and inference.html
│ ├── Tutorial - Export DETR to TensorRT and inference.ipynb
│ ├── Tutorial - Export Deformable DETR to TensorRT and inference.html
│ └── Tutorial - Export Deformable DETR to TensorRT and inference.ipynb
│ ├── finetuning_deformable_detr.html
│ ├── finetuning_deformable_detr.ipynb
│ ├── finetuning_detr.html
│ ├── finetuning_detr.ipynb
│ ├── tensort_inference.html
│ ├── training_deformable_detr.html
│ ├── training_deformable_detr.ipynb
│ ├── training_detr.html
│ ├── training_detr.ipynb
│ ├── training_panoptic.html
│ ├── training_panoptic.ipynb
│ └── training_raft.html
├── docsource
├── Makefile
├── README.md
├── make.bat
├── requirements.txt
└── source
│ ├── alodataset
│ ├── alodataset.rst
│ ├── base_dataset.rst
│ ├── chairssdhom_dataset.rst
│ ├── coco_detection_dataset.rst
│ ├── coco_panoptic_dataset.rst
│ ├── crowd_human_dataset.rst
│ ├── flying_chairs2_dataset.rst
│ ├── flyingthings3D_subset_dataset.rst
│ ├── merge_dataset.rst
│ ├── mot17.rst
│ ├── sintel_disparity_dataset.rst
│ ├── sintel_flow_dataset.rst
│ ├── sintel_multi_dataset.rst
│ ├── transform.rst
│ └── waymo_dataset.rst
│ ├── alonet
│ ├── alonet.callbacks.rst
│ ├── alonet.metrics.rst
│ ├── alonet.rst
│ ├── alonet.transformers.rst
│ ├── deformable.rst
│ ├── deformable_architecture.rst
│ ├── deformable_models.rst
│ ├── deformable_training.rst
│ ├── detr.rst
│ ├── detr_architecture.rst
│ ├── detr_connectors.rst
│ ├── detr_models.rst
│ ├── detr_training.rst
│ ├── panoptic.rst
│ ├── panoptic_models.rst
│ └── panoptic_training.rst
│ ├── aloscene
│ ├── aloscene.rst
│ ├── augmented_tensor.rst
│ ├── bounding_boxes_2d.rst
│ ├── bounding_boxes_3d.rst
│ ├── camera_calib.rst
│ ├── disparity.rst
│ ├── flow.rst
│ ├── frame.rst
│ ├── labels.rst
│ ├── mask.rst
│ ├── notebooks
│ │ └── bounding_boxes_3d.ipynb
│ ├── oriented_boxes_2d.rst
│ ├── points2d.rst
│ └── spatial_augmented_tensor.rst
│ ├── conf.py
│ ├── getting_started
│ ├── alodataset.ipynb
│ ├── alonet.ipynb
│ ├── aloscene.ipynb
│ ├── augmented_tensor.ipynb
│ └── getting_started.rst
│ ├── images
│ ├── aloception.png
│ ├── boxes_header.png
│ ├── disp_hflip.jpg
│ ├── disp_view.jpg
│ ├── flow_hflip.jpg
│ ├── flow_view.jpg
│ ├── mask_types.png
│ ├── panoptic_head.png
│ └── points2d_header.png
│ ├── index.rst
│ └── tutorials
│ ├── data_setup.rst
│ ├── export_tensorrt
│ ├── Tutorial - Export DETR to TensorRT and inference.ipynb
│ └── Tutorial - Export Deformable DETR to TensorRT and inference.ipynb
│ ├── finetuning_deformable_detr.ipynb
│ ├── finetuning_detr.ipynb
│ ├── tensort_inference.rst
│ ├── training_deformable_detr.ipynb
│ ├── training_detr.ipynb
│ └── training_panoptic.ipynb
├── entrypoint.sh
├── images
└── aloception-oss.jpg
├── requirements
└── requirements-torch1.13.1.txt
├── setup.py
├── tutorials
├── 1-hello_world.py
├── 2-frame.py
├── 2.1-frame.py
├── 2.2-frame.py
├── 2.3-frame.py
├── 3-boxes.py
├── 3.1-boxes.py
├── 4.0-rendering.py
├── 4.1-sequence.py
├── 4.2-custom_get_view.py
├── 4.3-get_view_flow.py
├── 5.1-detrmod_coco_.py
├── 5.2-detrmod_lit_.py
├── 5.3-train_on_coco.py
├── 5.4-eval_on_coco.py
├── 5.5-custom_datamod.py
├── 5.6-custom_detrmod.py
└── develop.md
└── unittest
├── test_augmented_tensor.py
├── test_boxes.py
├── test_boxes_3d.py
├── test_disparity.py
├── test_flow.py
├── test_frame.py
├── test_oriented_boxes_2d.py
├── test_points2d.py
├── test_projections.py
├── test_train.py
└── test_transformation.py
/.github/pull_request_template.md:
--------------------------------------------------------------------------------
1 | General description of your pull request with the list of new features and/or bugs.
2 |
3 | * ***New feature 1*** : Description
4 | ```python
5 | # Python code snippet showing how to use it.
6 | ```
7 |
8 | * ***New feature 2*** : Description
9 | ```python
10 | # Python code snippet showing how to use it.
11 | ```
12 |
13 | * ***Fix bug X*** : Description
14 |
15 | _____
16 | This pull request includes
17 |
18 | - [ ] Bug fix (non-breaking change which fixes an issue)
19 | - [ ] New feature (non-breaking change which adds functionality)
20 | - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected)
21 | - [ ] This change requires a documentation update
22 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.pyc
2 | lightning_logs/*
3 | .vscode
4 | images/test.jpeg
5 | aloscene/utils/oriented_iou/data
6 | wandb/*
7 | *.log
8 | *.onnx
9 | checkpoints/*
10 | aloscene/utils/rotated_iou/data
11 | tensorboard/*
12 | **/.ipynb_checkpoints
13 | *_Tutorial*
14 | workspace.code-workspace
15 | _sandbox/
16 | logs/*
17 | *.mar
18 | *.pt
19 |
20 | # Distribution / packaging
21 | .Python
22 | build/
23 | develop-eggs/
24 | dist/
25 | downloads/
26 | eggs/
27 | .eggs/
28 | lib/
29 | lib64/
30 | parts/
31 | sdist/
32 | var/
33 | wheels/
34 | pip-wheel-metadata/
35 | share/python-wheels/
36 | *.egg-info/
37 | .installed.cfg
38 | *.egg
39 | MANIFEST
40 |
--------------------------------------------------------------------------------
/DEVELOPMENT.md:
--------------------------------------------------------------------------------
1 | # Aloception - Development
2 |
3 | ## Building the documentation
4 |
5 | See docs/README.md
6 |
7 | ## Useful extension
8 | - [Python Docstring Generator](https://marketplace.visualstudio.com/items?itemName=njpwerner.autodocstring). In setting, change the format to `numpy`
9 |
10 | ## Unit test
11 |
12 | ```
13 | python -m pytest
14 | ```
15 |
16 | NOTE: You might want to use only one GPU to run the tests (Multi-GPU is gonna be used insteads to test the training pipelines.)
17 |
18 |
19 | ## Contributing
20 |
21 | Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are **greatly appreciated**.
22 |
23 | See the [open issues](https://gitlab.com/aigen-vision/aloception/issues) for a list of proposed features (and known issues).
24 |
25 | ..TODO..
26 |
27 | ## Submitting & merging merge request
28 |
29 | - Ideally, all merge request should be linked with a specific issue.
30 | - If the merge request is linked with an issue, the name should be as follow: #issueID-name-of-mg with the list of Issue to automatically close once the merge request is merged:
31 | (closes #1, closes#2)
32 | - A merge request must include the list of all changes & added features.
33 | - The reviewer is added only once the merge request is ready to be merged.
34 | Once the reviewer finished reviewing the merge request is `approved` or not `approved` (using the approved button) along with a review. Then, the reviewer should remove itself from the merge request.
35 | If `approved` : the MR can be merge.
36 | Otherwise : All thread of the review must be resolved before adding back a reviewer on the MR.
37 | ## License
38 |
39 | TODO
40 |
--------------------------------------------------------------------------------
/alodataset/__init__.py:
--------------------------------------------------------------------------------
1 | from . import utils
2 | from . import prepare
3 | from .base_dataset import BaseDataset, Split
4 | from .sequence_mixin import SequenceMixin
5 | from .split_mixin import SplitMixin
6 | from .waymo_dataset import WaymoDataset
7 | from .coco_base_dataset import CocoBaseDataset
8 | from .coco_detection_dataset import CocoDetectionDataset
9 | from .coco_panoptic_dataset import CocoPanopticDataset
10 | from .chairssdhom_dataset import ChairsSDHomDataset
11 | from .flyingthings3D_subset_dataset import FlyingThings3DSubsetDataset
12 | from .mot17 import Mot17
13 | from .flying_chairs2_dataset import FlyingChairs2Dataset
14 | from .merge_dataset import MergeDataset
15 | from .crowd_human_dataset import CrowdHumanDataset
16 | from .sintel_flow_dataset import SintelFlowDataset
17 | from .sintel_disparity_dataset import SintelDisparityDataset
18 | from .sintel_multi_dataset import SintelMultiDataset
19 | from .from_directory_dataset import FromDirectoryDataset
20 | from .woodScape_dataset import WooodScapeDataset
21 | from .woodScape_split_dataset import WoodScapeSplitDataset
22 |
23 | import pkg_resources
24 | __version__ = pkg_resources.get_distribution("aloception").version
25 |
--------------------------------------------------------------------------------
/alodataset/io/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/alodataset/io/__init__.py
--------------------------------------------------------------------------------
/alodataset/io/fs.py:
--------------------------------------------------------------------------------
1 | """ File system utils methods
2 | """
3 | import os
4 | from shutil import copyfile, move
5 |
6 |
7 | def move_and_replace(src_dir_path: str, tgt_dir_path: str):
8 | """This method will copy the full `src_dir_path` into an other
9 | `tgt_dir_path`. If some file already exists in the target dir, this
10 | method will compare both file and replace the target file if the
11 | src file and tgt file do not match.
12 |
13 | Parameters
14 | ----------
15 | src_dir_path : str
16 | Source directory
17 | tgt_dir_path : str
18 | Target directory
19 | """
20 | # Merge the WIP directory with the target dir
21 | for src_dir, dirs, files in os.walk(src_dir_path):
22 | dst_dir = src_dir.replace(src_dir_path, tgt_dir_path, 1)
23 | if not os.path.exists(dst_dir):
24 | os.makedirs(dst_dir)
25 | for file_ in files:
26 | src_file = os.path.join(src_dir, file_)
27 | dst_file = os.path.join(dst_dir, file_)
28 | if os.path.exists(dst_file):
29 | if os.path.samefile(src_file, dst_file):
30 | continue
31 | os.remove(dst_file)
32 | move(src_file, dst_file)
33 |
--------------------------------------------------------------------------------
/alodataset/kitti_split_dataset.py:
--------------------------------------------------------------------------------
1 | import torch
2 | import numpy as np
3 | from typing import Dict, List
4 | from aloscene import Frame, Mask
5 | from alodataset import Split, SplitMixin
6 | from alodataset.kitti_depth import KittiBaseDataset
7 |
8 |
9 | class KittiSplitDataset(KittiBaseDataset, SplitMixin):
10 | SPLIT_FOLDERS = {Split.VAL: "val", Split.TRAIN: "train"}
11 |
12 | def __init__(
13 | self,
14 | split=Split.TRAIN,
15 | add_depth_mask: bool = True,
16 | custom_drives: Dict[str, List[str]] = None,
17 | main_folder: str = 'image_02',
18 | name: str='kitti',
19 | **kwargs
20 | ):
21 |
22 | self.split = split
23 | self.add_depth_mask = add_depth_mask
24 | super().__init__(
25 | subsets=self.get_split_folder(),
26 | name=name,
27 | custom_drives=custom_drives,
28 | main_folder=main_folder,
29 | return_depth=True,
30 | **kwargs)
31 |
32 |
33 | def getitem(self, idx):
34 | frame = super().getitem(idx)
35 | if self.add_depth_mask:
36 | mask = Mask((frame.depth.as_tensor() != 0).type(torch.float), names=frame.depth.names)
37 | frame.depth.add_child("valid_mask", mask, align_dim=["B", "T"], mergeable=True)
38 | return frame
39 |
--------------------------------------------------------------------------------
/alodataset/prepare/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/alodataset/prepare/__init__.py
--------------------------------------------------------------------------------
/alodataset/prepare/waymo-requirements.txt:
--------------------------------------------------------------------------------
1 | waymo-open-dataset-tf-2-4-0
2 | tqdm
--------------------------------------------------------------------------------
/alodataset/prepare/waymo_prepare.py:
--------------------------------------------------------------------------------
1 | from alodataset import WaymoDataset, Split
2 |
3 | waymo_dataset = WaymoDataset()
4 | waymo_dataset.prepare()
5 | print("prepared dataset directory:", waymo_dataset.dataset_dir)
--------------------------------------------------------------------------------
/alodataset/sequence_mixin.py:
--------------------------------------------------------------------------------
1 | class SequenceMixin(object):
2 | def __init__(self, sequence_size: int = 1, sequence_skip: int = 0, **kwargs):
3 | """Sequence Mixin
4 | Parameters
5 | ----------
6 | sequence_size: int
7 | Size of sequence to load
8 | sequence_skip: int
9 | Number of frame to skip between each element of the sequence
10 | """
11 |
12 | super(SequenceMixin, self).__init__(**kwargs)
13 |
14 | self.sequence_size = sequence_size
15 | self.sequence_skip = sequence_skip
16 |
--------------------------------------------------------------------------------
/alodataset/split_mixin.py:
--------------------------------------------------------------------------------
1 | from alodataset import Split
2 |
3 |
4 | class SplitMixin(object):
5 |
6 | SPLIT_FOLDERS = {}
7 |
8 | def __init__(self, split: Split = Split.TRAIN, **kwargs):
9 | """Sequence Mixin
10 | Parameters
11 | ----------
12 | split: alodataset.Split
13 | Split.TRAIN by default.
14 | """
15 | super(SplitMixin, self).__init__(**kwargs)
16 |
17 | assert isinstance(split, Split)
18 |
19 | self.split = split
20 |
21 | def get_split_folder(self):
22 | assert self.split in self.SPLIT_FOLDERS
23 | return self.SPLIT_FOLDERS[self.split]
24 |
--------------------------------------------------------------------------------
/alodataset/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/alodataset/utils/__init__.py
--------------------------------------------------------------------------------
/alodataset/woodScape_split_dataset.py:
--------------------------------------------------------------------------------
1 | from alodataset import Split, SplitMixin, WooodScapeDataset
2 |
3 |
4 | class WoodScapeSplitDataset(WooodScapeDataset, SplitMixin):
5 | SPLIT_FOLDERS = {Split.VAL: -0.1, Split.TRAIN: 0.9}
6 |
7 | def __init__(
8 | self,
9 | split=Split.TRAIN,
10 | **kwargs
11 | ):
12 | self.split = split
13 | super().__init__(fragment=self.get_split_folder(), **kwargs)
14 |
15 |
16 | if __name__ == "__main__":
17 | val = WoodScapeSplitDataset(split=Split.VAL)
18 | train = WoodScapeSplitDataset(split=Split.TRAIN)
19 |
20 | print("val :", len(val))
21 | print("train :", len(train))
22 |
--------------------------------------------------------------------------------
/alonet/__init__.py:
--------------------------------------------------------------------------------
1 | ALONET_ROOT = "/".join(__file__.split("/")[:-1])
2 | from . import metrics
3 | from . import common
4 | from . import detr
5 | from . import transformers
6 | from . import raft
7 |
8 | from . import deformable_detr
9 | from . import callbacks
10 |
11 | from . import detr_panoptic
12 | from . import deformable_detr_panoptic
13 |
14 | import pkg_resources
15 | __version__ = pkg_resources.get_distribution("aloception").version
16 |
--------------------------------------------------------------------------------
/alonet/callbacks/__init__.py:
--------------------------------------------------------------------------------
1 | from .object_detector_callback import ObjectDetectorCallback
2 | from .metrics_callback import MetricsCallback
3 | from .base_metrics_callback import InstancesBaseMetricsCallback
4 | from .map_metrics_callback import ApMetricsCallback
5 | from .pq_metrics_callback import PQMetricsCallback
6 |
--------------------------------------------------------------------------------
/alonet/callbacks/pq_metrics_callback.py:
--------------------------------------------------------------------------------
1 | """Callback that stores samples in each step to calculate the different Panoptic Quality metrics
2 |
3 | See Also
4 | --------
5 | :mod:`PQMetrics `, the specific metric implement in this callback
6 | """
7 | import matplotlib.pyplot as plt
8 | from pytorch_lightning.utilities import rank_zero_only
9 | from alonet.common.logger import log_figure, log_scalar
10 |
11 | from alonet.metrics import PQMetrics
12 | from alonet.callbacks import InstancesBaseMetricsCallback
13 |
14 |
15 | class PQMetricsCallback(InstancesBaseMetricsCallback):
16 | def __init__(self, *args, **kwargs):
17 | super().__init__(*args, base_metric=PQMetrics, **kwargs)
18 |
19 | @rank_zero_only
20 | def on_validation_end(self, trainer, pl_module):
21 | if trainer.logger is None:
22 | return
23 |
24 | for t, pq_metrics in enumerate(self.metrics):
25 |
26 | prefix = f"val/{t}/" if len(self.metrics) > 1 else "val/"
27 | all_maps, all_maps_per_class = pq_metrics.calc_map(print_result=False)
28 |
29 | log_scalar(trainer, f"{prefix}PQ", all_maps["all"]["pq"])
30 | log_scalar(trainer, f"{prefix}SQ", all_maps["all"]["sq"])
31 | log_scalar(trainer, f"{prefix}RQ", all_maps["all"]["rq"])
32 |
33 | # Bar per each PQ class
34 | plt.style.use("ggplot")
35 | for cat in ["thing", "stuff"] if len(all_maps_per_class) > 1 else ["all"]:
36 | x_set, y_set = zip(*all_maps_per_class[cat].items())
37 | y_set = [y["pq"] for y in y_set]
38 |
39 | _, ax = plt.subplots()
40 | ax.barh(x_set, y_set)
41 | ax.set_xlabel("Panoptic Quality metric")
42 | ax.set_ylabel("Category")
43 | ax.set_title("PQ metric per category")
44 | log_figure(trainer, f"{prefix}pq_{cat}_per_class", plt.gcf())
45 | plt.clf()
46 | plt.cla()
47 |
48 | self.metrics = []
49 |
--------------------------------------------------------------------------------
/alonet/common/__init__.py:
--------------------------------------------------------------------------------
1 | from .weights import load_weights
2 | from .pl_helpers import run_pl_training, add_argparse_args, load_training
3 |
--------------------------------------------------------------------------------
/alonet/common/abstract_classes.py:
--------------------------------------------------------------------------------
1 | """
2 | Inspired by https://stackoverflow.com/a/50381071/14647356
3 |
4 | Tools to create abstract classes
5 | """
6 |
7 |
8 | class AbstractAttribute:
9 | pass
10 |
11 |
12 | def abstract_attribute(obj=None):
13 | if obj is None:
14 | obj = AbstractAttribute()
15 | obj.__is_abstract_attribute__ = True
16 | return obj
17 |
18 |
19 | def check_abstract_attribute_instanciation(cls):
20 | abstract_attributes = {
21 | name for name in dir(cls) if getattr(getattr(cls, name), "__is_abstract_attribute__", False)
22 | }
23 | if abstract_attributes:
24 | raise NotImplementedError(
25 | f"Can't instantiate abstract class {type(cls).__name__}."
26 | f"The following abstract attributes shoud be instanciated: {', '.join(abstract_attributes)}"
27 | )
28 |
29 |
30 | def super_new(abstract_cls, cls, *args, **kwargs):
31 | __new__ = super(abstract_cls, cls).__new__
32 | if __new__ is object.__new__:
33 | return __new__(cls)
34 | else:
35 | return __new__(cls, *args, **kwargs)
36 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/__init__.py:
--------------------------------------------------------------------------------
1 | from .deformable_detr import DeformableDETR
2 | from .deformable_detr_r50 import DeformableDetrR50
3 | from .deformable_detr_r50_refinement import DeformableDetrR50Refinement
4 | from .deformable_detr_r50_finetune import DeformableDetrR50Finetune, DeformableDetrR50RefinementFinetune
5 | from .matcher import DeformableDetrHungarianMatcher
6 | from .criterion import DeformableCriterion
7 | from .train import LitDeformableDetr
8 | from .deformable_transformer import DeformableTransformerDecoder, DeformableTransformerDecoderLayer
9 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/callbacks.py:
--------------------------------------------------------------------------------
1 | """Callbacks for Deformable DETR training is the same as DETR training
2 | """
--------------------------------------------------------------------------------
/alonet/deformable_detr/deformable_detr_r50.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import torch
3 |
4 | import alonet
5 | from alonet.deformable_detr import DeformableDETR
6 | from alonet.deformable_detr.backbone import Joiner
7 | import aloscene
8 |
9 |
10 | class DeformableDetrR50(DeformableDETR):
11 | """Deformable Detr with Resnet50 backbone"""
12 |
13 | def __init__(self, *args, return_intermediate_dec: bool = True, num_classes=91, **kwargs):
14 | backbone = self.build_backbone(
15 | backbone_name="resnet50", train_backbone=True, return_interm_layers=True, dilation=False
16 | )
17 | position_embed = self.build_positional_encoding(hidden_dim=256)
18 | backbone = Joiner(backbone, position_embed)
19 | transformer = self.build_transformer(
20 | hidden_dim=256,
21 | dropout=0.1,
22 | nheads=8,
23 | dim_feedforward=1024,
24 | enc_layers=6,
25 | dec_layers=6,
26 | num_feature_levels=4,
27 | dec_n_points=4,
28 | enc_n_points=4,
29 | return_intermediate_dec=return_intermediate_dec,
30 | )
31 |
32 | super().__init__(backbone, transformer, *args, num_classes=num_classes, with_box_refine=False, **kwargs)
33 |
34 |
35 | if __name__ == "__main__":
36 | from alonet.deformable_detr import DeformableDetrR50
37 |
38 | # For testing
39 | device = torch.device("cuda")
40 | parser = argparse.ArgumentParser(description="Detr R50 inference on image")
41 | parser.add_argument("image_path", type=str, help="Path to the image for inference")
42 | args = parser.parse_args()
43 |
44 | model = DeformableDetrR50(weights="deformable-detr-r50").eval()
45 |
46 | image_path = args.image_path
47 | frame = aloscene.Frame(image_path).norm_resnet()
48 | frames = aloscene.Frame.batch_list([frame])
49 | frames = frames.to(device)
50 |
51 | m_outputs = model(frames)
52 | pred_boxes = model.inference(m_outputs)
53 | # Add and display the predicted boxes
54 | frame.append_boxes2d(pred_boxes[0], "pred_boxes")
55 | frame.get_view([frame.boxes2d]).render()
56 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/deformable_detr_r50_refinement.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | import torch
3 |
4 | import alonet
5 | from alonet.deformable_detr import DeformableDETR
6 | from alonet.deformable_detr.backbone import Joiner
7 | import aloscene
8 |
9 |
10 | class DeformableDetrR50Refinement(DeformableDETR):
11 | """Deformable Detr with Resnet50 backbone with box refinement"""
12 |
13 | def __init__(self, *args, return_intermediate_dec: bool = True, num_classes=91, **kwargs):
14 | backbone = self.build_backbone(
15 | backbone_name="resnet50", train_backbone=True, return_interm_layers=True, dilation=False
16 | )
17 | position_embed = self.build_positional_encoding(hidden_dim=256)
18 | backbone = Joiner(backbone, position_embed)
19 | transformer = self.build_transformer(
20 | hidden_dim=256,
21 | dropout=0.1,
22 | nheads=8,
23 | dim_feedforward=1024,
24 | enc_layers=6,
25 | dec_layers=6,
26 | num_feature_levels=4,
27 | dec_n_points=4,
28 | enc_n_points=4,
29 | return_intermediate_dec=return_intermediate_dec,
30 | )
31 |
32 | super().__init__(backbone, transformer, *args, num_classes=num_classes, with_box_refine=True, **kwargs)
33 |
34 |
35 | if __name__ == "__main__":
36 | from alonet.deformable_detr import DeformableDetrR50Refinement
37 |
38 | # For testing
39 | device = torch.device("cuda")
40 | parser = argparse.ArgumentParser(description="Detr R50 inference on image")
41 | parser.add_argument("image_path", type=str, help="Path to the image for inference")
42 | args = parser.parse_args()
43 |
44 | model = DeformableDetrR50Refinement(weights="deformable-detr-r50-refinement").eval()
45 |
46 | image_path = args.image_path
47 | frame = aloscene.Frame(image_path).norm_resnet()
48 | frames = aloscene.Frame.batch_list([frame])
49 | frames = frames.to(device)
50 |
51 | m_outputs = model(frames)
52 | pred_boxes = model.inference(m_outputs)
53 | # Add and display the predicted boxes
54 | frame.append_boxes2d(pred_boxes[0], "pred_boxes")
55 | frame.get_view([frame.boxes2d]).render()
56 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/eval_on_coco.py:
--------------------------------------------------------------------------------
1 | import os
2 | import torch
3 | from torch import nn
4 | import torch.nn.functional as F
5 |
6 | from argparse import ArgumentParser
7 |
8 | import pytorch_lightning as pl
9 | import wandb
10 |
11 | from typing import *
12 |
13 | from alonet.detr import CocoDetection2Detr
14 | from alonet.deformable_detr import LitDeformableDetr
15 |
16 | import aloscene
17 | import alonet
18 |
19 |
20 | def main():
21 | """Main"""
22 | device = torch.device("cuda")
23 |
24 | # Build parser
25 | parser = ArgumentParser(conflict_handler="resolve")
26 | parser = alonet.common.add_argparse_args(parser) # Common alonet parser
27 | parser = CocoDetection2Detr.add_argparse_args(parser) # Coco detection parser
28 | parser = LitDeformableDetr.add_argparse_args(parser) # LitDetr training parser
29 |
30 | parser.add_argument(
31 | "--ap_limit", type=int, default=None, help="Limit AP computation at the given number of sample"
32 | )
33 |
34 | args = parser.parse_args() # Parse
35 |
36 | # Init the Detr model with the dataset
37 | model = LitDeformableDetr(args)
38 | args.batch_size = 1
39 | coco_loader = CocoDetection2Detr(args)
40 |
41 | model = model.to(device)
42 | model.model.eval()
43 |
44 | ap_metrics = alonet.metrics.ApMetrics()
45 |
46 | for it, data in enumerate(coco_loader.val_dataloader(sampler=torch.utils.data.SequentialSampler)):
47 | frame = aloscene.Frame.batch_list(data)
48 | frame = frame.to(device)
49 |
50 | pred_boxes = model.inference(model(frame))[0]
51 | gt_boxes = frame.boxes2d[0]
52 |
53 | ap_metrics.add_sample(pred_boxes, gt_boxes)
54 |
55 | print(f"it:{it}", end="\r")
56 | if args.ap_limit is not None and it > args.ap_limit:
57 | break
58 |
59 | print("Total eval batch:", it)
60 | ap_metrics.calc_map(print_result=True)
61 |
62 |
63 | if __name__ == "__main__":
64 | main()
65 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/matcher.py:
--------------------------------------------------------------------------------
1 | import torch
2 | import aloscene
3 | from alonet.detr.matcher import DetrHungarianMatcher
4 |
5 |
6 | class DeformableDetrHungarianMatcher(DetrHungarianMatcher):
7 | @torch.no_grad()
8 | def hungarian_cost_class(self, tgt_boxes: aloscene.BoundingBoxes2D, m_outputs: dict, **kwargs):
9 | """
10 | Compute the cost class for the Hungarian matcher
11 |
12 | Parameters
13 | ----------
14 | m_outputs: dict
15 | Dict output of the alonet.detr.Detr model. This is a dict that contains at least these entries:
16 | - "pred_logits": Tensor of dim [batch_size, num_queries, num_classes] with the classification logits
17 | - "pred_boxes": Tensor of dim [batch_size, num_queries, 4] with the predicted box coordinates
18 |
19 | tgt_boxes: aloscene.BoundingBoxes2D
20 | Target boxes2d across the batch
21 | """
22 | out_prob = m_outputs["pred_logits"]
23 | # Retrieve the target ID for each boxes 2d
24 | tgt_ids = tgt_boxes.labels.type(torch.long).rename_(None) # [total number of target boxes in batch,]
25 |
26 | if "activation_fn" not in m_outputs:
27 | raise Exception("'activation_fn' must be declared in forward output.")
28 | if m_outputs["activation_fn"] == "softmax":
29 | out_prob = out_prob.flatten(0, 1).softmax(-1) # [batch_size * num_queries, num_classes]
30 | # Compute the classification cost. Contrary to the loss, we don't use the NLL,
31 | # but approximate it in 1 - proba[target class].
32 | # The 1 is a constant that doesn't change the matching, it can be ommitted.
33 | cost_class = -out_prob[:, tgt_ids].as_tensor() # [batch_size * num_queries, total nb of targets in batch]
34 | else:
35 | out_prob = out_prob.flatten(0, 1).sigmoid() # [batch_size * num_queries, num_classes]
36 | alpha = 0.25
37 | gamma = 2.0
38 | neg_cost_class = (1 - alpha) * (out_prob ** gamma) * (-(1 - out_prob + 1e-8).log())
39 | pos_cost_class = alpha * ((1 - out_prob) ** gamma) * (-(out_prob + 1e-8).log())
40 | cost_class = pos_cost_class[:, tgt_ids] - neg_cost_class[:, tgt_ids]
41 | cost_class = cost_class.as_tensor()
42 | return cost_class
43 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/alonet/deformable_detr/ops/__init__.py
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/functions/__init__.py:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------------------------
2 | # Deformable DETR
3 | # Copyright (c) 2020 SenseTime. All Rights Reserved.
4 | # Licensed under the Apache License, Version 2.0 [see LICENSE for details]
5 | # ------------------------------------------------------------------------------------------------
6 | # Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0
7 | # ------------------------------------------------------------------------------------------------
8 |
9 | from .ms_deform_attn_func import (
10 | MSDeformAttnFunction,
11 | ms_deform_attn_core_pytorch,
12 | load_MultiScaleDeformableAttention,
13 | load_ops,
14 | )
15 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/make.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # ------------------------------------------------------------------------------------------------
3 | # Deformable DETR
4 | # Copyright (c) 2020 SenseTime. All Rights Reserved.
5 | # Licensed under the Apache License, Version 2.0 [see LICENSE for details]
6 | # ------------------------------------------------------------------------------------------------
7 | # Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0
8 | # ------------------------------------------------------------------------------------------------
9 |
10 | ALONET_ROOT=$1
11 | cd $ALONET_ROOT/deformable_detr/ops
12 | if [ -d "./build" ]
13 | then
14 | rm -r ./build
15 | echo "build directory exists. build directory cleaned."
16 | fi
17 | python setup.py build install
18 | python test.py
19 | cd -
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/modules/__init__.py:
--------------------------------------------------------------------------------
1 | # ------------------------------------------------------------------------------------------------
2 | # Deformable DETR
3 | # Copyright (c) 2020 SenseTime. All Rights Reserved.
4 | # Licensed under the Apache License, Version 2.0 [see LICENSE for details]
5 | # ------------------------------------------------------------------------------------------------
6 | # Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0
7 | # ------------------------------------------------------------------------------------------------
8 |
9 | from .ms_deform_attn import MSDeformAttn
10 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/src/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/alonet/deformable_detr/ops/src/__init__.py
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/src/cpu/ms_deform_attn_cpu.cpp:
--------------------------------------------------------------------------------
1 | /*!
2 | **************************************************************************************************
3 | * Deformable DETR
4 | * Copyright (c) 2020 SenseTime. All Rights Reserved.
5 | * Licensed under the Apache License, Version 2.0 [see LICENSE for details]
6 | **************************************************************************************************
7 | * Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0
8 | **************************************************************************************************
9 | */
10 |
11 | #include
12 |
13 | #include
14 | #include
15 |
16 |
17 | at::Tensor
18 | ms_deform_attn_cpu_forward(
19 | const at::Tensor &value,
20 | const at::Tensor &spatial_shapes,
21 | const at::Tensor &level_start_index,
22 | const at::Tensor &sampling_loc,
23 | const at::Tensor &attn_weight,
24 | const int im2col_step)
25 | {
26 | AT_ERROR("Not implement on cpu");
27 | }
28 |
29 | std::vector
30 | ms_deform_attn_cpu_backward(
31 | const at::Tensor &value,
32 | const at::Tensor &spatial_shapes,
33 | const at::Tensor &level_start_index,
34 | const at::Tensor &sampling_loc,
35 | const at::Tensor &attn_weight,
36 | const at::Tensor &grad_output,
37 | const int im2col_step)
38 | {
39 | AT_ERROR("Not implement on cpu");
40 | }
41 |
42 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/src/cpu/ms_deform_attn_cpu.h:
--------------------------------------------------------------------------------
1 | /*!
2 | **************************************************************************************************
3 | * Deformable DETR
4 | * Copyright (c) 2020 SenseTime. All Rights Reserved.
5 | * Licensed under the Apache License, Version 2.0 [see LICENSE for details]
6 | **************************************************************************************************
7 | * Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0
8 | **************************************************************************************************
9 | */
10 |
11 | #pragma once
12 | #include
13 |
14 | at::Tensor
15 | ms_deform_attn_cpu_forward(
16 | const at::Tensor &value,
17 | const at::Tensor &spatial_shapes,
18 | const at::Tensor &level_start_index,
19 | const at::Tensor &sampling_loc,
20 | const at::Tensor &attn_weight,
21 | const int im2col_step);
22 |
23 | std::vector
24 | ms_deform_attn_cpu_backward(
25 | const at::Tensor &value,
26 | const at::Tensor &spatial_shapes,
27 | const at::Tensor &level_start_index,
28 | const at::Tensor &sampling_loc,
29 | const at::Tensor &attn_weight,
30 | const at::Tensor &grad_output,
31 | const int im2col_step);
32 |
33 |
34 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/src/cuda/ms_deform_attn_cuda.h:
--------------------------------------------------------------------------------
1 | /*!
2 | **************************************************************************************************
3 | * Deformable DETR
4 | * Copyright (c) 2020 SenseTime. All Rights Reserved.
5 | * Licensed under the Apache License, Version 2.0 [see LICENSE for details]
6 | **************************************************************************************************
7 | * Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0
8 | **************************************************************************************************
9 | */
10 |
11 | #pragma once
12 | #include
13 |
14 | at::Tensor ms_deform_attn_cuda_forward(
15 | const at::Tensor &value,
16 | const at::Tensor &spatial_shapes,
17 | const at::Tensor &level_start_index,
18 | const at::Tensor &sampling_loc,
19 | const at::Tensor &attn_weight,
20 | const int im2col_step);
21 |
22 | std::vector ms_deform_attn_cuda_backward(
23 | const at::Tensor &value,
24 | const at::Tensor &spatial_shapes,
25 | const at::Tensor &level_start_index,
26 | const at::Tensor &sampling_loc,
27 | const at::Tensor &attn_weight,
28 | const at::Tensor &grad_output,
29 | const int im2col_step);
30 |
31 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/src/ms_deform_attn.h:
--------------------------------------------------------------------------------
1 | /*!
2 | **************************************************************************************************
3 | * Deformable DETR
4 | * Copyright (c) 2020 SenseTime. All Rights Reserved.
5 | * Licensed under the Apache License, Version 2.0 [see LICENSE for details]
6 | **************************************************************************************************
7 | * Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0
8 | **************************************************************************************************
9 | */
10 |
11 | #pragma once
12 |
13 | #include "cpu/ms_deform_attn_cpu.h"
14 |
15 | #ifdef WITH_CUDA
16 | #include "cuda/ms_deform_attn_cuda.h"
17 | #endif
18 |
19 |
20 | at::Tensor
21 | ms_deform_attn_forward(
22 | const at::Tensor &value,
23 | const at::Tensor &spatial_shapes,
24 | const at::Tensor &level_start_index,
25 | const at::Tensor &sampling_loc,
26 | const at::Tensor &attn_weight,
27 | const int64_t im2col_step)
28 | {
29 | if (value.type().is_cuda())
30 | {
31 | #ifdef WITH_CUDA
32 | return ms_deform_attn_cuda_forward(
33 | value, spatial_shapes, level_start_index, sampling_loc, attn_weight, im2col_step);
34 | #else
35 | AT_ERROR("Not compiled with GPU support");
36 | #endif
37 | }
38 | AT_ERROR("Not implemented on the CPU");
39 | }
40 |
41 | std::vector
42 | ms_deform_attn_backward(
43 | const at::Tensor &value,
44 | const at::Tensor &spatial_shapes,
45 | const at::Tensor &level_start_index,
46 | const at::Tensor &sampling_loc,
47 | const at::Tensor &attn_weight,
48 | const at::Tensor &grad_output,
49 | const int64_t im2col_step)
50 | {
51 | if (value.type().is_cuda())
52 | {
53 | #ifdef WITH_CUDA
54 | return ms_deform_attn_cuda_backward(
55 | value, spatial_shapes, level_start_index, sampling_loc, attn_weight, grad_output, im2col_step);
56 | #else
57 | AT_ERROR("Not compiled with GPU support");
58 | #endif
59 | }
60 | AT_ERROR("Not implemented on the CPU");
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/ops/src/vision.cpp:
--------------------------------------------------------------------------------
1 | /*!
2 | **************************************************************************************************
3 | * Deformable DETR
4 | * Copyright (c) 2020 SenseTime. All Rights Reserved.
5 | * Licensed under the Apache License, Version 2.0 [see LICENSE for details]
6 | **************************************************************************************************
7 | * Modified from https://github.com/chengdazhi/Deformable-Convolution-V2-PyTorch/tree/pytorch_1.0.0
8 | **************************************************************************************************
9 | */
10 |
11 | #include "ms_deform_attn.h"
12 | #include
13 |
14 | // static auto registry = torch::RegisterOperators("alonet::ms_deform_attn", &ms_deform_attn_forward);
15 |
16 | // PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) {
17 | // m.def("ms_deform_attn_forward", &ms_deform_attn_forward, "ms_deform_attn_forward");
18 | // m.def("ms_deform_attn_backward", &ms_deform_attn_backward, "ms_deform_attn_backward");
19 | // }
20 |
21 | TORCH_LIBRARY(alonet_custom, m){
22 | m.def("ms_deform_attn_forward", ms_deform_attn_forward);
23 | m.def("ms_deform_attn_backward", ms_deform_attn_backward);
24 | }
--------------------------------------------------------------------------------
/alonet/deformable_detr/production/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Serving
3 | created: '2021-09-29T13:55:46.171Z'
4 | modified: '2021-10-26T12:13:08.907Z'
5 | ---
6 |
7 | # Launch Serving
8 |
9 | ```
10 | # Stop any serving if exists
11 | torchserve --stop
12 | rm deformable_detr_r50.mar
13 |
14 | # Create model.pt
15 | python alonet/deformable_detr/production/export_to_pt.py
16 |
17 | # Generate .mar file
18 | torch-model-archiver --model-name deformable_detr_r50 --version 1.0 --serialized-file deformable-detr-r50.pt --handler alonet/detr/production/model_handler.py --extra-files "alonet/detr/production/index_to_name_things.json,alonet/deformable_detr/production/setup_config.json"
19 |
20 | # Move file into model_store folder
21 | mkdir model_store
22 | mv deformable_detr_r50.mar model_store/
23 |
24 | # Launch serving
25 | torchserve --start --model-store model_store --models deformable_detr_r50.mar --ncs
26 | ```
27 |
28 | ```
29 | torchserve --stop
30 | ```
31 |
32 | # Client request
33 |
34 |
35 | ```
36 | # Verify if models is dispo
37 | curl localhost:8081/models
38 | curl localhost:8081/models/deformable_detr_r50
39 |
40 | # Inference
41 | curl localhost:8080/predictions/deformable_detr_r50 -T path/to/image
42 | ```
43 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/production/export_to_pt.py:
--------------------------------------------------------------------------------
1 | import torch
2 | from alonet.deformable_detr import DeformableDetrR50
3 |
4 | if __name__ == "__main__":
5 | device = torch.device("cuda")
6 |
7 | model = DeformableDetrR50(weights="deformable-detr-r50", tracing=True, aux_loss=False).eval()
8 | model.to(device)
9 |
10 | example_input = torch.rand(1, 4, 800, 1333).to(device)
11 | example_input2 = torch.rand(1, 4, 400, 600).to(device)
12 |
13 | traced_script_module = torch.jit.trace(model, example_input, check_inputs=[example_input, example_input2])
14 | traced_script_module.save("deformable-detr-r50.pt")
15 |
16 | print("[INFO] Model export successfully")
17 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/production/setup_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "threshold": 0.2,
3 | "background_class": 91,
4 | "activation_fn" : "sigmoid",
5 | "enable_cuda_ops" : true
6 | }
7 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/train_on_coco.py:
--------------------------------------------------------------------------------
1 | import random
2 | import numpy as np
3 | import torch
4 |
5 | from argparse import ArgumentParser
6 |
7 | from alonet.detr import CocoDetection2Detr
8 | from alonet.deformable_detr import LitDeformableDetr
9 |
10 | import alonet
11 |
12 |
13 | def get_arg_parser():
14 | # Build parser
15 | parser = ArgumentParser(conflict_handler="resolve")
16 | parser = alonet.common.add_argparse_args(parser) # Common alonet parser
17 | parser = CocoDetection2Detr.add_argparse_args(parser) # Coco detection parser
18 | parser = LitDeformableDetr.add_argparse_args(parser) # LitDeformableDetr training parser
19 | # parser = pl.Trainer.add_argparse_args(parser) # Pytorch lightning Parser
20 | return parser
21 |
22 |
23 | def main():
24 | """Main"""
25 | # NOTE: for reproducibility
26 | torch.manual_seed(42)
27 | random.seed(42)
28 | np.random.seed(0)
29 |
30 | # torch.autograd.set_detect_anomaly(True)
31 |
32 | args = get_arg_parser().parse_args() # Parse
33 |
34 | # Init the Detr model with the dataset
35 | lit_model = LitDeformableDetr(args)
36 | coco_loader = CocoDetection2Detr(args)
37 |
38 | lit_model.run_train(
39 | data_loader=coco_loader,
40 | args=args,
41 | project="deformable_detr_r50",
42 | expe_name=args.expe_name or "deformable_detr_r50",
43 | )
44 |
45 |
46 | if __name__ == "__main__":
47 | main()
48 |
--------------------------------------------------------------------------------
/alonet/deformable_detr/utils.py:
--------------------------------------------------------------------------------
1 | import os
2 | import subprocess
3 | import torch
4 | from torch import nn
5 | import copy
6 | from alonet import ALONET_ROOT
7 |
8 |
9 | def inverse_sigmoid(x, eps=1e-5):
10 | x = x.clamp(min=0.0, max=1.0)
11 | x1 = x.clamp(min=eps)
12 | x2 = (1 - x).clamp(min=eps)
13 | y = torch.log(x1 / x2)
14 | return y
15 |
--------------------------------------------------------------------------------
/alonet/deformable_detr_panoptic/__init__.py:
--------------------------------------------------------------------------------
1 | from .deformable_detr_r50_panoptic import DeformableDetrR50Panoptic
2 | from .deformable_detr_r50_panoptic_finetune import DeformableDetrR50PanopticFinetune
3 | from .criterion import DeformablePanopticCriterion
4 | from .train import LitPanopticDeformableDetr
5 |
--------------------------------------------------------------------------------
/alonet/deformable_detr_panoptic/callbacks.py:
--------------------------------------------------------------------------------
1 | """Callbacks for Deformable DETR Panoptic training are the same as DETR Panoptic training
2 | """
3 |
--------------------------------------------------------------------------------
/alonet/deformable_detr_panoptic/criterion.py:
--------------------------------------------------------------------------------
1 | """This class computes the loss for
2 | :mod:`DEFORMABLE DETR PANOPTIC `.
3 | The process happens in two steps:
4 |
5 | 1) We compute hungarian assignment between ground truth boxes and the outputs of the model
6 | 2) We supervise each pair of matched ground-truth / prediction (supervise class, boxes and masks).
7 | """
8 |
9 | from alonet.detr_panoptic.criterion import PanopticCriterion
10 | from alonet.deformable_detr import DeformableCriterion
11 |
12 |
13 | class DeformablePanopticCriterion(PanopticCriterion, DeformableCriterion):
14 | """Create the criterion.
15 |
16 | Parameters
17 | ----------
18 | num_classes: int
19 | number of object categories, omitting the special no-object category
20 | matcher: nn.Module
21 | module able to compute a matching between targets and proposed boxes
22 | loss_label_weight : float
23 | Label class weight, to use in CE or sigmoid focal (default) loss (depends of network configuration)
24 | loss_boxes_weight: float
25 | Boxes loss l1 weight
26 | loss_giou_weight: float
27 | Boxes loss GIOU
28 | loss_dice_weight: float
29 | DICE/F-1 loss weight use in masks_loss
30 | loss_focal_weight: float
31 | Focal loss weight use in masks_loss
32 | eos_coef: float
33 | relative classification weight applied to the no-object category
34 | focal_alpha : float, optional
35 | This parameter is used only when the model use sigmoid activation function.
36 | Weighting factor in range (0,1) to balance positive vs negative examples. -1 for no weighting, by default 0.25
37 | aux_loss_stage:
38 | Number of auxialiry stage
39 | losses: list
40 | list of all the losses to be applied. See get_loss for list of available losses.
41 | """
42 |
--------------------------------------------------------------------------------
/alonet/deformable_detr_panoptic/train_on_coco.py:
--------------------------------------------------------------------------------
1 | from argparse import ArgumentParser
2 | from alonet.deformable_detr_panoptic import LitPanopticDeformableDetr
3 | from alonet.detr import CocoPanoptic2Detr
4 |
5 | import alonet
6 |
7 |
8 | def get_arg_parser():
9 | parser = ArgumentParser(conflict_handler="resolve")
10 | parser = alonet.common.add_argparse_args(parser) # Common alonet parser
11 | parser = CocoPanoptic2Detr.add_argparse_args(parser) # Coco detection parser
12 | parser = LitPanopticDeformableDetr.add_argparse_args(parser) # LitDetr training parser
13 | # parser = pl.Trainer.add_argparse_args(parser) # Pytorch lightning Parser
14 | return parser
15 |
16 |
17 | def main():
18 | """Main"""
19 | # Build parser
20 | args = get_arg_parser().parse_args() # Parse
21 |
22 | # Init the Panoptic2Detr and LitPanoptic modules
23 | coco_loader = CocoPanoptic2Detr(args=args)
24 | lit_panoptic = LitPanopticDeformableDetr(args)
25 |
26 | # Start training
27 | lit_panoptic.run_train(data_loader=coco_loader, args=args, project="deformable-detr-panoptic", expe_name="coco")
28 |
29 |
30 | if __name__ == "__main__":
31 | main()
32 |
--------------------------------------------------------------------------------
/alonet/detr/README.md:
--------------------------------------------------------------------------------
1 | # Detr
2 |
3 | Here is a simple example to get started with **Detr** and aloception. To learn more about Detr, you can checkout the Detr Tutorials or
4 | the scripts described bellow.
5 |
6 | ```python
7 | # Load model
8 | model = alonet.detr.DetrR50(num_classes=91, weights="detr-r50").eval()
9 |
10 | # Open and normalized frame
11 | frame = aloscene.Frame("/path/to/image.jpg").norm_resnet()
12 |
13 | # Run inference
14 | pred_boxes = model.inference(model([frame]))
15 |
16 | # Add and display the predicted boxes
17 | frame.append_boxes2d(pred_boxes[0], "pred_boxes")
18 | frame.get_view().render()
19 | ```
20 |
21 |
22 | ### Running inference with detr_r50
23 |
24 | ```
25 | python alonet/detr/detr_r50.py /path/to/image.jpg
26 | ```
27 |
28 | ### Training Detr from scratch
29 | ```
30 | python alonet/detr/train_on_coco.py
31 | ```
32 |
33 | ### Running evaluation of detr-r50
34 |
35 | ```
36 | python alonet/detr/eval_on_coco.py --weights detr-r50 --batch_size 1
37 | ```
38 |
39 | ```
40 | | all | .50 | .55 | .60 | .65 | .70 | .75 | .80 | .85 | .90 | .95 |
41 | -------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
42 | box | 39.93 | 58.80 | 56.57 | 54.00 | 50.99 | 47.06 | 42.17 | 36.12 | 28.74 | 18.62 | 6.25 |
43 | -------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+-------+
44 | ```
45 |
--------------------------------------------------------------------------------
/alonet/detr/__init__.py:
--------------------------------------------------------------------------------
1 | from .data_modules import Data2Detr
2 | from .data_modules import CocoDetection2Detr
3 | from .data_modules import CocoPanoptic2Detr
4 |
5 | from .matcher import DetrHungarianMatcher
6 | from .criterion import DetrCriterion
7 |
8 | from .detr import Detr
9 | from .detr_r50 import DetrR50
10 | from .detr_r50_finetune import DetrR50Finetune
11 |
12 | from .train import LitDetr
13 | from .callbacks import DetrObjectDetectorCallback
14 |
15 | from .transformer import Transformer, TransformerDecoderLayer, TransformerDecoder
16 |
--------------------------------------------------------------------------------
/alonet/detr/callbacks.py:
--------------------------------------------------------------------------------
1 | """Detr Callback for object detection training that use :mod:`~aloscene.frame` as GT."""
2 | import aloscene
3 |
4 | from alonet.callbacks import ObjectDetectorCallback
5 | from pytorch_lightning.utilities import rank_zero_only
6 |
7 |
8 | class DetrObjectDetectorCallback(ObjectDetectorCallback):
9 | def __init__(self, *args, **kwargs):
10 | super().__init__(*args, **kwargs)
11 |
12 | @rank_zero_only
13 | def on_train_batch_end(self, trainer, pl_module, outputs, batch, batch_idx, dataloader_idx):
14 | if trainer.logger is None:
15 | return
16 | if trainer.fit_loop.should_accumulate() or (trainer.global_step + 1) % (trainer.log_every_n_steps * 10) != 0:
17 | # Draw boxes for last batch
18 | if (trainer.fit_loop.total_batch_idx + 1) % trainer.num_training_batches != 0:
19 | return
20 |
21 | assert isinstance(outputs, dict)
22 | assert "m_outputs" in outputs
23 |
24 | if isinstance(batch, list):
25 | frames = aloscene.Frame.batch_list(batch)
26 | else:
27 | frames = batch
28 |
29 | pred_boxes = pl_module.inference(outputs["m_outputs"])
30 | self.log_boxes_2d(frames=frames, preds_boxes=pred_boxes, trainer=trainer, name="train/frame_obj_detector")
31 |
32 | @rank_zero_only
33 | def on_validation_epoch_end(self, trainer, pl_module):
34 | if trainer.logger is None:
35 | return
36 |
37 | # Send the validation frame on the same device than the Model
38 | if self.val_frames.device != pl_module.device:
39 | self.val_frames = self.val_frames.to(pl_module.device)
40 |
41 | pred_boxes = pl_module.inference(pl_module(self.val_frames))
42 | self.log_boxes_2d(
43 | frames=self.val_frames, preds_boxes=pred_boxes, trainer=trainer, name="val/frame_obj_detector"
44 | )
45 |
--------------------------------------------------------------------------------
/alonet/detr/data_modules/__init__.py:
--------------------------------------------------------------------------------
1 | from .data2detr import Data2Detr
2 | from .coco_detection2detr import CocoDetection2Detr
3 | from .coco_panoptic2detr import CocoPanoptic2Detr
4 |
--------------------------------------------------------------------------------
/alonet/detr/data_modules/coco_panoptic2detr.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 |
3 | from alonet.detr.data_modules import Data2Detr
4 | import alodataset
5 |
6 |
7 | class CocoPanoptic2Detr(Data2Detr):
8 | def setup(self, stage: Optional[str] = None, fix_classes_len: int = 250):
9 | """:attr:`train_dataset` and :attr:`val_dataset` datasets setup, follow the parameters used
10 | in class declaration. Also, set :attr:`label_names` attribute.
11 |
12 | Parameters
13 | ----------
14 | stage : str, optional
15 | Stage either `fit`, `validate`, `test` or `predict`, by default None
16 | fix_classes_len : int, optional
17 | Fix datasets to a specific number the number of classes, filling the rest with "N/A" value.
18 | """
19 | if stage == "fit" or stage is None:
20 | # Setup train/val loaders
21 | self.train_dataset = alodataset.CocoPanopticDataset(
22 | transform_fn=self.val_transform if self.train_on_val else self.train_transform,
23 | sample=self.sample,
24 | split=alodataset.Split.VAL if self.train_on_val else alodataset.Split.TRAIN,
25 | fix_classes_len=fix_classes_len,
26 | )
27 | self.sample = self.train_dataset.sample or self.sample # Update sample if user prompt is given
28 | self.val_dataset = alodataset.CocoPanopticDataset(
29 | transform_fn=self.val_transform,
30 | sample=self.sample,
31 | split=alodataset.Split.VAL,
32 | fix_classes_len=fix_classes_len,
33 | )
34 | self.sample = self.val_dataset.sample or self.sample # Update sample if user prompt is given
35 | self.label_names = self.val_dataset.label_names if hasattr(self.val_dataset, "label_names") else None
36 |
37 |
38 | if __name__ == "__main__":
39 | # setup data
40 | coco = CocoPanoptic2Detr()
41 | coco.prepare_data()
42 | coco.setup()
43 |
44 | samples = next(iter(coco.train_dataloader()))
45 | samples[0].get_view().render()
46 |
47 | samples = next(iter(coco.val_dataloader()))
48 | samples[0].get_view().render()
49 |
--------------------------------------------------------------------------------
/alonet/detr/eval_on_coco.py:
--------------------------------------------------------------------------------
1 | from argparse import ArgumentParser
2 | import torch
3 |
4 | from alonet.detr import CocoDetection2Detr
5 | from alonet.detr import LitDetr
6 |
7 | import aloscene
8 | import alonet
9 |
10 |
11 | def main():
12 | """Main"""
13 | device = torch.device("cuda")
14 |
15 | # Build parser
16 | parser = ArgumentParser(conflict_handler="resolve")
17 | parser = alonet.common.add_argparse_args(parser) # Common alonet parser
18 | parser = CocoDetection2Detr.add_argparse_args(parser) # Coco detection parser
19 | parser = LitDetr.add_argparse_args(parser) # LitDetr training parser
20 |
21 | parser.add_argument(
22 | "--ap_limit", type=int, default=None, help="Limit AP computation at the given number of sample"
23 | )
24 |
25 | args = parser.parse_args() # Parse
26 |
27 | # Init the Detr model with the dataset
28 | detr = LitDetr(args)
29 | args.batch_size = 1
30 | coco_loader = CocoDetection2Detr(args)
31 |
32 | detr = detr.to(device)
33 | detr.model.eval()
34 |
35 | ap_metrics = alonet.metrics.ApMetrics()
36 |
37 | for it, data in enumerate(coco_loader.val_dataloader(sampler=torch.utils.data.SequentialSampler)):
38 | frame = aloscene.Frame.batch_list(data)
39 | frame = frame.to(device)
40 |
41 | pred_boxes = detr.inference(detr(frame))[0]
42 | gt_boxes = frame.boxes2d[0]
43 |
44 | ap_metrics.add_sample(pred_boxes, gt_boxes)
45 |
46 | print(f"it:{it}", end="\r")
47 | if args.ap_limit is not None and it > args.ap_limit:
48 | break
49 |
50 | print("Total eval batch:", it)
51 | ap_metrics.calc_map(print_result=True)
52 |
53 |
54 | if __name__ == "__main__":
55 | main()
56 |
--------------------------------------------------------------------------------
/alonet/detr/misc.py:
--------------------------------------------------------------------------------
1 | import os
2 | from typing import Union
3 | import torch
4 | from aloscene import Frame
5 | import torch.distributed as dist
6 | from functools import wraps
7 |
8 |
9 | def assert_and_export_onnx(check_mean_std=False, input_mean_std=None):
10 | def decorator(forward):
11 | @wraps(forward)
12 | def wrapper(instance, frames: Union[torch.Tensor, Frame], is_export_onnx=False, *args, **kwargs):
13 | # A little hack: we use is_export_onnx=None and is_tracing=None as True when exporting onnx
14 | # because torch.onnx.export accepts only torch.Tensor or None
15 | if hasattr(instance, "tracing") and instance.tracing:
16 | assert isinstance(frames, torch.Tensor)
17 | kwargs["is_tracing"] = None
18 | if is_export_onnx is None:
19 | return forward(instance, frames, is_export_onnx=None, **kwargs)
20 | else:
21 | if isinstance(frames, list):
22 | frames = Frame.batch_list(frames)
23 | assert isinstance(frames, Frame)
24 | assert frames.normalization == "resnet"
25 | assert frames.names == ("B", "C", "H", "W")
26 | assert frames.mask is not None
27 | assert frames.mask.names == ("B", "C", "H", "W")
28 | if check_mean_std and input_mean_std is not None:
29 | assert frames.mean_std[0] == input_mean_std[0]
30 | assert frames.mean_std[1] == input_mean_std[1]
31 | return forward(instance, frames, **kwargs)
32 |
33 | return wrapper
34 |
35 | return decorator
36 |
--------------------------------------------------------------------------------
/alonet/detr/production/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | title: Serving
3 | created: '2021-09-29T13:55:46.171Z'
4 | modified: '2021-10-26T12:13:08.907Z'
5 | ---
6 |
7 | # Launch Serving
8 |
9 | ```
10 | # Stop any serving if exists
11 | torchserve --stop
12 | rm detr_r50.mar
13 |
14 | # Create model.pt
15 | python alonet/detr/production/export_to_pt.py
16 |
17 | # Generate .mar file
18 | torch-model-archiver --model-name detr_r50 --version 1.0 --serialized-file detr-r50.pt --handler alonet/detr/production/model_handler.py --extra-files "alonet/detr/production/index_to_name_things.json,alonet/detr/production/setup_config.json"
19 |
20 | # Move file into model_store folder
21 | mkdir model_store
22 | mv detr_r50.mar model_store/
23 |
24 | # Launch serving
25 | torchserve --start --model-store model_store --models detr_r50.mar --ncs
26 | ```
27 |
28 | ```
29 | torchserve --stop
30 | ```
31 |
32 | # Client request
33 |
34 |
35 | ```
36 | # Verify if models is dispo
37 | curl localhost:8081/models
38 | curl localhost:8081/models/detr_r50
39 |
40 | # Inference
41 | curl localhost:8080/predictions/detr_r50 -T path/to/image
42 | ```
43 |
--------------------------------------------------------------------------------
/alonet/detr/production/__init__.py:
--------------------------------------------------------------------------------
1 | from .model_handler import ModelHandler
2 |
--------------------------------------------------------------------------------
/alonet/detr/production/export_to_pt.py:
--------------------------------------------------------------------------------
1 | import torch
2 | from alonet.detr import DetrR50
3 |
4 | if __name__ == "__main__":
5 | device = torch.device("cuda")
6 |
7 | model = DetrR50(weights="detr-r50", tracing=True, aux_loss=False).eval()
8 | model.to(device)
9 |
10 | example_input = torch.rand(1, 4, 800, 1333).to(device)
11 | example_input2 = torch.rand(1, 4, 400, 600).to(device)
12 |
13 | traced_script_module = torch.jit.trace(model, example_input, check_inputs=[example_input, example_input2])
14 | traced_script_module.save("detr-r50.pt")
15 |
16 | print("[INFO] Model export successfully")
17 |
--------------------------------------------------------------------------------
/alonet/detr/production/index_to_name_things.json:
--------------------------------------------------------------------------------
1 | {
2 | "0": "__background__",
3 | "1": "person",
4 | "2": "bicycle",
5 | "3": "car",
6 | "4": "motorcycle",
7 | "5": "airplane",
8 | "6": "bus",
9 | "7": "train",
10 | "8": "truck",
11 | "9": "boat",
12 | "10": "traffic light",
13 | "11": "fire hydrant",
14 | "12": "N/A",
15 | "13": "stop sign",
16 | "14": "parking meter",
17 | "15": "bench",
18 | "16": "bird",
19 | "17": "cat",
20 | "18": "dog",
21 | "19": "horse",
22 | "20": "sheep",
23 | "21": "cow",
24 | "22": "elephant",
25 | "23": "bear",
26 | "24": "zebra",
27 | "25": "giraffe",
28 | "26": "N/A",
29 | "27": "backpack",
30 | "28": "umbrella",
31 | "29": "N/A",
32 | "30": "N/A",
33 | "31": "handbag",
34 | "32": "tie",
35 | "33": "suitcase",
36 | "34": "frisbee",
37 | "35": "skis",
38 | "36": "snowboard",
39 | "37": "sports ball",
40 | "38": "kite",
41 | "39": "baseball bat",
42 | "40": "baseball glove",
43 | "41": "skateboard",
44 | "42": "surfboard",
45 | "43": "tennis racket",
46 | "44": "bottle",
47 | "45": "N/A",
48 | "46": "wine glass",
49 | "47": "cup",
50 | "48": "fork",
51 | "49": "knife",
52 | "50": "spoon",
53 | "51": "bowl",
54 | "52": "banana",
55 | "53": "apple",
56 | "54": "sandwich",
57 | "55": "orange",
58 | "56": "broccoli",
59 | "57": "carrot",
60 | "58": "hot dog",
61 | "59": "pizza",
62 | "60": "donut",
63 | "61": "cake",
64 | "62": "chair",
65 | "63": "couch",
66 | "64": "potted plant",
67 | "65": "bed",
68 | "66": "N/A",
69 | "67": "dining table",
70 | "68": "N/A",
71 | "69": "N/A",
72 | "70": "toilet",
73 | "71": "N/A",
74 | "72": "tv",
75 | "73": "laptop",
76 | "74": "mouse",
77 | "75": "remote",
78 | "76": "keyboard",
79 | "77": "cell phone",
80 | "78": "microwave",
81 | "79": "oven",
82 | "80": "toaster",
83 | "81": "sink",
84 | "82": "refrigerator",
85 | "83": "N/A",
86 | "84": "book",
87 | "85": "clock",
88 | "86": "vase",
89 | "87": "scissors",
90 | "88": "teddy bear",
91 | "89": "hair drier",
92 | "90": "toothbrush",
93 | "91": "__background__"
94 | }
95 |
--------------------------------------------------------------------------------
/alonet/detr/production/setup_config.json:
--------------------------------------------------------------------------------
1 | {
2 | "threshold": 0.85,
3 | "background_class": 91,
4 | "activation_fn" : "softmax",
5 | "enable_cuda_ops" : false
6 | }
7 |
--------------------------------------------------------------------------------
/alonet/detr/train_on_coco.py:
--------------------------------------------------------------------------------
1 | from argparse import ArgumentParser
2 | from alonet.detr import CocoDetection2Detr
3 | from alonet.detr import LitDetr
4 |
5 | import alonet
6 |
7 |
8 | def get_arg_parser():
9 | parser = ArgumentParser(conflict_handler="resolve")
10 | parser = alonet.common.add_argparse_args(parser) # Common alonet parser
11 | parser = CocoDetection2Detr.add_argparse_args(parser) # Coco detection parser
12 | parser = LitDetr.add_argparse_args(parser) # LitDetr training parser
13 | # parser = pl.Trainer.add_argparse_args(parser) # Pytorch lightning Parser
14 | return parser
15 |
16 |
17 | def main():
18 | """Main"""
19 | # Build parser
20 | args = get_arg_parser().parse_args() # Parse
21 |
22 | # Init the Detr model with the dataset
23 | detr = LitDetr(args)
24 | coco_loader = CocoDetection2Detr(args)
25 |
26 | detr.run_train(data_loader=coco_loader, args=args, project="detr", expe_name="detr_50")
27 |
28 |
29 | if __name__ == "__main__":
30 | main()
31 |
--------------------------------------------------------------------------------
/alonet/detr_panoptic/__init__.py:
--------------------------------------------------------------------------------
1 | from .detr_panoptic import PanopticHead
2 | from .detr_r50_panoptic import DetrR50Panoptic
3 | from .detr_r50_panoptic_finetune import DetrR50PanopticFinetune
4 | from .criterion import DetrPanopticCriterion
5 | from .callbacks import PanopticObjectDetectorCallback, PanopticApMetricsCallbacks
6 | from .train import LitPanopticDetr
7 |
--------------------------------------------------------------------------------
/alonet/detr_panoptic/misc.py:
--------------------------------------------------------------------------------
1 | from typing import Union
2 | import torch
3 | from aloscene import Frame
4 | from functools import wraps
5 |
6 |
7 | def assert_and_export_onnx(check_mean_std=False, input_mean_std=None):
8 | def decorator(forward):
9 | @wraps(forward)
10 | def wrapper(instance, frames: Union[torch.Tensor, Frame], is_export_onnx=False, *args, **kwargs):
11 | # A little hack: we use is_export_onnx=None and is_tracing=None as True when exporting onnx
12 | # because torch.onnx.export accepts only torch.Tensor or None
13 | if hasattr(instance, "tracing") and instance.tracing:
14 | assert isinstance(frames, (torch.Tensor, dict))
15 | if isinstance(frames, torch.Tensor):
16 | assert frames.shape[1] == 4 # Image input: expected rgb 3 + mask 1
17 | else:
18 | # Image in DETR format, with fields at least:
19 | assert all([x in frames for x in ["dec_outputs", "enc_outputs", "bb_lvl3_mask_outputs"]])
20 | assert all([x in frames for x in [f"bb_lvl{i}_src_outputs" for i in range(4)]])
21 | kwargs["is_tracing"] = None
22 | if is_export_onnx is None:
23 | return forward(instance, frames, is_export_onnx=None, **kwargs)
24 | else:
25 | if isinstance(frames, list):
26 | frames = Frame.batch_list(frames)
27 | assert isinstance(frames, Frame)
28 | assert frames.normalization == "resnet"
29 | assert frames.names == ("B", "C", "H", "W")
30 | assert frames.mask is not None
31 | assert frames.mask.names == ("B", "C", "H", "W")
32 | if check_mean_std and input_mean_std is not None:
33 | assert frames.mean_std[0] == input_mean_std[0]
34 | assert frames.mean_std[1] == input_mean_std[1]
35 | return forward(instance, frames, **kwargs)
36 |
37 | return wrapper
38 |
39 | return decorator
40 |
--------------------------------------------------------------------------------
/alonet/detr_panoptic/nn/__init__.py:
--------------------------------------------------------------------------------
1 | from .FPNstyle import FPNstyleCNN
2 | from .MHAttention import MHAttentionMap
3 |
--------------------------------------------------------------------------------
/alonet/detr_panoptic/train_on_coco.py:
--------------------------------------------------------------------------------
1 | from argparse import ArgumentParser
2 | from alonet.detr_panoptic import LitPanopticDetr
3 | from alonet.detr import CocoPanoptic2Detr
4 |
5 | import alonet
6 |
7 |
8 | def get_arg_parser():
9 | parser = ArgumentParser(conflict_handler="resolve")
10 | parser = alonet.common.add_argparse_args(parser) # Common alonet parser
11 | parser = CocoPanoptic2Detr.add_argparse_args(parser) # Coco detection parser
12 | parser = LitPanopticDetr.add_argparse_args(parser) # LitDetr training parser
13 | # parser = pl.Trainer.add_argparse_args(parser) # Pytorch lightning Parser
14 | return parser
15 |
16 |
17 | def main():
18 | """Main"""
19 | # Build parser
20 | args = get_arg_parser().parse_args() # Parse
21 |
22 | # Init the Panoptic2Detr and LitPanoptic modules
23 | coco_loader = CocoPanoptic2Detr(args=args)
24 | lit_panoptic = LitPanopticDetr(args)
25 |
26 | # Start training
27 | lit_panoptic.run_train(data_loader=coco_loader, args=args, project="detr-panoptic", expe_name="coco")
28 |
29 |
30 | if __name__ == "__main__":
31 | main()
32 |
--------------------------------------------------------------------------------
/alonet/metrics/__init__.py:
--------------------------------------------------------------------------------
1 | from .compute_map import ApMetrics
2 | from .compute_map_3d import ApMetrics3D
3 | from .compute_pq import PQMetrics
4 | from .depth_metrics import DepthMetrics
5 |
--------------------------------------------------------------------------------
/alonet/metrics/utils.py:
--------------------------------------------------------------------------------
1 | from typing import Dict, List
2 |
3 |
4 | def _print_map(average_pq: Dict, pq_per_class: Dict, suffix: str = "", **kwargs):
5 | _print_head(suffix, **kwargs)
6 | _print_body(average_pq, pq_per_class, **kwargs)
7 |
8 |
9 | def _print_head(suffix: str = "", head_elm: List = [], clm_size: int = 9, **kwargs):
10 | make_row = lambda vals: (f" %{clm_size - 2}s |" * len(vals)) % tuple(vals)
11 | make_sep = lambda n: (("-" * clm_size + "+") * (n + 1))
12 |
13 | print()
14 | print(make_sep(len(head_elm) + 1))
15 | print(" " * (2 * clm_size + 1) + "|" + make_row([v + suffix for v in head_elm]))
16 | print(make_sep(len(head_elm) + 1))
17 |
18 |
19 | def _print_body(average_pq: Dict, pq_per_class: Dict, clm_size: int = 9, **kwargs):
20 | make_row = lambda vals: (f" %{clm_size - 2}s |" * len(vals)) % tuple(vals)
21 | make_sep = lambda n: (("-" * clm_size + "+") * (n + 1))
22 |
23 | if pq_per_class is not None:
24 | for cat, metrics in pq_per_class.items():
25 | print(
26 | make_row(
27 | [cat[:clm_size * 2 - 1] if len(cat) > clm_size * 2 else cat + " " * (clm_size * 2 - 1 - len(cat))] +
28 | ["%.3f" % metrics[k] for k in metrics.keys()]
29 | )
30 | )
31 | print(make_sep(len(metrics) + 1))
32 |
33 |
34 | if average_pq is not None:
35 | n = "%d" % average_pq.pop("n")
36 | print(
37 | make_row(
38 | ["total = %s" % n + " " * (clm_size * 2 - 9 - len(n))] +
39 | ["%.3f" % average_pq[k] for k in average_pq.keys()]
40 | )
41 | )
42 | print(make_sep(len(average_pq) + 1))
43 |
44 |
--------------------------------------------------------------------------------
/alonet/multi_gpu.py:
--------------------------------------------------------------------------------
1 | import torch
2 | import torch.distributed as dist
3 |
4 |
5 | def get_world_size():
6 | if not is_dist_avail_and_initialized():
7 | return 1
8 | return dist.get_world_size()
9 |
10 |
11 | def is_dist_avail_and_initialized():
12 | if not dist.is_available():
13 | return False
14 | if not dist.is_initialized():
15 | return False
16 | return True
17 |
18 |
19 | def get_rank():
20 | if not is_dist_avail_and_initialized():
21 | return 0
22 | return dist.get_rank()
23 |
24 |
25 | def is_main_rank(func):
26 | def _method(*args, **kwargs):
27 | if get_rank() == 0:
28 | return func(*args, **kwargs)
29 | else:
30 | return
31 | return func
32 |
33 | return _method
34 |
--------------------------------------------------------------------------------
/alonet/raft/README.md:
--------------------------------------------------------------------------------
1 | # Raft
2 |
3 |
4 | Here is a simple example to get started with **RAFT** and aloception. To learn more about RAFT, you can checkout the script bellow.
5 |
6 | ```python
7 | # Use the left frame from the Sintel Flow dataset and normalize the frame for the RAFT Model
8 | frame = alodataset.SintelFlowDataset(sample=True).getitem(0)["left"].norm_minmax_sym()
9 |
10 | # Load the model using the sintel weights
11 | raft = alonet.raft.RAFT(weights="raft-sintel")
12 |
13 | # Compute optical flow
14 | padder = alonet.raft.utils.Padder()
15 | flow = raft.inference(raft(padder.pad(frame[0:1]), padder.pad(frame[1:2])))
16 |
17 | # Render the flow along with the first frame
18 | flow[0].get_view().render()
19 | ```
20 |
21 | ## Running inference with RAFT
22 |
23 | Inference can be performed using official pretrained weights:
24 | ```
25 | python alonet/raft/raft.py --weights=raft-things image1.png img2.png
26 | ```
27 | or with a custom weight file:
28 | ```
29 | python alonet/raft/raft.py --weights=path/to/weights.pth image1.png img2.png
30 | ```
31 |
32 | ## Running evaluation of RAFT
33 | RAFT model is evaluated with official weights "raft-things".
34 |
35 | The **EPE** score is computed on Sintel training set. This reproduces the results from RAFT paper : table 1 (training data:"C+T", "method:our(2-views), eval:"sintel training clean).
36 |
37 | ```
38 | python alonet/raft/eval_on_sintel.py
39 | ```
40 |
41 | This results in EPE=1.46, which is similar to 1.43 in the paper (obtained as a median score for models trained with 3 differents seeds).
42 |
43 | ## Training RAFT from scratch
44 | To reproduce the first stage of RAFT training on FlyingChairs dataset:
45 | ```
46 | python alonet/raft/train_on_chairs.py
47 | ```
48 |
49 | It is possible to reproduce the full RAFT training or to train on custom dataset by creating the necessary dataset classes and following the same approach as in `train_on_chairs.py`
50 |
--------------------------------------------------------------------------------
/alonet/raft/__init__.py:
--------------------------------------------------------------------------------
1 | from .raft import RAFT
2 | from .raft_small import RAFTSmall
3 | from .callbacks import RAFTFlowImagesCallback, RAFTEPECallback
4 | from .train import LitRAFT
5 | from .data_modules.chairs2raft import Chairs2RAFT
6 |
--------------------------------------------------------------------------------
/alonet/raft/callbacks/__init__.py:
--------------------------------------------------------------------------------
1 | from .flow_image import RAFTFlowImagesCallback
2 | from .flow_video import FlowVideoCallback
3 | from .epe import RAFTEPECallback
4 |
--------------------------------------------------------------------------------
/alonet/raft/data_modules/__init__.py:
--------------------------------------------------------------------------------
1 | from .data2raft import Data2RAFT
2 | from .chairs2raft import Chairs2RAFT
3 |
--------------------------------------------------------------------------------
/alonet/raft/data_modules/chairs2raft.py:
--------------------------------------------------------------------------------
1 | from torch.utils.data import SequentialSampler, RandomSampler
2 | import pytorch_lightning as pl
3 |
4 | from alodataset import FlyingChairs2Dataset, Split
5 | from alonet.raft.data_modules import Data2RAFT
6 |
7 |
8 | class Chairs2RAFT(Data2RAFT):
9 | def __init__(self, args):
10 | self.val_names = ["Chairs2"]
11 | super().__init__(args)
12 |
13 | def train_dataloader(self):
14 | split = Split.VAL if self.train_on_val else Split.TRAIN
15 | dataset = FlyingChairs2Dataset(split=split, transform_fn=self.train_transform, sample=self.sample)
16 | self.sample = self.sample or dataset.sample
17 | sampler = SequentialSampler if self.sequential else RandomSampler
18 | return dataset.train_loader(batch_size=self.batch_size, num_workers=self.num_workers, sampler=sampler)
19 |
20 | def val_dataloader(self):
21 | dataset = FlyingChairs2Dataset(split=Split.VAL, transform_fn=self.val_transform, sample=self.sample)
22 | self.sample = self.sample or dataset.sample
23 | return dataset.train_loader(batch_size=1, num_workers=self.num_workers, sampler=SequentialSampler)
24 |
25 |
26 | if __name__ == "__main__":
27 |
28 | import argparse
29 |
30 | parser = argparse.ArgumentParser()
31 | parser = Chairs2RAFT.add_argparse_args(parser)
32 | args = parser.parse_args(["--batch_size=8", "--num_workers=1"])
33 | multi = Chairs2RAFT(args)
34 | frames = next(iter(multi.train_dataloader()))
35 | frames[0].get_view().render()
36 | frames = next(iter(multi.val_dataloader()))
37 | frames[0].get_view().render()
38 |
--------------------------------------------------------------------------------
/alonet/raft/data_modules/chairssdhom2raft.py:
--------------------------------------------------------------------------------
1 | from torch.utils.data import SequentialSampler, RandomSampler
2 |
3 | from alodataset import ChairsSDHomDataset, Split
4 | from alonet.raft.data_modules import Data2RAFT
5 |
6 |
7 | class ChairsSDHom2RAFT(Data2RAFT):
8 | def __init__(self, args):
9 | self.val_names = ["SDHom"]
10 | super().__init__(args)
11 |
12 | def train_dataloader(self):
13 | split = Split.VAL if self.train_on_val else Split.TRAIN
14 | dataset = ChairsSDHomDataset(split=split, transform_fn=self.train_transform, sample=self.sample)
15 | sampler = SequentialSampler if self.sequential else RandomSampler
16 | return dataset.train_loader(batch_size=self.batch_size, num_workers=self.num_workers, sampler=sampler)
17 |
18 | def val_dataloader(self):
19 | dataset = ChairsSDHomDataset(split=Split.VAL, transform_fn=self.val_transform, sample=self.sample)
20 |
21 | return dataset.train_loader(batch_size=1, num_workers=self.num_workers, sampler=SequentialSampler)
22 |
23 |
24 | if __name__ == "__main__":
25 |
26 | import argparse
27 |
28 | parser = argparse.ArgumentParser()
29 | parser = ChairsSDHom2RAFT.add_argparse_args(parser)
30 | args = parser.parse_args(["--batch_size=8", "--num_workers=1"])
31 | multi = ChairsSDHom2RAFT(args)
32 | frames = next(iter(multi.train_dataloader()))
33 | frames[0].get_view().render()
34 | frames = next(iter(multi.val_dataloader()))
35 | frames[0].get_view().render()
36 |
--------------------------------------------------------------------------------
/alonet/raft/data_modules/sintel2raft.py:
--------------------------------------------------------------------------------
1 | from torch.utils.data import SequentialSampler, RandomSampler
2 |
3 | # import pytorch_lightning as pl
4 |
5 | from alonet.raft.data_modules import Data2RAFT
6 | from alodataset import SintelDataset, Split
7 |
8 |
9 | class Sintel2RAFT(Data2RAFT):
10 | def __init__(self, args):
11 | self.val_names = ["Things"]
12 | super().__init__(args)
13 |
14 | def train_dataloader(self):
15 | if self.train_on_val:
16 | raise ValueError("No validation set for sintel dataset")
17 |
18 | dataset = SintelDataset(
19 | split=Split.TRAIN,
20 | cameras=["left"],
21 | labels=["flow", "flow_occ"],
22 | sequence_size=2,
23 | sample=self.sample,
24 | transform_fn=lambda f: self.train_transform(f["left"]),
25 | )
26 |
27 | sampler = SequentialSampler if self.sequential else RandomSampler
28 | return dataset.train_loader(batch_size=self.batch_size, num_workers=self.num_workers, sampler=sampler)
29 |
30 | def val_dataloader(self):
31 | return None
32 |
33 |
34 | if __name__ == "__main__":
35 |
36 | import argparse
37 |
38 | parser = argparse.ArgumentParser()
39 | parser = Sintel2RAFT.add_argparse_args(parser)
40 | args = parser.parse_args(["--batch_size=8", "--num_workers=1"])
41 | multi = Sintel2RAFT(args)
42 | # 1 sample from train
43 | frames = next(iter(multi.train_dataloader()))
44 | frames[0].get_view().render()
45 |
--------------------------------------------------------------------------------
/alonet/raft/raft_small.py:
--------------------------------------------------------------------------------
1 | import alonet
2 | from alonet.raft.update import SmallUpdateBlock
3 | from alonet.raft.extractor import SmallEncoder
4 |
5 | from alonet.raft.raft import RAFTBase
6 |
7 |
8 | class RAFTSmall(RAFTBase):
9 |
10 | hidden_dim = 96
11 | context_dim = 64
12 | corr_levels = 4
13 | corr_radius = 3
14 |
15 | def __init__(self, dropout=0, **kwargs):
16 | self.dropout = dropout
17 | fnet = self.build_fnet(encoder_cls=SmallEncoder, output_dim=128)
18 | cnet = self.build_cnet(encoder_cls=SmallEncoder)
19 | update_block = self.build_update_block(update_cls=SmallUpdateBlock)
20 |
21 | super().__init__(fnet, cnet, update_block, **kwargs)
22 |
23 |
24 | if __name__ == "__main__":
25 | from torch.utils.data import SequentialSampler
26 | from alodataset import ChairsSDHomDataset, Split
27 | from aloscene import Frame
28 |
29 | print()
30 | print("[Warning] No pretrained weights for RAFTSmall. In this demo, the model is randomly initialized.")
31 | print()
32 | raft = RAFTSmall()
33 | chairs = ChairsSDHomDataset(split=Split.VAL)
34 | loader = chairs.train_loader(sampler=SequentialSampler)
35 | frames = next(iter(loader))
36 | frames = Frame.batch_list(frames)
37 | frames = frames.norm_minmax_sym()
38 | frame1 = frames[:, 0, ...]
39 | frame2 = frames[:, 1, ...]
40 | model_out = raft.forward(frame1, frame2)
41 | flows = raft.inference(model_out)
42 | flow_final = flows[-1].detach().cpu()
43 | flow_final.get_view().render()
44 |
--------------------------------------------------------------------------------
/alonet/raft/train_on_chairs.py:
--------------------------------------------------------------------------------
1 | import argparse
2 |
3 | from alonet.raft import Chairs2RAFT
4 | from alonet.raft import LitRAFT
5 | import alonet
6 |
7 |
8 | def get_args_parser():
9 | parser = argparse.ArgumentParser(conflict_handler="resolve")
10 | parser = alonet.common.add_argparse_args(parser, add_pl_args=True)
11 | parser = Chairs2RAFT.add_argparse_args(parser)
12 | parser = LitRAFT.add_argparse_args(parser)
13 | return parser
14 |
15 |
16 | def main():
17 | # Build parser and parse command line arguments
18 | args = get_args_parser().parse_args()
19 |
20 | # init model and dataset
21 | raft = LitRAFT(args)
22 | multi = Chairs2RAFT(args)
23 |
24 | raft.run_train(data_loader=multi, args=args, project="raft", expe_name="reproduce-raft-chairs")
25 |
26 |
27 | if __name__ == "__main__":
28 | main()
29 |
--------------------------------------------------------------------------------
/alonet/raft/utils/__init__.py:
--------------------------------------------------------------------------------
1 | from .utils import Padder
2 |
--------------------------------------------------------------------------------
/alonet/raft/utils/utils.py:
--------------------------------------------------------------------------------
1 | import torch
2 | import torch.nn.functional as F
3 |
4 |
5 | def bilinear_sampler(img, coords, mode="bilinear", mask=False):
6 | """Wrapper for grid_sample, uses pixel coordinates"""
7 | H, W = img.shape[-2:]
8 | xgrid, ygrid = coords.split([1, 1], dim=-1)
9 | xgrid = 2 * xgrid / (W - 1) - 1
10 | ygrid = 2 * ygrid / (H - 1) - 1
11 |
12 | grid = torch.cat([xgrid, ygrid], dim=-1)
13 | img = F.grid_sample(img, grid, align_corners=True)
14 |
15 | if mask:
16 | mask = (xgrid > -1) & (ygrid > -1) & (xgrid < 1) & (ygrid < 1)
17 | return img, mask.float()
18 |
19 | return img
20 |
21 |
22 | def coords_grid(batch, ht, wd):
23 | coords = torch.meshgrid(torch.arange(ht), torch.arange(wd))
24 | coords = torch.stack(coords[::-1], dim=0).float()
25 | return coords[None].repeat(batch, 1, 1, 1)
26 |
27 |
28 | def upflow8(flow, mode="bilinear"):
29 | new_size = (8 * flow.shape[2], 8 * flow.shape[3])
30 | return 8 * F.interpolate(flow, size=new_size, mode=mode, align_corners=True)
31 |
32 |
33 | class Padder:
34 | """Pad spatial dims to multiples of 8"""
35 |
36 | def __init__(self):
37 | pass
38 |
39 | def _set_pad(self, frame):
40 | self.h, self.w = frame.HW
41 | self.pad_h = (((self.h // 8) + 1) * 8 - self.h) % 8
42 | self.pad_w = (((self.h // 8) + 1) * 8 - self.w) % 8
43 | # padding offsets
44 | self.top = self.pad_h // 2
45 | self.bottom = self.pad_h - self.top
46 | self.left = self.pad_w // 2
47 | self.right = self.pad_w - self.left
48 |
49 | def pad(self, frame):
50 | """Pad frame but not its labels"""
51 | self._set_pad(frame)
52 | _pad = [self.left, self.right, self.top, self.bottom]
53 | frame.rename_(None, auto_restore_names=True) # temporarily remove tensor names
54 | frame = F.pad(frame, _pad, mode="replicate") # because F.pad does not support named tensors
55 | return frame
56 |
57 | def unpad(self, tensor):
58 | h, w = tensor.shape[-2:]
59 | top, bottom, left, right = self.top, self.bottom, self.left, self.right
60 | return tensor[..., top : h - bottom, left : w - right]
61 |
--------------------------------------------------------------------------------
/alonet/torch2trt/__init__.py:
--------------------------------------------------------------------------------
1 | from .TRTEngineBuilder import TRTEngineBuilder
2 | from .TRTExecutor import TRTExecutor
3 | from .base_exporter import BaseTRTExporter
4 | from .utils import load_trt_custom_plugins, create_calibrator
5 | from .calibrator import DataBatchStreamer
6 |
7 | from alonet import ALONET_ROOT
8 | import os
9 |
10 |
11 | MS_DEFORM_IM2COL_PLUGIN_LIB = os.path.join(
12 | ALONET_ROOT, "torch2trt/plugins/ms_deform_im2col/build/libms_deform_im2col_trt.so"
13 | )
14 |
--------------------------------------------------------------------------------
/alonet/torch2trt/plugins/make.sh:
--------------------------------------------------------------------------------
1 | # to be run from root of aloception
2 | # add commands for each plugin here for automatic build
3 |
4 | ALONET_ROOT=$1
5 |
6 | # ====== ms_deform_im2col
7 | BUILD_DIR=$ALONET_ROOT/torch2trt/plugins/ms_deform_im2col/build
8 | mkdir -p $BUILD_DIR
9 | cd $BUILD_DIR
10 | cmake ..
11 | make -j
12 | cd -
13 |
--------------------------------------------------------------------------------
/alonet/torch2trt/plugins/ms_deform_im2col/CMakeLists.txt:
--------------------------------------------------------------------------------
1 | # We need cmake >= 3.8, since 3.8 introduced CUDA as a first class language
2 | cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
3 | project(MsDeformIm2ColTRT LANGUAGES CXX CUDA)
4 |
5 | # Enable all compile warnings
6 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic -Wno-deprecated-declarations")
7 |
8 | # Sets variable to a value if variable is unset.
9 | macro(set_ifndef var val)
10 | if (NOT ${var})
11 | set(${var} ${val})
12 | endif()
13 | message(STATUS "Configurable variable ${var} set to ${${var}}")
14 | endmacro()
15 |
16 | # -------- CONFIGURATION --------
17 | set_ifndef(TRT_LIB /home/ubuntu/TensorRT-8.0.0.3/lib)
18 | set_ifndef(TRT_INCLUDE /home/ubuntu/TensorRT-8.0.0.3/include)
19 | set_ifndef(CUDA_INC_DIR /usr/local/cuda/include)
20 | set_ifndef(CUDA_ARCH_SM 70) # should be fine for Tesla V100
21 |
22 | # Find dependencies:
23 | message("\nThe following variables are derived from the values of the previous variables unless provided explicitly:\n")
24 |
25 | # TensorRT's nvinfer lib
26 | find_library(_NVINFER_LIB nvinfer HINTS ${TRT_LIB} PATH_SUFFIXES lib lib64)
27 | set_ifndef(NVINFER_LIB ${_NVINFER_LIB})
28 |
29 |
30 | # -------- BUILDING --------
31 |
32 | # Add include directories
33 | include_directories(${CUDA_INC_DIR} ${TRT_INCLUDE} ${CMAKE_SOURCE_DIR}/sources/)
34 | message(STATUS "CUDA_INC_DIR: ${CUDA_INC_DIR}")
35 | # Define plugin library target
36 | add_library(ms_deform_im2col_trt MODULE
37 | ${CMAKE_SOURCE_DIR}/sources/ms_deform_im2col_kernel.cu
38 | ${CMAKE_SOURCE_DIR}/sources/ms_deform_im2col_kernel.h
39 | ${CMAKE_SOURCE_DIR}/sources/ms_deform_im2col_plugin.cpp
40 | ${CMAKE_SOURCE_DIR}/sources/ms_deform_im2col_plugin.h
41 | )
42 |
43 | # Use C++11
44 | target_compile_features(ms_deform_im2col_trt PUBLIC cxx_std_11)
45 |
46 | # Link TensorRT's nvinfer lib
47 | target_link_libraries(ms_deform_im2col_trt PRIVATE ${NVINFER_LIB})
48 |
49 | # We need to explicitly state that we need all CUDA files
50 | # to be built with -dc as the member functions will be called by
51 | # other libraries and executables (in our case, Python inference scripts)
52 | set_target_properties(ms_deform_im2col_trt PROPERTIES
53 | CUDA_SEPARABLE_COMPILATION ON
54 | )
55 |
56 | # CUDA ARCHITECTURE
57 | set_target_properties(ms_deform_im2col_trt PROPERTIES
58 | CUDA_ARCHITECTURES "${CUDA_ARCH_SM}")
59 |
--------------------------------------------------------------------------------
/alonet/torch2trt/plugins/ms_deform_im2col/README.txt:
--------------------------------------------------------------------------------
1 | To build the plugin:
2 | mkdir build && cd build
3 | cmake .. && make -j
4 |
5 | NOTE: If any of the dependencies are not installed in their default locations, you can manually specify them. For example:
6 |
7 | cmake .. -DPYBIND11_DIR=/path/to/pybind11/
8 | -DCMAKE_CUDA_COMPILER=/usr/local/cuda-x.x/bin/nvcc (Or adding /path/to/nvcc into $PATH)
9 | -DCUDA_INC_DIR=/usr/local/cuda-x.x/include/ (Or adding /path/to/cuda/include into $CPLUS_INCLUDE_PATH)
10 | -DPYTHON3_INC_DIR=/usr/include/python3.6/
11 | -DTRT_LIB=/path/to/tensorrt/lib/
12 | -DTRT_INCLUDE=/path/to/tensorrt/include/
13 | -DCUDA_ARCH_SM=70
14 |
15 | Check matching sm for Nvidia GPU:
16 | https://arnon.dk/matching-sm-architectures-arch-and-gencode-for-various-nvidia-cards/
--------------------------------------------------------------------------------
/alonet/torch2trt/plugins/ms_deform_im2col/sources/ms_deform_im2col_kernel.h:
--------------------------------------------------------------------------------
1 | #ifndef MS_DEFORM_IM2COL_KERNEL
2 | #define MS_DEFORM_IM2COL_KERNEL
3 |
4 | #include "NvInfer.h"
5 | #include "cuda_fp16.h"
6 |
7 | using namespace nvinfer1;
8 |
9 |
10 | int ms_deform_im2col_inference(
11 | cudaStream_t stream,
12 | const void* data_value,
13 | const void* data_spatial_shapes,
14 | const void* data_level_start_index,
15 | const void* data_sampling_loc,
16 | const void* data_attn_weight,
17 | const int batch_size,
18 | const int spatial_size,
19 | const int num_heads,
20 | const int channels,
21 | const int num_levels,
22 | const int num_query,
23 | const int num_point,
24 | void* data_col,
25 | DataType mDataType
26 | );
27 |
28 | #endif
29 |
30 |
--------------------------------------------------------------------------------
/alonet/torch2trt/requirements.txt:
--------------------------------------------------------------------------------
1 | nvidia-pyindex==1.0.9
2 | onnx_graphsurgeon==0.3.14
3 | nvidia-tensorrt==8.2.0.6
4 | pycuda==2020.1
5 |
--------------------------------------------------------------------------------
/alonet/transformers/__init__.py:
--------------------------------------------------------------------------------
1 | from .mlp import MLP
2 | from .position_encoding import PositionEmbeddingSine
3 |
--------------------------------------------------------------------------------
/alonet/transformers/mlp.py:
--------------------------------------------------------------------------------
1 | import torch.nn.functional as F
2 | from torch import nn
3 | import torch
4 |
5 |
6 | class MLP(nn.Module):
7 | """Very simple multi-layer perceptron (also called FFN)"""
8 |
9 | def __init__(self, input_dim, hidden_dim, output_dim, num_layers):
10 | super().__init__()
11 | self.num_layers = num_layers
12 | h = [hidden_dim] * (num_layers - 1)
13 | self.layers = nn.ModuleList(nn.Linear(n, k) for n, k in zip([input_dim] + h, h + [output_dim]))
14 |
15 | def forward(self, x):
16 | for i, layer in enumerate(self.layers):
17 | x = F.relu(layer(x)) if i < self.num_layers - 1 else layer(x)
18 | return x
19 |
--------------------------------------------------------------------------------
/aloscene/io/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/aloscene/io/__init__.py
--------------------------------------------------------------------------------
/aloscene/io/depth.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 |
3 |
4 | def load_depth(path):
5 | """
6 | Load Depth data
7 |
8 | Parameters
9 | ----------
10 | path: str
11 | path to the disparity file. Supported format: {".npy",".npz"}. If your file is stored differently, as an
12 | alternative, you can open the file yourself and then create the Depth augmented Tensor from the depth
13 | data.
14 | """
15 | if path.endswith(".npy"):
16 | return np.load(path)
17 | elif path.endswith(".npz"):
18 | content = np.load(path)
19 | return content[content.keys()[0]]
20 | else:
21 | raise ValueError(
22 | f"Unknown extension for depth file: {path}. As an alternative you can load the file manually\
23 | and then create the Depth augmented tensor from the depth data."
24 | )
25 |
--------------------------------------------------------------------------------
/aloscene/io/flow.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import torch
3 |
4 |
5 | def load_flow_flo(flo_path):
6 | """
7 | Load a 2D flow map with pytorch in float32 format
8 |
9 | Parameters
10 | ----------
11 | flo_path : str
12 | path of the ".flo" file
13 | add_temporal : bool, default=True
14 | add a first dimension for time
15 |
16 | Returns
17 | -------
18 | flow : torch.Tensor
19 | tensor containing the flow map
20 | """
21 | with open(flo_path, "rb") as f:
22 | header = f.read(4)
23 | if header.decode("utf-8") != "PIEH":
24 | raise Exception("Flow file header does not contain PIEH")
25 | width = np.fromfile(f, np.int32, 1).squeeze()
26 | height = np.fromfile(f, np.int32, 1).squeeze()
27 | flow = np.fromfile(f, np.float32, width * height * 2).reshape((height, width, 2))
28 | flow = flow.transpose([2, 0, 1]) # pytorch convention : C, H, W
29 | flow = torch.from_numpy(flow)
30 | return flow
31 |
32 |
33 | def load_flow(flow_path):
34 | if flow_path.endswith(".flo"):
35 | return load_flow_flo(flow_path)
36 | elif flow_path.endswith(".zfd"):
37 | raise Exception("zfd format is not supported.")
38 | else:
39 | raise ValueError(f"Unknown extension for flow file: {flow_path}")
40 |
41 |
42 | def load_scene_flow(path: str) -> np.ndarray:
43 | if not path.endswith(".npy"):
44 | raise ValueError(
45 | f"Scene flow file should be of type .npy, but {path} has the extension .{path.split('.')[-1]}"
46 | )
47 | with open(path, "rb") as file:
48 | return np.load(file)
49 |
--------------------------------------------------------------------------------
/aloscene/io/image.py:
--------------------------------------------------------------------------------
1 | from aloscene.io.utils.errors import InvalidSampleError
2 |
3 | import cv2
4 | import torch
5 | import torchvision
6 | import numpy as np
7 | from torchvision.io.image import ImageReadMode
8 |
9 |
10 | def load_image(image_path):
11 | """
12 | Load an image with pytorch in float32 format
13 |
14 | Parameters
15 | ----------
16 | image_path : str
17 | path of the image
18 |
19 | Returns
20 | -------
21 | image : torch.Tensor
22 | tensor containing the image
23 | """
24 | try:
25 | image = torchvision.io.read_image(image_path, ImageReadMode.RGB).type(torch.float32)
26 | except RuntimeError as e:
27 | try:
28 | image = cv2.imread(image_path)
29 | image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)
30 | image = np.moveaxis(image, 2, 0)
31 | image = torch.Tensor(image).type(torch.float32)
32 | except RuntimeError as e:
33 | raise InvalidSampleError(f"[Alodataset Warning] Invalid image: {image_path} error={e}")
34 | return image
35 |
--------------------------------------------------------------------------------
/aloscene/io/mask.py:
--------------------------------------------------------------------------------
1 | import torch
2 | import torchvision
3 | from aloscene.io.utils.errors import InvalidSampleError
4 | from torchvision.io.image import ImageReadMode
5 |
6 |
7 | def load_mask_png(path):
8 | try:
9 | image = torchvision.io.read_image(path, ImageReadMode.GRAY).type(torch.float32) / 255.0
10 | except RuntimeError as e:
11 | raise InvalidSampleError(f"[Alodataset Warning] Invalid mask file: {path}")
12 | return image
13 |
14 |
15 | def load_mask(path):
16 | if path.endswith(".zfd"):
17 | raise Exception("zfd format is not supported.")
18 | elif path.lower().endswith(".png"):
19 | return load_mask_png(path)
20 | else:
21 | raise ValueError()
22 |
--------------------------------------------------------------------------------
/aloscene/io/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/aloscene/io/utils/__init__.py
--------------------------------------------------------------------------------
/aloscene/io/utils/errors.py:
--------------------------------------------------------------------------------
1 | class InvalidSampleError(Exception):
2 | def __init___(self, *args, **kwargs):
3 | super().__init__(*args, **kwargs)
4 |
--------------------------------------------------------------------------------
/aloscene/matched_indices.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/aloscene/matched_indices.py
--------------------------------------------------------------------------------
/aloscene/pose.py:
--------------------------------------------------------------------------------
1 | from aloscene.camera_calib import CameraExtrinsic
2 | import torch
3 |
4 |
5 | class Pose(CameraExtrinsic):
6 | """Pose Tensor. Usually use to store World2Frame coordinates
7 |
8 | Parameters
9 | ----------
10 | x: torch.Tensor
11 | Pose matrix
12 | """
13 |
14 | @staticmethod
15 | def __new__(cls, x, *args, names=(None, None), **kwargs):
16 | tensor = super().__new__(cls, x, *args, names=names, **kwargs)
17 | return tensor
18 |
19 | def __init__(self, x, *args, **kwargs):
20 | super().__init__(x)
21 |
22 | def _hflip(self, *args, **kwargs):
23 | return self.clone()
24 |
25 | def _vflip(self, *args, **kwargs):
26 | return self.clone()
27 |
28 | def _resize(self, *args, **kwargs):
29 | # Resize image does not change cam extrinsic
30 | return self.clone()
31 |
32 | def _crop(self, *args, **kwargs):
33 | # Cropping image does not change cam extrinsic
34 | return self.clone()
35 |
36 | def _pad(self, *args, **kwargs):
37 | # Padding image does not change cam extrinsic
38 | return self.clone()
39 |
--------------------------------------------------------------------------------
/aloscene/renderer/__init__.py:
--------------------------------------------------------------------------------
1 | from .renderer import View, Renderer, put_adapative_cv2_text, adapt_text_size_to_frame
2 |
--------------------------------------------------------------------------------
/aloscene/tensors/__init__.py:
--------------------------------------------------------------------------------
1 | from .augmented_tensor import AugmentedTensor
2 | from .spatial_augmented_tensor import SpatialAugmentedTensor
3 |
--------------------------------------------------------------------------------
/aloscene/utils/__init__.py:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/aloscene/utils/__init__.py
--------------------------------------------------------------------------------
/aloscene/utils/data_utils.py:
--------------------------------------------------------------------------------
1 | def DLtoLD(d):
2 | """
3 | Transform dict of lists to a list of dicts
4 | """
5 | if not d:
6 | return []
7 | # reserve as much *distinct* dicts as the longest sequence
8 | result = [{} for i in range(max(map(len, d.values())))]
9 | # fill each dict, one key at a time
10 | for k, seq in d.items():
11 | for oneDict, oneValue in zip(result, seq):
12 | oneDict[k] = oneValue
13 | return result
14 |
15 |
16 | def LDtoDL(LD):
17 | """Transform a list of dict to a dict of list"""
18 | DL = {}
19 | for d in LD:
20 | for k, v in d.items():
21 | if k not in DL:
22 | DL[k] = [v]
23 | else:
24 | DL[k].append(v)
25 | return DL
26 |
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/_test_corner_cases.py:
--------------------------------------------------------------------------------
1 | import torch
2 | from oriented_iou_loss import cal_iou
3 |
4 | device = torch.device("cuda:0")
5 | box_0 = torch.tensor([0.0, 0.0, 2.0, 2.0, 0.0], device=device)
6 |
7 |
8 | def test_same_box():
9 | expect = 1.0
10 | box_1 = torch.tensor([0.0, 0.0, 2.0, 2.0, 0.0], device=device)
11 | result = cal_iou(box_0[None, None, ...], box_1[None, None, ...])[0].cpu().numpy()
12 | print("expect:", expect, "get:", result[0, 0])
13 |
14 |
15 | def test_same_edge():
16 | expect = 0.0
17 | box_1 = torch.tensor([0.0, 2, 2.0, 2.0, 0.0], device=device)
18 | result = cal_iou(box_0[None, None, ...], box_1[None, None, ...])[0].cpu().numpy()
19 | print("expect:", expect, "get:", result[0, 0])
20 |
21 |
22 | def test_same_edge_offset():
23 | expect = 0.3333
24 | box_1 = torch.tensor([0.0, 1.0, 2.0, 2.0, 0.0], device=device)
25 | result = cal_iou(box_0[None, None, ...], box_1[None, None, ...])[0].cpu().numpy()
26 | print("expect:", expect, "get:", result[0, 0])
27 |
28 |
29 | def test_same_box2():
30 | expect = 1
31 | box_1 = torch.tensor([38, 120, 1.3, 20, 50], device=device)
32 | result = cal_iou(box_1[None, None, ...], box_1[None, None, ...])[0].cpu().numpy()
33 | print("expect:", expect, "get:", result[0, 0])
34 |
35 |
36 | if __name__ == "__main__":
37 | test_same_box()
38 | test_same_edge()
39 | test_same_edge_offset()
40 | test_same_box2()
41 |
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/build/lib.linux-x86_64-3.8/sort_vertices.cpython-38-x86_64-linux-gnu.so:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/aloscene/utils/rotated_iou/cuda_op/build/lib.linux-x86_64-3.8/sort_vertices.cpython-38-x86_64-linux-gnu.so
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/.ninja_deps:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/.ninja_deps
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/.ninja_log:
--------------------------------------------------------------------------------
1 | # ninja log v5
2 | 0 12392 1630925914680258205 /home/thibault/work/aloception/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/sort_vert.o 2d2fe61c5d5a0e5c
3 | 1 6508 1630926122393554458 /home/thibault/work/aloception/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/sort_vert_kernel.o 2146f1f8c5ae4202
4 | 1 12590 1630926128469592730 /home/thibault/work/aloception/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/sort_vert.o 2d2fe61c5d5a0e5c
5 |
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/sort_vert.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/sort_vert.o
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/sort_vert_kernel.o:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/aloscene/utils/rotated_iou/cuda_op/build/temp.linux-x86_64-3.8/sort_vert_kernel.o
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/cuda_ext.py:
--------------------------------------------------------------------------------
1 | import torch
2 | from torch import nn
3 | from torch.autograd import Function
4 | try:
5 | import sort_vertices
6 | sort_vertices_error = None
7 | except Exception as e:
8 | sort_vertices= None
9 | sort_vertices_error = e
10 | pass
11 |
12 |
13 | class SortVertices(Function):
14 | @staticmethod
15 | def forward(ctx, vertices, mask, num_valid):
16 |
17 | if sort_vertices is None:
18 | raise Exception(f"To install: cd aloception/aloscene/utils/rotated_iou/cuda_op; python setup.py install --user. Error={sort_vertices_error}")
19 |
20 | idx = sort_vertices.sort_vertices_forward(vertices, mask, num_valid)
21 | ctx.mark_non_differentiable(idx)
22 | return idx
23 |
24 | @staticmethod
25 | def backward(ctx, gradout):
26 | return ()
27 |
28 |
29 | sort_v = SortVertices.apply
30 |
31 | if __name__ == "__main__":
32 | import time
33 |
34 | v = torch.rand([8, 1024, 24, 2]).float().cuda()
35 | mean = torch.mean(v, dim=2, keepdim=True)
36 | v = v - mean
37 | m = (torch.rand([8, 1024, 24]) > 0.8).cuda()
38 | nv = torch.sum(m.int(), dim=-1).int().cuda()
39 | start = time.time()
40 | result = sort_v(v, m, nv)
41 | torch.cuda.synchronize()
42 | print("time: %.2f ms" % ((time.time() - start) * 1000))
43 | print(result.size())
44 | print(result[0, 0, :])
45 |
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/cuda_utils.h:
--------------------------------------------------------------------------------
1 | #ifndef _CUDA_UTILS_H
2 | #define _CUDA_UTILS_H
3 |
4 | #include
5 | #include
6 | #include
7 | #include
8 | #include
9 | #include
10 |
11 | #define TOTAL_THREADS 512
12 |
13 | inline int opt_n_thread(int work_size){
14 | const int pow_2 = std::log(static_cast(work_size)) / std::log(2.0);
15 | return max(min(1<(), mask.data_ptr(),
24 | num_valid.data_ptr(), idx.data_ptr());
25 |
26 | return idx;
27 | }
28 |
29 | PYBIND11_MODULE(TORCH_EXTENSION_NAME, m){
30 | m.def("sort_vertices_forward", &sort_vertices, "sort vertices of a convex polygon. forward only");
31 | }
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/sort_vert.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 |
4 | #define MAX_NUM_VERT_IDX 9
5 |
6 | at::Tensor sort_vertices(at::Tensor vertices, at::Tensor mask, at::Tensor num_valid);
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/sort_vertices.egg-info/PKG-INFO:
--------------------------------------------------------------------------------
1 | Metadata-Version: 1.0
2 | Name: sort-vertices
3 | Version: 0.0.0
4 | Summary: UNKNOWN
5 | Home-page: UNKNOWN
6 | Author: UNKNOWN
7 | Author-email: UNKNOWN
8 | License: UNKNOWN
9 | Description: UNKNOWN
10 | Platform: UNKNOWN
11 |
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/sort_vertices.egg-info/SOURCES.txt:
--------------------------------------------------------------------------------
1 | setup.py
2 | sort_vert.cpp
3 | sort_vert_kernel.cu
4 | sort_vertices.egg-info/PKG-INFO
5 | sort_vertices.egg-info/SOURCES.txt
6 | sort_vertices.egg-info/dependency_links.txt
7 | sort_vertices.egg-info/top_level.txt
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/sort_vertices.egg-info/dependency_links.txt:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/sort_vertices.egg-info/top_level.txt:
--------------------------------------------------------------------------------
1 | sort_vertices
2 |
--------------------------------------------------------------------------------
/aloscene/utils/rotated_iou/cuda_op/utils.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include
3 | #include
4 |
5 | #define CHECK_CUDA(x) \
6 | do { \
7 | TORCH_CHECK(x.is_cuda(), #x " must be a CUDA tensor"); \
8 | } while (0)
9 |
10 | #define CHECK_CONTIGUOUS(x) \
11 | do { \
12 | TORCH_CHECK(x.is_contiguous(), #x " must ne a contiguous tensor"); \
13 | } while (0)
14 |
15 | #define CHECK_IS_INT(x) \
16 | do { \
17 | TORCH_CHECK(x.scalar_type()==at::ScalarType::Int, \
18 | #x " must be a int tensor"); \
19 | } while (0)
20 |
21 | #define CHECK_IS_FLOAT(x) \
22 | do { \
23 | TORCH_CHECK(x.scalar_type()==at::ScalarType::Float, \
24 | #x " must be a float tensor"); \
25 | } while (0)
26 |
27 | #define CHECK_IS_BOOL(x) \
28 | do { \
29 | TORCH_CHECK(x.scalar_type()==at::ScalarType::Bool, \
30 | #x " must be a bool tensor"); \
31 | } while (0)
--------------------------------------------------------------------------------
/dev_requirements.txt:
--------------------------------------------------------------------------------
1 | flake8>=3.0.0
2 | flake8_black>=0.2.3
3 | black>=21.7
4 | pydocstyle>=6.1.1
5 |
--------------------------------------------------------------------------------
/docs/.buildinfo:
--------------------------------------------------------------------------------
1 | # Sphinx build info version 1
2 | # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
3 | config: 4373a2a91504f77c561b8f32c2afd8ef
4 | tags: 645f666f9bcd5a90fca523b33c5a78b7
5 |
--------------------------------------------------------------------------------
/docs/.nojekyll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/.nojekyll
--------------------------------------------------------------------------------
/docs/_images/aloception.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/aloception.png
--------------------------------------------------------------------------------
/docs/_images/aloscene_notebooks_bounding_boxes_3d_11_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/aloscene_notebooks_bounding_boxes_3d_11_0.png
--------------------------------------------------------------------------------
/docs/_images/aloscene_notebooks_bounding_boxes_3d_16_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/aloscene_notebooks_bounding_boxes_3d_16_0.png
--------------------------------------------------------------------------------
/docs/_images/aloscene_notebooks_bounding_boxes_3d_17_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/aloscene_notebooks_bounding_boxes_3d_17_0.png
--------------------------------------------------------------------------------
/docs/_images/aloscene_notebooks_bounding_boxes_3d_9_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/aloscene_notebooks_bounding_boxes_3d_9_0.png
--------------------------------------------------------------------------------
/docs/_images/disp_hflip.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/disp_hflip.jpg
--------------------------------------------------------------------------------
/docs/_images/disp_view.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/disp_view.jpg
--------------------------------------------------------------------------------
/docs/_images/flow_hflip.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/flow_hflip.jpg
--------------------------------------------------------------------------------
/docs/_images/flow_view.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/flow_view.jpg
--------------------------------------------------------------------------------
/docs/_images/getting_started_alodataset_10_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_alodataset_10_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_alodataset_14_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_alodataset_14_1.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_alodataset_3_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_alodataset_3_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_alodataset_3_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_alodataset_3_1.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_alodataset_3_2.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_alodataset_3_2.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_alodataset_7_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_alodataset_7_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_aloscene_11_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_aloscene_11_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_aloscene_19_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_aloscene_19_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_aloscene_21_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_aloscene_21_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_aloscene_23_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_aloscene_23_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_aloscene_2_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_aloscene_2_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_augmented_tensor_10_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_augmented_tensor_10_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_augmented_tensor_14_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_augmented_tensor_14_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_augmented_tensor_19_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_augmented_tensor_19_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_augmented_tensor_1_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_augmented_tensor_1_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_augmented_tensor_21_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_augmented_tensor_21_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_augmented_tensor_24_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_augmented_tensor_24_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_augmented_tensor_30_0.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_augmented_tensor_30_0.png
--------------------------------------------------------------------------------
/docs/_images/getting_started_augmented_tensor_7_1.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/getting_started_augmented_tensor_7_1.png
--------------------------------------------------------------------------------
/docs/_images/panoptic_head.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/panoptic_head.png
--------------------------------------------------------------------------------
/docs/_images/points2d_header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_images/points2d_header.png
--------------------------------------------------------------------------------
/docs/_sources/alodataset/alodataset.rst.txt:
--------------------------------------------------------------------------------
1 | Alodataset
2 | ==============
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | transform
8 | base_dataset
9 | merge_dataset
10 | chairssdhom_dataset
11 | coco_detection_dataset
12 | crowd_human_dataset.rst
13 | flyingthings3D_subset_dataset.rst
14 | flying_chairs2_dataset.rst
15 | waymo_dataset.rst
16 | mot17
17 | sintel_flow_dataset.rst
18 | sintel_disparity_dataset.rst
19 | sintel_multi_dataset.rst
20 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/base_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | Base dataset
4 | ---------------------
5 |
6 | .. automodule:: alodataset.base_dataset
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
11 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/chairssdhom_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | ChairsSDHom
2 | ###########
3 |
4 | This dataset is part of the `Optical Flow datasets
5 | `_
6 | provided by the Computer Science Group of the University of Freiburg.
7 |
8 |
9 | - For more information about the dataset, please refer to the `CVPR2017 paper `_.
10 | - To download the dataset, please follow instructions at `this link `_ in the section *The "ChairsSDHom" Dataset*.
11 |
12 | ChairsSDHomDataset API
13 | **********************
14 |
15 | .. automodule:: alodataset.chairssdhom_dataset
16 | :members:
17 | :undoc-members:
18 | :show-inheritance:
19 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/crowd_human_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | Crowd human
4 | ---------------------
5 |
6 | .. automodule:: alodataset.crowd_human_dataset
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/flying_chairs2_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | FlyingChairs2
2 | #############
3 |
4 | This dataset is part of the `Optical Flow datasets
5 | `_
6 | provided by the Computer Science Group of the University of Freiburg.
7 |
8 |
9 | - For more information about the dataset, please refer to the `ECCV2018 paper `_.
10 | - To download the dataset, please follow instructions at `this link `_ in the section *The "Flying Chairs 2" Dataset*.
11 |
12 |
13 | FlyingChairs2 API
14 | *****************
15 |
16 | .. automodule:: alodataset.flying_chairs2_dataset
17 | :members:
18 | :undoc-members:
19 | :show-inheritance:
20 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/flyingthings3D_subset_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | Flyingthings3D Subset
2 | ---------------------
3 |
4 | This dataset is part of the `Scene Flow datasets
5 | `_
6 | provided by the Computer Science Group of the University of Freiburg.
7 |
8 | This is a synthetic dataset containing optical flow and disparity, with occlusion, for two cameras (left/right).
9 |
10 |
11 | - For more information about the dataset, please refer to the `CVPR2016 paper `_.
12 | - To download the dataset, please follow instructions at `this link `_ in the section *DispNet/FlowNet2.0 dataset subsets*.
13 |
14 | Flyingthings3DSubsetDataset API
15 | ===============================
16 |
17 | .. automodule:: alodataset.flyingthings3D_subset_dataset
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/merge_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | Merging datasets
2 | ----------------
3 |
4 | Basic usage
5 | ===========
6 |
7 | The class :attr:`MergeDataset` is used to merge multiple datasets::
8 |
9 | from alodataset import FlyingThings3DSubsetDataset, MergeDataset
10 | dataset1 = FlyingThings3DSubsetDataset(sequence_size=2, transform_fn=lambda f: f["left"])
11 | dataset2 = FlyingThings3DSubsetDataset(sequence_size=2, transform_fn=lambda f: f["right"])
12 | dataset = MergeDataset([dataset1, dataset2])
13 |
14 | It is then possible to shuffle the datasets together, and sample batches than can contain items from different datasets::
15 |
16 | # this batch can contain items from dataset1 and/or dataset2
17 | batch = next(iter(dataset.train_loader(batch_size=4)))
18 |
19 | It is possible to apply specific transformations to each dataset,
20 | and then apply the same global transformation to the items::
21 |
22 | from alodataset.transforms import RandomCrop
23 | dataset1 = FlyingThings3DSubsetDataset(sequence_size=2, transform_fn=lambda f: f["left"]) # specific transform
24 | dataset2 = FlyingThings3DSubsetDataset(sequence_size=2, transform_fn=lambda f: f["right"]) # specific transform
25 | dataset = MergeDataset([dataset1, dataset2], transform_fn=RandomCrop(size=(368, 496)) # global transform
26 |
27 | MergeDataset API
28 | ================
29 |
30 | .. automodule:: alodataset.merge_dataset
31 | :members:
32 | :undoc-members:
33 | :show-inheritance:
34 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/mot17.rst.txt:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | MOT17
4 | ---------------------
5 |
6 | .. automodule:: alodataset.mot17
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/sintel_disparity_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | Sintel Disparity
2 | ################
3 |
4 | The MPI Sintel Disparity is an extension to the Sintel Flow Dataset. This dataset contains disparity annotations and occlusions.
5 |
6 | - To download the dataset and have more information, `follow this link `_.
7 | - The main conference paper for more detailed information is available `here `_. Other references are listed in the previous link.
8 |
9 |
10 | SintelDisparityDataset API
11 | ***************************
12 |
13 | .. automodule:: alodataset.sintel_disparity_dataset
14 | :members:
15 | :undoc-members:
16 | :show-inheritance:
17 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/sintel_flow_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | Sintel Optical Flow
2 | ###################
3 |
4 | The MPI Sintel Flow Dataset is a dataset for the evaluation of optical flow derived from the open source 3D animated
5 | short film, Sintel.
6 |
7 | - To download the dataset and have more information, `follow this link `_.
8 | - The main conference paper for more detailed information is available `here `_. Other references are listed in the previous link.
9 |
10 |
11 | SintelFlowDataset API
12 | *********************
13 |
14 | .. automodule:: alodataset.sintel_flow_dataset
15 | :members:
16 | :undoc-members:
17 | :show-inheritance:
18 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/sintel_multi_dataset.rst.txt:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | Sintel Multi (Flow + Disparity)
4 | -------------------------------
5 |
6 | .. automodule:: alodataset.sintel_multi_dataset
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docs/_sources/alodataset/transform.rst.txt:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | Transformations
4 | ---------------------
5 |
6 | .. automodule:: alodataset.transforms
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
11 |
12 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/alonet.callbacks.rst.txt:
--------------------------------------------------------------------------------
1 | Callbacks
2 | ========================
3 |
4 | List of callbacks used in different modules, in order to present different metrics while them are training. See
5 | `Callbacks `_ to get more information.
6 |
7 | Base Metrics Callback
8 | ----------------------------------------------
9 |
10 | .. automodule:: alonet.callbacks.base_metrics_callback
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 |
16 | AP Metrics Callback
17 | ----------------------------------------------
18 |
19 | .. automodule:: alonet.callbacks.map_metrics_callback
20 | :members:
21 | :undoc-members:
22 | :show-inheritance:
23 |
24 |
25 | PQ Metrics Callback
26 | ----------------------------------------------
27 |
28 | .. automodule:: alonet.callbacks.pq_metrics_callback
29 | :members:
30 | :undoc-members:
31 | :show-inheritance:
32 |
33 |
34 | Metrics Callbacks
35 | -----------------------------------------
36 |
37 | .. automodule:: alonet.callbacks.metrics_callback
38 | :members:
39 | :undoc-members:
40 | :show-inheritance:
41 |
42 |
43 | Object Detector Callback
44 | --------------------------------------------------
45 |
46 | .. automodule:: alonet.callbacks.object_detector_callback
47 | :members:
48 | :undoc-members:
49 | :show-inheritance:
50 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/alonet.rst.txt:
--------------------------------------------------------------------------------
1 | Alonet
2 | ==============
3 |
4 |
5 | .. toctree::
6 | :maxdepth: 2
7 |
8 | detr
9 | deformable
10 | panoptic
11 | alonet.callbacks
12 | alonet.metrics
13 | alonet.transformers
14 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/alonet.transformers.rst.txt:
--------------------------------------------------------------------------------
1 | Transformer
2 | ===========================
3 |
4 | MLP
5 | ------------------------------
6 |
7 | .. automodule:: alonet.transformers.mlp
8 | :members:
9 | :undoc-members:
10 | :show-inheritance:
11 |
12 |
13 | Positional Encoding
14 | ---------------------------------------------
15 |
16 | .. automodule:: alonet.transformers.position_encoding
17 | :members:
18 | :undoc-members:
19 | :show-inheritance:
20 |
21 |
22 | Transformer
23 | ---------------
24 |
25 | .. automodule:: alonet.transformers
26 | :members:
27 | :undoc-members:
28 | :show-inheritance:
29 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/deformable.rst.txt:
--------------------------------------------------------------------------------
1 | Deformable DETR
2 | ==========================
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 | :caption: API
7 |
8 | deformable_models
9 | deformable_architecture
10 | deformable_training
11 |
12 |
13 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/deformable_architecture.rst.txt:
--------------------------------------------------------------------------------
1 | Architecture
2 | =============================
3 |
4 |
5 | Backbone
6 | ---------------------------------------
7 |
8 | .. automodule:: alonet.deformable_detr.backbone
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 |
14 | Transformer
15 | ------------------------------------------------------
16 |
17 | .. automodule:: alonet.deformable_detr.deformable_transformer
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
--------------------------------------------------------------------------------
/docs/_sources/alonet/deformable_training.rst.txt:
--------------------------------------------------------------------------------
1 | Training
2 | =========================
3 |
4 |
5 | Training
6 | ------------------------------------
7 |
8 | .. automodule:: alonet.deformable_detr.train
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 | Callbacks
14 | ----------------------------------------
15 |
16 | .. automodule:: alonet.deformable_detr.callbacks
17 | :members:
18 | :undoc-members:
19 | :show-inheritance:
20 |
21 | Criterion
22 | ----------------------------------------
23 |
24 | .. automodule:: alonet.deformable_detr.criterion
25 | :members:
26 | :undoc-members:
27 | :show-inheritance:
28 |
29 |
30 | Matcher
31 | --------------------------------------
32 |
33 | .. automodule:: alonet.deformable_detr.matcher
34 | :members:
35 | :undoc-members:
36 | :show-inheritance:
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/detr.rst.txt:
--------------------------------------------------------------------------------
1 | Detr
2 | ==========================
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 | :caption: API
7 |
8 | detr_models
9 | detr_architecture
10 | detr_training
11 | detr_connectors
12 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/detr_architecture.rst.txt:
--------------------------------------------------------------------------------
1 | Architecture
2 | ===================
3 |
4 |
5 | Backbone
6 | ---------------------------
7 |
8 | .. automodule:: alonet.detr.backbone
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 |
14 | Transformer
15 | ------------------------------
16 |
17 | .. automodule:: alonet.detr.transformer
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/detr_models.rst.txt:
--------------------------------------------------------------------------------
1 | Models
2 | ===================
3 |
4 | Basic usage
5 | --------------------
6 |
7 | To instantiate a DETR R50 (resnet50 backbone):
8 |
9 | .. code-block:: python
10 |
11 | from alonet.detr import DetrR50
12 | model = DetrR50()
13 |
14 | If you want to finetune from the model pretrained on COCO dataset:
15 |
16 | .. code-block:: python
17 |
18 | from alonet.detr import DetrR50Finetune
19 | # NUM_CLASS is the number of classes in your finetune
20 | model = DetrR50Finetune(num_classes=NUM_CLASS, weights="detr-r50")
21 |
22 | To run inference:
23 |
24 | .. code-block:: python
25 |
26 | from aloscene import Frame
27 | device = model.device # supposed that `model` is already defined as above
28 |
29 | # read image and preprocess image with Resnet normalization
30 | frame = aloscene.Frame(PATH_TO_IMAGE).norm_resnet()
31 | # create a batch from a list of images
32 | frames = aloscene.Frame.batch_list([frame])
33 | frames = frames.to(device)
34 |
35 | # forward pass
36 | m_outputs = model(frames)
37 | # get predicted boxes as aloscene.BoundingBoxes2D from forward outputs
38 | pred_boxes = model.inference(m_outputs)
39 | # Display the predicted boxes
40 | frame.append_boxes2d(pred_boxes[0], "pred_boxes")
41 | frame.get_view([frame.boxes2d]).render()
42 |
43 | Detr Base
44 | -----------------------
45 |
46 | .. automodule:: alonet.detr.detr
47 | :members:
48 | :undoc-members:
49 | :show-inheritance:
50 |
51 |
52 | Detr R50
53 | ----------------------------
54 |
55 | .. automodule:: alonet.detr.detr_r50
56 | :members:
57 | :undoc-members:
58 | :show-inheritance:
59 |
60 |
61 | Detr R50 Finetune
62 | --------------------------------------
63 |
64 | .. automodule:: alonet.detr.detr_r50_finetune
65 | :members:
66 | :undoc-members:
67 | :show-inheritance:
68 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/detr_training.rst.txt:
--------------------------------------------------------------------------------
1 | Training
2 | ===================
3 |
4 |
5 | Training
6 | ------------------------
7 |
8 | .. automodule:: alonet.detr.train
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 |
14 | Criterion
15 | ----------------------------
16 |
17 | .. automodule:: alonet.detr.criterion
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 | Matcher
23 | --------------------------
24 |
25 | .. automodule:: alonet.detr.matcher
26 | :members:
27 | :undoc-members:
28 | :show-inheritance:
29 |
30 |
31 | Callbacks
32 | ----------------------------
33 |
34 | .. automodule:: alonet.detr.callbacks
35 | :members:
36 | :undoc-members:
37 | :show-inheritance:
38 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/panoptic.rst.txt:
--------------------------------------------------------------------------------
1 | Detr panoptic
2 | ==========================
3 |
4 | The module allows the implementation of a neural network that connects the output of a |detr|_ for the prediction of
5 | segmentation maps, according to the boxes predicted from the base model.
6 |
7 | .. toctree::
8 | :maxdepth: 3
9 | :caption: API
10 |
11 | panoptic_models
12 | panoptic_training
13 |
14 | .. Hyperlinks
15 | .. |detr| replace:: Detr-based models
16 | .. _detr: detr_models.html#module-alonet.detr.detr
17 |
--------------------------------------------------------------------------------
/docs/_sources/alonet/panoptic_training.rst.txt:
--------------------------------------------------------------------------------
1 | Training
2 | =========================
3 |
4 | For training, :mod:`LitPanopticDetr ` implements a
5 | `Pytorch Lightning Module `_ that
6 | uses as default the :mod:`~alonet.detr.detr_r50` module coupled with :mod:`~alonet.detr_panoptic.detr_panoptic`.
7 | For this reason, :mod:`alonet.detr.criterion` and :mod:`alonet.detr.matcher` are used in the training. However,
8 | the :mod:`alonet.detr_panoptic.callbacks` are adapted to the predictions of the masks in the inference process.
9 |
10 | Training
11 | ------------------------------------
12 |
13 | .. automodule:: alonet.detr_panoptic.train
14 | :members:
15 | :undoc-members:
16 | :show-inheritance:
17 |
18 | Callbacks
19 | ----------------------------------------
20 |
21 | .. automodule:: alonet.detr_panoptic.callbacks
22 | :members:
23 | :undoc-members:
24 | :show-inheritance:
25 |
26 | .. Criterion
27 | .. ----------------------------------------
28 |
29 | .. .. automodule:: alonet.detr.criterion
30 | .. :members:
31 | .. :undoc-members:
32 | .. :show-inheritance:
33 |
34 |
35 | .. Matcher
36 | .. --------------------------------------
37 |
38 | .. .. automodule:: alonet.detr.matcher
39 | .. :members:
40 | .. :undoc-members:
41 | .. :show-inheritance:
42 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/aloscene.rst.txt:
--------------------------------------------------------------------------------
1 | Aloscene
2 | ================
3 |
4 |
5 | .. toctree::
6 | :maxdepth: 3
7 | :caption: Package Reference
8 |
9 | frame
10 | bounding_boxes_2d
11 | oriented_boxes_2d
12 | points2d
13 | labels
14 | mask
15 | flow
16 | disparity
17 | bounding_boxes_3d
18 | camera_calib
19 |
20 | .. toctree::
21 | :maxdepth: 3
22 | :caption: Augmented Tensor
23 |
24 | augmented_tensor
25 | spatial_augmented_tensor
26 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/augmented_tensor.rst.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | Augmented Tensor
4 | -----------------------------------------
5 |
6 | .. automodule:: aloscene.tensors.augmented_tensor
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
11 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/bounding_boxes_2d.rst.txt:
--------------------------------------------------------------------------------
1 |
2 | BoundingBoxes2D
3 | ---------------------
4 |
5 | .. automodule:: aloscene.bounding_boxes_2d
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
--------------------------------------------------------------------------------
/docs/_sources/aloscene/bounding_boxes_3d.rst.txt:
--------------------------------------------------------------------------------
1 | BoundingBoxes3D
2 | ======================
3 |
4 | Bounding Boxes 3D Tensor of shape (n, 7) of which the last dimension is : [xc, yc, zc, Dx, Dy, Dz, heading]
5 |
6 | - Coordinate xc, yc, zc of boxes’ center
7 | - Boxes’ dimension Dx, Dy, Dz along the 3 axis
8 | - Heading is the orientation by rotating around vertical Y-axis.
9 |
10 | With this coordinate system convention:
11 |
12 | - The X axis is positive to the right
13 | - The Y axis is positive downwards
14 | - The Z axis is positive forwards
15 |
16 | .. toctree::
17 | :maxdepth: 0
18 | :caption: Basic usage:
19 |
20 | notebooks/bounding_boxes_3d.ipynb
21 |
22 |
23 | API
24 | --------
25 |
26 | .. automodule:: aloscene.bounding_boxes_3d
27 | :members:
28 | :undoc-members:
29 | :show-inheritance:
30 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/camera_calib.rst.txt:
--------------------------------------------------------------------------------
1 | Camera calibration
2 | ---------------------
3 |
4 | .. automodule:: aloscene.camera_calib
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/frame.rst.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | Frame
4 | ---------------------
5 |
6 | .. automodule:: aloscene.frame
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/labels.rst.txt:
--------------------------------------------------------------------------------
1 |
2 | Label
3 | ---------------------
4 |
5 | .. automodule:: aloscene.labels
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
--------------------------------------------------------------------------------
/docs/_sources/aloscene/mask.rst.txt:
--------------------------------------------------------------------------------
1 | Mask
2 | ----
3 |
4 | The aloscene :attr:`Mask` object represents a binary or float mask. It can be used to represent different objects,
5 | for example occlusions mask for flow and disparity use cases.
6 |
7 | .. note::
8 |
9 | The values of a :attr:`Mask` are between 0. and 1., to allow to partially/completely mask another tensor
10 | by multiplying it by the mask.
11 |
12 | Basic Use
13 | =========
14 |
15 | A :attr:`Mask` object can be initialized from a path to a mask file::
16 |
17 | from aloscene import Mask
18 | mask = Mask("path/to/mask.png")
19 |
20 | or from an existing tensor::
21 |
22 | import torch
23 | mask_float_tensor = torch.rand((1,400,600))
24 | mask = Mask(mask_tensor, names=("C","H","W"))
25 |
26 |
27 | Mask API
28 | --------
29 |
30 | .. automodule:: aloscene.mask
31 | :members:
32 | :undoc-members:
33 | :show-inheritance:
34 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/oriented_boxes_2d.rst.txt:
--------------------------------------------------------------------------------
1 | OrientedBoxes2D
2 | ====================
3 |
4 | Oriented Boxes 2D is defined by [x, y, w, h, theta] in which:
5 |
6 | - x, y: center coordinates (could be relative or absolute values)
7 | - w, h: width, height (could be relative or absolute values)
8 | - theta: rotation angle
9 |
10 | Basic usage
11 | ---------------
12 |
13 | .. code-block:: python
14 |
15 | import numpy as np
16 | import torch
17 | from aloscene import OrientedBoxes2D
18 |
19 | boxes = OrientedBoxes2D(
20 | torch.tensor(
21 | [
22 | # [x, y, w, h, theta]
23 | [0.5, 0.5, 0.2, 0.2, 0],
24 | [0.1, 0.1, 0.2, 0.3, np.pi / 6],
25 | [0.1, 0.8, 0.1, 0.3, -np.pi / 3],
26 | [0.6, 0.3, 0.4, 0.2, np.pi / 4],
27 | ],
28 | device=torch.device("cuda"),
29 | ),
30 | absolute=False, # use relative values for x, y, w, h
31 | )
32 |
33 | boxes.get_view().render()
34 |
35 | Get coordinates of 4 corners for each boxes:
36 |
37 | .. code-block:: python
38 |
39 | print(boxes.corners())
40 |
41 | Convert to absolute value format with frame size = (300, 300):
42 |
43 | .. code-block:: python
44 |
45 | abs_boxes = boxes.abs_boxes((300, 300))
46 | print(abs_boxes)
47 | print(abs_boxes.absolute) # True
48 | print(abs_boxes.rel_pos() == boxes) # True
49 |
50 | Calucate oriented IoU/GIoU with another set of boxes:
51 |
52 | .. code-block:: python
53 |
54 | boxes2 = OrientedBoxes2D(
55 | torch.tensor(
56 | [
57 | [1, 1, 2, 2, 0],
58 | [5, 5, 2, 3, np.pi / 6],
59 | [1, 1, 1, 3, -np.pi / 3],
60 | [3, 1, 4, 2, np.pi / 4]
61 | ],
62 | device=torch.device("cuda")
63 | )
64 | )
65 | iou = boxes.rotated_iou_with(boxes2)
66 | giou = boxes.rotated_giou_with(boxes2)
67 | print(iou)
68 | print(giou)
69 |
70 |
71 | API
72 | ---------------------
73 |
74 | .. automodule:: aloscene.oriented_boxes_2d
75 | :members:
76 | :undoc-members:
77 | :show-inheritance:
78 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/points2d.rst.txt:
--------------------------------------------------------------------------------
1 |
2 | Points2D
3 | ---------------------
4 |
5 | .. image:: ../images/points2d_header.png
6 | :width: 100%
7 | :alt: Points2D Header
8 |
9 |
10 | .. automodule:: aloscene.points_2d
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
--------------------------------------------------------------------------------
/docs/_sources/aloscene/spatial_augmented_tensor.rst.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | Spatial Augmented Tensor
4 | --------------------------------------------------
5 |
6 | .. automodule:: aloscene.tensors.spatial_augmented_tensor
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docs/_sources/getting_started/alodataset.rst.txt:
--------------------------------------------------------------------------------
1 | Alodataset: Loading your datasets
2 | --------------------------------------------------
3 |
--------------------------------------------------------------------------------
/docs/_sources/getting_started/alonet.rst.txt:
--------------------------------------------------------------------------------
1 | Alonet: Loading & training your models
2 | --------------------------------------------------
--------------------------------------------------------------------------------
/docs/_sources/getting_started/augmented_tensor.rst.txt:
--------------------------------------------------------------------------------
1 | About Augmented Tensor
2 | --------------------------------------------------
--------------------------------------------------------------------------------
/docs/_sources/index.rst.txt:
--------------------------------------------------------------------------------
1 |
2 |
3 | Aloception's documentation
4 | ==========================
5 |
6 | .. toctree::
7 | :maxdepth: 2
8 | :caption: Geting Started
9 |
10 | getting_started/getting_started
11 | getting_started/aloscene
12 | getting_started/alodataset
13 | getting_started/alonet
14 | getting_started/augmented_tensor
15 |
16 | .. toctree::
17 | :maxdepth: 2
18 | :caption: Turorials
19 |
20 | tutorials/data_setup
21 | tutorials/training_detr
22 | tutorials/finetuning_detr
23 | tutorials/training_panoptic
24 | tutorials/training_deformable_detr
25 | tutorials/finetuning_deformable_detr
26 | tutorials/tensort_inference
27 |
28 |
29 | .. toctree::
30 | :maxdepth: 3
31 | :caption: Aloception API
32 |
33 | aloscene/aloscene
34 | alodataset/alodataset
35 | alonet/alonet
36 |
--------------------------------------------------------------------------------
/docs/_sources/tutorials/tensort_inference.rst.txt:
--------------------------------------------------------------------------------
1 | Exporting DETR / Deformable-DETR to TensorRT
2 | --------------------------------------------------
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 | :caption: Contents:
7 |
8 | export_tensorrt/Tutorial - Export DETR to TensorRT and inference.ipynb
9 | export_tensorrt/Tutorial - Export Deformable DETR to TensorRT and inference.ipynb
--------------------------------------------------------------------------------
/docs/_sources/tutorials/training_raft.rst.txt:
--------------------------------------------------------------------------------
1 | Training RAFT
2 | --------------------------------------------------
--------------------------------------------------------------------------------
/docs/_static/css/fonts/Roboto-Slab-Bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/Roboto-Slab-Bold.woff
--------------------------------------------------------------------------------
/docs/_static/css/fonts/Roboto-Slab-Bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/Roboto-Slab-Bold.woff2
--------------------------------------------------------------------------------
/docs/_static/css/fonts/Roboto-Slab-Regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/Roboto-Slab-Regular.woff
--------------------------------------------------------------------------------
/docs/_static/css/fonts/Roboto-Slab-Regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/Roboto-Slab-Regular.woff2
--------------------------------------------------------------------------------
/docs/_static/css/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/docs/_static/css/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/docs/_static/css/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/docs/_static/css/fonts/fontawesome-webfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/fontawesome-webfont.woff2
--------------------------------------------------------------------------------
/docs/_static/css/fonts/lato-bold-italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/lato-bold-italic.woff
--------------------------------------------------------------------------------
/docs/_static/css/fonts/lato-bold-italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/lato-bold-italic.woff2
--------------------------------------------------------------------------------
/docs/_static/css/fonts/lato-bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/lato-bold.woff
--------------------------------------------------------------------------------
/docs/_static/css/fonts/lato-bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/lato-bold.woff2
--------------------------------------------------------------------------------
/docs/_static/css/fonts/lato-normal-italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/lato-normal-italic.woff
--------------------------------------------------------------------------------
/docs/_static/css/fonts/lato-normal-italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/lato-normal-italic.woff2
--------------------------------------------------------------------------------
/docs/_static/css/fonts/lato-normal.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/lato-normal.woff
--------------------------------------------------------------------------------
/docs/_static/css/fonts/lato-normal.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/css/fonts/lato-normal.woff2
--------------------------------------------------------------------------------
/docs/_static/documentation_options.js:
--------------------------------------------------------------------------------
1 | var DOCUMENTATION_OPTIONS = {
2 | URL_ROOT: document.getElementById("documentation_options").getAttribute('data-url_root'),
3 | VERSION: '0.0.1',
4 | LANGUAGE: 'None',
5 | COLLAPSE_INDEX: false,
6 | BUILDER: 'html',
7 | FILE_SUFFIX: '.html',
8 | LINK_SUFFIX: '.html',
9 | HAS_SOURCE: true,
10 | SOURCELINK_SUFFIX: '.txt',
11 | NAVIGATION_WITH_KEYS: false
12 | };
--------------------------------------------------------------------------------
/docs/_static/file.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/file.png
--------------------------------------------------------------------------------
/docs/_static/fonts/Inconsolata-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Inconsolata-Bold.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Inconsolata-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Inconsolata-Regular.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Inconsolata.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Inconsolata.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato-Bold.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato-Regular.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-bold.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-bold.eot
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-bold.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-bold.woff
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-bold.woff2
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-bolditalic.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-bolditalic.eot
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-bolditalic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-bolditalic.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-bolditalic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-bolditalic.woff
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-bolditalic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-bolditalic.woff2
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-italic.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-italic.eot
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-italic.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-italic.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-italic.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-italic.woff
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-italic.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-italic.woff2
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-regular.eot
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-regular.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-regular.woff
--------------------------------------------------------------------------------
/docs/_static/fonts/Lato/lato-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/Lato/lato-regular.woff2
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab-Bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab-Bold.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab-Regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab-Regular.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab/roboto-slab-v7-bold.eot
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab/roboto-slab-v7-bold.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab/roboto-slab-v7-bold.woff2
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab/roboto-slab-v7-regular.eot
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab/roboto-slab-v7-regular.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff
--------------------------------------------------------------------------------
/docs/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/RobotoSlab/roboto-slab-v7-regular.woff2
--------------------------------------------------------------------------------
/docs/_static/fonts/fontawesome-webfont.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/fontawesome-webfont.eot
--------------------------------------------------------------------------------
/docs/_static/fonts/fontawesome-webfont.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/fontawesome-webfont.ttf
--------------------------------------------------------------------------------
/docs/_static/fonts/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/docs/_static/fonts/fontawesome-webfont.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/fonts/fontawesome-webfont.woff2
--------------------------------------------------------------------------------
/docs/_static/js/badge_only.js:
--------------------------------------------------------------------------------
1 | !function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=4)}({4:function(e,t,r){}});
--------------------------------------------------------------------------------
/docs/_static/minus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/minus.png
--------------------------------------------------------------------------------
/docs/_static/plus.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/_static/plus.png
--------------------------------------------------------------------------------
/docs/objects.inv:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docs/objects.inv
--------------------------------------------------------------------------------
/docsource/Makefile:
--------------------------------------------------------------------------------
1 | # Minimal makefile for Sphinx documentation
2 | #
3 |
4 | # You can set these variables from the command line, and also
5 | # from the environment for the first two.
6 | SPHINXOPTS ?=
7 | SPHINXBUILD ?= sphinx-build
8 | SOURCEDIR = source
9 | BUILDDIR = build
10 |
11 | # Put it first so that "make" without argument is like "make help".
12 | help:
13 | @$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14 |
15 | .PHONY: help Makefile
16 |
17 | # Catch-all target: route all unknown targets to Sphinx using the new
18 | # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19 | %: Makefile
20 | @$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
21 |
22 |
23 | github:
24 | @make html
25 | @cp -a build/html/. ../docs
26 |
--------------------------------------------------------------------------------
/docsource/README.md:
--------------------------------------------------------------------------------
1 | # Generating the documentation
2 |
3 |
4 | ## Packages installed
5 |
6 | Building it requires the package `sphinx` that you can
7 | install using:
8 |
9 | ```bash
10 | pip install -r requirements.txt
11 | ```
12 |
13 | It also need to have Pandoc installed: [Pandoc](https://pandoc.org/installing.html)
14 |
15 | ## Building the documentation
16 |
17 | Once you have setup `sphinx`, you can build the documentation by running the following command in the `/docs` folder:
18 |
19 | ```bash
20 | make html
21 | ```
22 |
23 | A folder called ``build/html`` should have been created. You can now open the file ``build/html/index.html`` in your
24 | browser.
25 |
26 | ---
27 | **NOTE**
28 |
29 | If you are adding/removing elements from the toc-tree or from any structural item, it is recommended to clean the build
30 | directory before rebuilding. Run the following command to clean and build:
31 |
32 | ```bash
33 | make clean && make html
34 | ```
35 |
36 | ---
37 |
38 | It should build the static app that will be available under `/docs/build/html`
39 |
--------------------------------------------------------------------------------
/docsource/make.bat:
--------------------------------------------------------------------------------
1 | @ECHO OFF
2 |
3 | pushd %~dp0
4 |
5 | REM Command file for Sphinx documentation
6 |
7 | if "%SPHINXBUILD%" == "" (
8 | set SPHINXBUILD=sphinx-build
9 | )
10 | set SOURCEDIR=source
11 | set BUILDDIR=build
12 |
13 | if "%1" == "" goto help
14 |
15 | %SPHINXBUILD% >NUL 2>NUL
16 | if errorlevel 9009 (
17 | echo.
18 | echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
19 | echo.installed, then set the SPHINXBUILD environment variable to point
20 | echo.to the full path of the 'sphinx-build' executable. Alternatively you
21 | echo.may add the Sphinx directory to PATH.
22 | echo.
23 | echo.If you don't have Sphinx installed, grab it from
24 | echo.http://sphinx-doc.org/
25 | exit /b 1
26 | )
27 |
28 | %SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29 | goto end
30 |
31 | :help
32 | %SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33 |
34 | :end
35 | popd
36 |
--------------------------------------------------------------------------------
/docsource/requirements.txt:
--------------------------------------------------------------------------------
1 | sphinx==4.1.2
2 | sphinx_rtd_theme==0.5.2
3 | docutils==0.16
4 | sphinx_autodoc_typehints
5 | numpydoc
6 | nbsphinx
7 | jupyter
8 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/alodataset.rst:
--------------------------------------------------------------------------------
1 | Alodataset
2 | ==============
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 |
7 | transform
8 | base_dataset
9 | merge_dataset
10 | chairssdhom_dataset
11 | coco_detection_dataset
12 | coco_panoptic_dataset
13 | crowd_human_dataset.rst
14 | flyingthings3D_subset_dataset.rst
15 | flying_chairs2_dataset.rst
16 | waymo_dataset.rst
17 | mot17
18 | sintel_flow_dataset.rst
19 | sintel_disparity_dataset.rst
20 | sintel_multi_dataset.rst
21 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/base_dataset.rst:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | Base dataset
4 | ---------------------
5 |
6 | .. automodule:: alodataset.base_dataset
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
11 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/chairssdhom_dataset.rst:
--------------------------------------------------------------------------------
1 | ChairsSDHom
2 | ###########
3 |
4 | This dataset is part of the `Optical Flow datasets
5 | `_
6 | provided by the Computer Science Group of the University of Freiburg.
7 |
8 |
9 | - For more information about the dataset, please refer to the `CVPR2017 paper `_.
10 | - To download the dataset, please follow instructions at `this link `_ in the section *The "ChairsSDHom" Dataset*.
11 |
12 | ChairsSDHomDataset API
13 | **********************
14 |
15 | .. automodule:: alodataset.chairssdhom_dataset
16 | :members:
17 | :undoc-members:
18 | :show-inheritance:
19 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/crowd_human_dataset.rst:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | Crowd human
4 | ---------------------
5 |
6 | .. automodule:: alodataset.crowd_human_dataset
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/flying_chairs2_dataset.rst:
--------------------------------------------------------------------------------
1 | FlyingChairs2
2 | #############
3 |
4 | This dataset is part of the `Optical Flow datasets
5 | `_
6 | provided by the Computer Science Group of the University of Freiburg.
7 |
8 |
9 | - For more information about the dataset, please refer to the `ECCV2018 paper `_.
10 | - To download the dataset, please follow instructions at `this link `_ in the section *The "Flying Chairs 2" Dataset*.
11 |
12 |
13 | FlyingChairs2 API
14 | *****************
15 |
16 | .. automodule:: alodataset.flying_chairs2_dataset
17 | :members:
18 | :undoc-members:
19 | :show-inheritance:
20 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/flyingthings3D_subset_dataset.rst:
--------------------------------------------------------------------------------
1 | Flyingthings3D Subset
2 | ---------------------
3 |
4 | This dataset is part of the `Scene Flow datasets
5 | `_
6 | provided by the Computer Science Group of the University of Freiburg.
7 |
8 | This is a synthetic dataset containing optical flow and disparity, with occlusion, for two cameras (left/right).
9 |
10 |
11 | - For more information about the dataset, please refer to the `CVPR2016 paper `_.
12 | - To download the dataset, please follow instructions at `this link `_ in the section *DispNet/FlowNet2.0 dataset subsets*.
13 |
14 | Flyingthings3DSubsetDataset API
15 | ===============================
16 |
17 | .. automodule:: alodataset.flyingthings3D_subset_dataset
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/merge_dataset.rst:
--------------------------------------------------------------------------------
1 | Merging datasets
2 | ----------------
3 |
4 | Basic usage
5 | ===========
6 |
7 | The class :attr:`MergeDataset` is used to merge multiple datasets::
8 |
9 | from alodataset import FlyingThings3DSubsetDataset, MergeDataset
10 | dataset1 = FlyingThings3DSubsetDataset(sequence_size=2, transform_fn=lambda f: f["left"])
11 | dataset2 = FlyingThings3DSubsetDataset(sequence_size=2, transform_fn=lambda f: f["right"])
12 | dataset = MergeDataset([dataset1, dataset2])
13 |
14 | It is then possible to shuffle the datasets together, and sample batches than can contain items from different datasets::
15 |
16 | # this batch can contain items from dataset1 and/or dataset2
17 | batch = next(iter(dataset.train_loader(batch_size=4)))
18 |
19 | It is possible to apply specific transformations to each dataset,
20 | and then apply the same global transformation to the items::
21 |
22 | from alodataset.transforms import RandomCrop
23 | dataset1 = FlyingThings3DSubsetDataset(sequence_size=2, transform_fn=lambda f: f["left"]) # specific transform
24 | dataset2 = FlyingThings3DSubsetDataset(sequence_size=2, transform_fn=lambda f: f["right"]) # specific transform
25 | dataset = MergeDataset([dataset1, dataset2], transform_fn=RandomCrop(size=(368, 496)) # global transform
26 |
27 | MergeDataset API
28 | ================
29 |
30 | .. automodule:: alodataset.merge_dataset
31 | :members:
32 | :undoc-members:
33 | :show-inheritance:
34 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/mot17.rst:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | MOT17
4 | ---------------------
5 |
6 | .. automodule:: alodataset.mot17
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/sintel_disparity_dataset.rst:
--------------------------------------------------------------------------------
1 | Sintel Disparity
2 | ################
3 |
4 | The MPI Sintel Disparity is an extension to the Sintel Flow Dataset. This dataset contains disparity annotations and occlusions.
5 |
6 | - To download the dataset and have more information, `follow this link `_.
7 | - The main conference paper for more detailed information is available `here `_. Other references are listed in the previous link.
8 |
9 |
10 | SintelDisparityDataset API
11 | ***************************
12 |
13 | .. automodule:: alodataset.sintel_disparity_dataset
14 | :members:
15 | :undoc-members:
16 | :show-inheritance:
17 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/sintel_flow_dataset.rst:
--------------------------------------------------------------------------------
1 | Sintel Optical Flow
2 | ###################
3 |
4 | The MPI Sintel Flow Dataset is a dataset for the evaluation of optical flow derived from the open source 3D animated
5 | short film, Sintel.
6 |
7 | - To download the dataset and have more information, `follow this link `_.
8 | - The main conference paper for more detailed information is available `here `_. Other references are listed in the previous link.
9 |
10 |
11 | SintelFlowDataset API
12 | *********************
13 |
14 | .. automodule:: alodataset.sintel_flow_dataset
15 | :members:
16 | :undoc-members:
17 | :show-inheritance:
18 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/sintel_multi_dataset.rst:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | Sintel Multi (Flow + Disparity)
4 | -------------------------------
5 |
6 | .. automodule:: alodataset.sintel_multi_dataset
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docsource/source/alodataset/transform.rst:
--------------------------------------------------------------------------------
1 | Hello, here is the page
2 |
3 | Transformations
4 | ---------------------
5 |
6 | .. automodule:: alodataset.transforms
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
11 |
12 |
--------------------------------------------------------------------------------
/docsource/source/alonet/alonet.callbacks.rst:
--------------------------------------------------------------------------------
1 | Callbacks
2 | ========================
3 |
4 | List of callbacks used in different modules, in order to present different metrics while them are training. See
5 | `Callbacks `_ to get more information.
6 |
7 | Base Metrics Callback
8 | ----------------------------------------------
9 |
10 | .. automodule:: alonet.callbacks.base_metrics_callback
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
15 |
16 | AP Metrics Callback
17 | ----------------------------------------------
18 |
19 | .. automodule:: alonet.callbacks.map_metrics_callback
20 | :members:
21 | :undoc-members:
22 | :show-inheritance:
23 |
24 |
25 | PQ Metrics Callback
26 | ----------------------------------------------
27 |
28 | .. automodule:: alonet.callbacks.pq_metrics_callback
29 | :members:
30 | :undoc-members:
31 | :show-inheritance:
32 |
33 |
34 | Metrics Callbacks
35 | -----------------------------------------
36 |
37 | .. automodule:: alonet.callbacks.metrics_callback
38 | :members:
39 | :undoc-members:
40 | :show-inheritance:
41 |
42 |
43 | Object Detector Callback
44 | --------------------------------------------------
45 |
46 | .. automodule:: alonet.callbacks.object_detector_callback
47 | :members:
48 | :undoc-members:
49 | :show-inheritance:
50 |
--------------------------------------------------------------------------------
/docsource/source/alonet/alonet.rst:
--------------------------------------------------------------------------------
1 | Alonet
2 | ==============
3 |
4 |
5 | .. toctree::
6 | :maxdepth: 2
7 |
8 | detr
9 | deformable
10 | panoptic
11 | alonet.callbacks
12 | alonet.metrics
13 | alonet.transformers
14 |
--------------------------------------------------------------------------------
/docsource/source/alonet/alonet.transformers.rst:
--------------------------------------------------------------------------------
1 | Transformer
2 | ===========================
3 |
4 | MLP
5 | ------------------------------
6 |
7 | .. automodule:: alonet.transformers.mlp
8 | :members:
9 | :undoc-members:
10 | :show-inheritance:
11 |
12 |
13 | Positional Encoding
14 | ---------------------------------------------
15 |
16 | .. automodule:: alonet.transformers.position_encoding
17 | :members:
18 | :undoc-members:
19 | :show-inheritance:
20 |
21 |
22 | Transformer
23 | ---------------
24 |
25 | .. automodule:: alonet.transformers
26 | :members:
27 | :undoc-members:
28 | :show-inheritance:
29 |
--------------------------------------------------------------------------------
/docsource/source/alonet/deformable.rst:
--------------------------------------------------------------------------------
1 | Deformable DETR
2 | ==========================
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 | :caption: API
7 |
8 | deformable_models
9 | deformable_architecture
10 | deformable_training
11 |
12 |
13 |
--------------------------------------------------------------------------------
/docsource/source/alonet/deformable_architecture.rst:
--------------------------------------------------------------------------------
1 | Architecture
2 | =============================
3 |
4 |
5 | Backbone
6 | ---------------------------------------
7 |
8 | .. automodule:: alonet.deformable_detr.backbone
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 |
14 | Transformer
15 | ------------------------------------------------------
16 |
17 | .. automodule:: alonet.deformable_detr.deformable_transformer
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
--------------------------------------------------------------------------------
/docsource/source/alonet/deformable_training.rst:
--------------------------------------------------------------------------------
1 | Training
2 | =========================
3 |
4 |
5 | Training
6 | ------------------------------------
7 |
8 | .. automodule:: alonet.deformable_detr.train
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 | Callbacks
14 | ----------------------------------------
15 |
16 | .. automodule:: alonet.deformable_detr.callbacks
17 | :members:
18 | :undoc-members:
19 | :show-inheritance:
20 |
21 | Criterion
22 | ----------------------------------------
23 |
24 | .. automodule:: alonet.deformable_detr.criterion
25 | :members:
26 | :undoc-members:
27 | :show-inheritance:
28 |
29 |
30 | Matcher
31 | --------------------------------------
32 |
33 | .. automodule:: alonet.deformable_detr.matcher
34 | :members:
35 | :undoc-members:
36 | :show-inheritance:
37 |
38 |
39 |
40 |
41 |
--------------------------------------------------------------------------------
/docsource/source/alonet/detr.rst:
--------------------------------------------------------------------------------
1 | Detr
2 | ==========================
3 |
4 | .. toctree::
5 | :maxdepth: 3
6 | :caption: API
7 |
8 | detr_models
9 | detr_architecture
10 | detr_training
11 | detr_connectors
12 |
--------------------------------------------------------------------------------
/docsource/source/alonet/detr_architecture.rst:
--------------------------------------------------------------------------------
1 | Architecture
2 | ===================
3 |
4 |
5 | Backbone
6 | ---------------------------
7 |
8 | .. automodule:: alonet.detr.backbone
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 |
14 | Transformer
15 | ------------------------------
16 |
17 | .. automodule:: alonet.detr.transformer
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 |
--------------------------------------------------------------------------------
/docsource/source/alonet/detr_models.rst:
--------------------------------------------------------------------------------
1 | Models
2 | ===================
3 |
4 | Basic usage
5 | --------------------
6 |
7 | To instantiate a DETR R50 (resnet50 backbone):
8 |
9 | .. code-block:: python
10 |
11 | from alonet.detr import DetrR50
12 | model = DetrR50()
13 |
14 | To load pretrained weights on COCO dataset:
15 |
16 | .. code-block:: python
17 |
18 | model = DetrR50(num_classes=NUM_CLASS, weights='detr-r50')
19 |
20 | Or from trained-models:
21 |
22 | .. code-block:: python
23 |
24 | model = DetrR50(num_classes=NUM_CLASS, weights='path/to/weights.pth' or 'path/to/weights.ckpt')
25 |
26 | If you want to finetune from the model pretrained on COCO dataset (by default):
27 |
28 | .. code-block:: python
29 |
30 | from alonet.detr import DetrR50Finetune
31 | # NUM_CLASS is the desired number of classes in the new model
32 | model = DetrR50Finetune(num_classes=NUM_CLASS)
33 |
34 | To run inference:
35 |
36 | .. code-block:: python
37 |
38 | from aloscene import Frame
39 | device = model.device # supposed that `model` is already defined as above
40 |
41 | # read image and preprocess image with Resnet normalization
42 | frame = aloscene.Frame(PATH_TO_IMAGE).norm_resnet()
43 | # create a batch from a list of images
44 | frames = aloscene.Frame.batch_list([frame])
45 | frames = frames.to(device)
46 |
47 | # forward pass
48 | m_outputs = model(frames)
49 | # get predicted boxes as aloscene.BoundingBoxes2D from forward outputs
50 | pred_boxes = model.inference(m_outputs)
51 | # Display the predicted boxes
52 | frame.append_boxes2d(pred_boxes[0], "pred_boxes")
53 | frame.get_view([frame.boxes2d]).render()
54 |
55 | Detr Base
56 | -----------------------
57 |
58 | .. automodule:: alonet.detr.detr
59 | :members:
60 | :undoc-members:
61 | :show-inheritance:
62 |
63 |
64 | Detr R50
65 | ----------------------------
66 |
67 | .. automodule:: alonet.detr.detr_r50
68 | :members:
69 | :undoc-members:
70 | :show-inheritance:
71 |
72 |
73 | Detr R50 Finetune
74 | --------------------------------------
75 |
76 | .. automodule:: alonet.detr.detr_r50_finetune
77 | :members:
78 | :undoc-members:
79 | :show-inheritance:
80 |
--------------------------------------------------------------------------------
/docsource/source/alonet/detr_training.rst:
--------------------------------------------------------------------------------
1 | Training
2 | ===================
3 |
4 |
5 | Training
6 | ------------------------
7 |
8 | .. automodule:: alonet.detr.train
9 | :members:
10 | :undoc-members:
11 | :show-inheritance:
12 |
13 |
14 | Criterion
15 | ----------------------------
16 |
17 | .. automodule:: alonet.detr.criterion
18 | :members:
19 | :undoc-members:
20 | :show-inheritance:
21 |
22 | Matcher
23 | --------------------------
24 |
25 | .. automodule:: alonet.detr.matcher
26 | :members:
27 | :undoc-members:
28 | :show-inheritance:
29 |
30 |
31 | Callbacks
32 | ----------------------------
33 |
34 | .. automodule:: alonet.detr.callbacks
35 | :members:
36 | :undoc-members:
37 | :show-inheritance:
38 |
--------------------------------------------------------------------------------
/docsource/source/alonet/panoptic.rst:
--------------------------------------------------------------------------------
1 | Panoptic Head
2 | ==========================
3 |
4 | This module allows the implementation of a neural network based on |detr|_ to make prediction of segmentation maps.
5 |
6 | .. toctree::
7 | :maxdepth: 3
8 | :caption: API
9 |
10 | panoptic_models
11 | panoptic_training
12 |
13 | .. Hyperlinks
14 | .. |detr| replace:: Detr-based models
15 | .. _detr: detr_models.html#module-alonet.detr.detr
16 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/aloscene.rst:
--------------------------------------------------------------------------------
1 | Aloscene
2 | ================
3 |
4 |
5 | .. toctree::
6 | :maxdepth: 3
7 | :caption: Package Reference
8 |
9 | frame
10 | bounding_boxes_2d
11 | oriented_boxes_2d
12 | points2d
13 | labels
14 | mask
15 | flow
16 | disparity
17 | bounding_boxes_3d
18 | camera_calib
19 |
20 | .. toctree::
21 | :maxdepth: 3
22 | :caption: Augmented Tensor
23 |
24 | augmented_tensor
25 | spatial_augmented_tensor
26 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/augmented_tensor.rst:
--------------------------------------------------------------------------------
1 |
2 |
3 | Augmented Tensor
4 | -----------------------------------------
5 |
6 | .. automodule:: aloscene.tensors.augmented_tensor
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
11 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/bounding_boxes_2d.rst:
--------------------------------------------------------------------------------
1 |
2 | BoundingBoxes2D
3 | ---------------------
4 |
5 | .. image:: ../images/boxes_header.png
6 | :width: 100%
7 | :alt: Points2D Header
8 |
9 |
10 | .. automodule:: aloscene.bounding_boxes_2d
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/bounding_boxes_3d.rst:
--------------------------------------------------------------------------------
1 | BoundingBoxes3D
2 | ======================
3 |
4 | Bounding Boxes 3D Tensor of shape (n, 7) of which the last dimension is : [xc, yc, zc, Dx, Dy, Dz, heading]
5 |
6 | - Coordinate xc, yc, zc of boxes’ center
7 | - Boxes’ dimension Dx, Dy, Dz along the 3 axis
8 | - Heading is the orientation by rotating around vertical Y-axis.
9 |
10 | With this coordinate system convention:
11 |
12 | - The X axis is positive to the right
13 | - The Y axis is positive downwards
14 | - The Z axis is positive forwards
15 |
16 | .. toctree::
17 | :maxdepth: 0
18 | :caption: Basic usage:
19 |
20 | notebooks/bounding_boxes_3d.ipynb
21 |
22 |
23 | API
24 | --------
25 |
26 | .. automodule:: aloscene.bounding_boxes_3d
27 | :members:
28 | :undoc-members:
29 | :show-inheritance:
30 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/camera_calib.rst:
--------------------------------------------------------------------------------
1 | Camera calibration
2 | ---------------------
3 |
4 | .. automodule:: aloscene.camera_calib
5 | :members:
6 | :undoc-members:
7 | :show-inheritance:
8 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/frame.rst:
--------------------------------------------------------------------------------
1 |
2 |
3 | Frame
4 | ---------------------
5 |
6 | .. automodule:: aloscene.frame
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/labels.rst:
--------------------------------------------------------------------------------
1 |
2 | Label
3 | ---------------------
4 |
5 | .. automodule:: aloscene.labels
6 | :members:
7 | :undoc-members:
8 | :show-inheritance:
--------------------------------------------------------------------------------
/docsource/source/aloscene/mask.rst:
--------------------------------------------------------------------------------
1 | Mask
2 | ----
3 |
4 | The :mod:`Mask ` object represents a binary or float mask. It can be used to represent different
5 | objects, for example occlusions mask for flow and disparity use cases, or binary masks per object for segmentation
6 | tasks.
7 |
8 | .. figure:: ../images/mask_types.png
9 | :width: 100%
10 | :alt: Mask types representation
11 | :class: with-shadow
12 |
13 | Mask types representation in different scenarios: **(top-left)** a binary mask used by :mod:`Frame `
14 | in :func:`resize` and :func:`forward` process, **(top-right)** a float mask used to flow representation,
15 | **(bottom-left)** a float mask used to render the disparity view and **(bottom-right)** multiple binary masks which
16 | encode the presence of an object in each pixel.
17 |
18 | .. note::
19 |
20 | The values of a :mod:`Mask ` are between 0. and 1., to allow to partially/completely mask another
21 | tensor by multiplying it by the mask.
22 |
23 | Basic Use
24 | =========
25 |
26 | A :attr:`Mask` object can be initialized from a path to a mask file::
27 |
28 | from aloscene import Mask
29 | mask = Mask("path/to/mask.png")
30 |
31 | or from an existing tensor::
32 |
33 | import torch
34 | mask_float_tensor = torch.rand((1,400,600))
35 | mask = Mask(mask_tensor, names=("N","H","W"))
36 |
37 | when a label is assigned to each mask, a segmentation view (one mask per object) is carried out::
38 |
39 | from aloscene import Labels
40 |
41 | # Four corner objects will be created
42 | labels = Labels(torch.as_tensor([0,1,1,0]), names = ("N"), labels_names = ["thing", "stuff"])
43 | mask_for_segmentation = Mask(torch.zeros(4,400,600), names=("N","H","W"))
44 | for i, (x, y) in enumerate(zip([0, 300, 0, 300], [0, 0, 200, 200])):
45 | mask_for_segmentation[i, y : y + 200, x : x + 300] = 1
46 |
47 | # Render with panoptic view
48 | mask_for_segmentation.append_labels(labels)
49 | mask_for_segmentation.get_view().render()
50 |
51 | Mask API
52 | ========
53 |
54 | .. automodule:: aloscene.mask
55 | :members:
56 | :undoc-members:
57 | :show-inheritance:
58 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/oriented_boxes_2d.rst:
--------------------------------------------------------------------------------
1 | OrientedBoxes2D
2 | ====================
3 |
4 | Oriented Boxes 2D is defined by [x, y, w, h, theta] in which:
5 |
6 | - x, y: center coordinates (could be relative or absolute values)
7 | - w, h: width, height (could be relative or absolute values)
8 | - theta: rotation angle
9 |
10 | Basic usage
11 | ---------------
12 |
13 | .. code-block:: python
14 |
15 | import numpy as np
16 | import torch
17 | from aloscene import OrientedBoxes2D
18 |
19 | boxes = OrientedBoxes2D(
20 | torch.tensor(
21 | [
22 | # [x, y, w, h, theta]
23 | [0.5, 0.5, 0.2, 0.2, 0],
24 | [0.1, 0.1, 0.2, 0.3, np.pi / 6],
25 | [0.1, 0.8, 0.1, 0.3, -np.pi / 3],
26 | [0.6, 0.3, 0.4, 0.2, np.pi / 4],
27 | ],
28 | device=torch.device("cuda"),
29 | ),
30 | absolute=False, # use relative values for x, y, w, h
31 | )
32 |
33 | boxes.get_view().render()
34 |
35 | Get coordinates of 4 corners for each boxes:
36 |
37 | .. code-block:: python
38 |
39 | print(boxes.corners())
40 |
41 | Convert to absolute value format with frame size = (300, 300):
42 |
43 | .. code-block:: python
44 |
45 | abs_boxes = boxes.abs_boxes((300, 300))
46 | print(abs_boxes)
47 | print(abs_boxes.absolute) # True
48 | print(abs_boxes.rel_pos() == boxes) # True
49 |
50 | Calucate oriented IoU/GIoU with another set of boxes:
51 |
52 | .. code-block:: python
53 |
54 | boxes2 = OrientedBoxes2D(
55 | torch.tensor(
56 | [
57 | [1, 1, 2, 2, 0],
58 | [5, 5, 2, 3, np.pi / 6],
59 | [1, 1, 1, 3, -np.pi / 3],
60 | [3, 1, 4, 2, np.pi / 4]
61 | ],
62 | device=torch.device("cuda")
63 | )
64 | )
65 | iou = boxes.rotated_iou_with(boxes2)
66 | giou = boxes.rotated_giou_with(boxes2)
67 | print(iou)
68 | print(giou)
69 |
70 |
71 | API
72 | ---------------------
73 |
74 | .. automodule:: aloscene.oriented_boxes_2d
75 | :members:
76 | :undoc-members:
77 | :show-inheritance:
78 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/points2d.rst:
--------------------------------------------------------------------------------
1 |
2 | Points2D
3 | ---------------------
4 |
5 | .. image:: ../images/points2d_header.png
6 | :width: 100%
7 | :alt: Points2D Header
8 |
9 |
10 | .. automodule:: aloscene.points_2d
11 | :members:
12 | :undoc-members:
13 | :show-inheritance:
14 |
--------------------------------------------------------------------------------
/docsource/source/aloscene/spatial_augmented_tensor.rst:
--------------------------------------------------------------------------------
1 |
2 |
3 | Spatial Augmented Tensor
4 | --------------------------------------------------
5 |
6 | .. automodule:: aloscene.tensors.spatial_augmented_tensor
7 | :members:
8 | :undoc-members:
9 | :show-inheritance:
10 |
--------------------------------------------------------------------------------
/docsource/source/images/aloception.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/aloception.png
--------------------------------------------------------------------------------
/docsource/source/images/boxes_header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/boxes_header.png
--------------------------------------------------------------------------------
/docsource/source/images/disp_hflip.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/disp_hflip.jpg
--------------------------------------------------------------------------------
/docsource/source/images/disp_view.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/disp_view.jpg
--------------------------------------------------------------------------------
/docsource/source/images/flow_hflip.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/flow_hflip.jpg
--------------------------------------------------------------------------------
/docsource/source/images/flow_view.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/flow_view.jpg
--------------------------------------------------------------------------------
/docsource/source/images/mask_types.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/mask_types.png
--------------------------------------------------------------------------------
/docsource/source/images/panoptic_head.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/panoptic_head.png
--------------------------------------------------------------------------------
/docsource/source/images/points2d_header.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/docsource/source/images/points2d_header.png
--------------------------------------------------------------------------------
/docsource/source/index.rst:
--------------------------------------------------------------------------------
1 |
2 |
3 | Aloception's documentation
4 | ==========================
5 |
6 | .. toctree::
7 | :maxdepth: 2
8 | :caption: Geting Started
9 |
10 | getting_started/getting_started
11 | getting_started/aloscene
12 | getting_started/alodataset
13 | getting_started/alonet
14 | getting_started/augmented_tensor
15 |
16 | .. toctree::
17 | :maxdepth: 2
18 | :caption: Turorials
19 |
20 | tutorials/data_setup
21 | tutorials/training_detr
22 | tutorials/finetuning_detr
23 | tutorials/training_panoptic
24 | tutorials/training_deformable_detr
25 | tutorials/finetuning_deformable_detr
26 | tutorials/tensort_inference
27 |
28 |
29 | .. toctree::
30 | :maxdepth: 3
31 | :caption: Aloception API
32 |
33 | aloscene/aloscene
34 | alodataset/alodataset
35 | alonet/alonet
36 |
--------------------------------------------------------------------------------
/docsource/source/tutorials/tensort_inference.rst:
--------------------------------------------------------------------------------
1 | Exporting DETR / Deformable-DETR to TensorRT
2 | --------------------------------------------------
3 |
4 | .. toctree::
5 | :maxdepth: 2
6 | :caption: Contents:
7 |
8 | export_tensorrt/Tutorial - Export DETR to TensorRT and inference.ipynb
9 | export_tensorrt/Tutorial - Export Deformable DETR to TensorRT and inference.ipynb
--------------------------------------------------------------------------------
/entrypoint.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 | set -e
3 |
4 | if [ -v LOCAL_USER_ID ]; then
5 | if id -u ${LOCAL_USER_ID} >/dev/null 2>&1; then
6 | BASE_USER=aloception
7 | else
8 | # Create a new user with the specified UID and GI
9 | useradd --home /home/aloception --uid $LOCAL_USER_ID --shell /bin/bash dynamic && usermod -aG sudo dynamic && echo "dynamic ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
10 | BASE_USER=dynamic
11 | fi
12 | else
13 | BASE_USER=aloception
14 | fi
15 |
16 | echo "Starting with UID : $LOCAL_USER_ID, base user: $BASE_USER"
17 |
18 | export CONDA_HOME=/opt/miniconda;
19 | export PATH=${CONDA_HOME}/condabin:${CONDA_HOME}/bin:${PATH};
20 | source activate base;
21 |
22 | if [ "$#" -ne 0 ]; then
23 | su -s /bin/bash $BASE_USER -c "export CONDA_HOME=/opt/miniconda; export PATH=${CONDA_HOME}/condabin:${CONDA_HOME}/bin:${PATH}; source activate base; $@"
24 | else
25 | su -s /bin/bash $BASE_USER -c "export CONDA_HOME=/opt/miniconda; export PATH=${CONDA_HOME}/condabin:${CONDA_HOME}/bin:${PATH}; source activate base; script -q /dev/null -c 'bash -i'"
26 | fi
27 |
28 |
--------------------------------------------------------------------------------
/images/aloception-oss.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Visual-Behavior/aloception-oss/02bcfecab014798899eba611eb9e3ee5c3be7f3f/images/aloception-oss.jpg
--------------------------------------------------------------------------------
/requirements/requirements-torch1.13.1.txt:
--------------------------------------------------------------------------------
1 | pycocotools==2.0.2
2 | PyYAML==5.4.1
3 | chardet==4.0.0
4 | idna==2.10
5 |
6 | scipy==1.10.0
7 |
8 | more_itertools==8.8.0
9 | requests==2.25.1
10 | opencv-python==4.7.0.68
11 |
12 | python-dateutil==2.8.2
13 | urllib3==1.26.6
14 |
15 | protobuf==4.21.12
16 | wandb==0.13.9
17 |
18 | tqdm==4.62.3
19 | captum==0.4.0
20 |
21 | setuptools==59.5.0
22 |
23 |
--------------------------------------------------------------------------------
/setup.py:
--------------------------------------------------------------------------------
1 | from setuptools import setup, find_packages
2 |
3 | setup(
4 | name='aloception',
5 | author='Visual Behavior',
6 | version='0.6.0beta',
7 | description='Aloception is a set of package for computer vision: aloscene, alodataset, alonet.',
8 | packages=find_packages(include=["aloscene", "aloscene.*", "alodataset", "alodataset.*", "alonet", "alonet.*"]),
9 | url='https://visualbehavior.ai/',
10 | download_url='https://github.com/Visual-Behavior/aloception-oss',
11 | install_requires=[
12 | 'PyYAML==5.4.1',
13 | 'chardet==4.0.0',
14 | 'idna==2.10',
15 | 'scipy==1.10.0',
16 | 'more_itertools==8.8.0',
17 | 'requests==2.25.1',
18 | 'opencv-python==4.7.0.68',
19 | 'python-dateutil==2.8.2',
20 | 'urllib3==1.26.6',
21 | 'protobuf==4.21.12',
22 | 'wandb==0.13.9',
23 | 'tqdm==4.62.3',
24 | 'captum==0.4.0',
25 | 'setuptools==59.5.0',
26 | ],
27 | setup_requires=['numpy', 'torch', 'nvidia-pyindex', 'pycuda'],
28 | license_files=['LICENSE'],
29 | keywords=['artificial intelligence', 'computer vision'],
30 | classifiers=[
31 | 'Programming Language :: Python',
32 | 'Topic :: Scientific/Engineering :: Artificial Intelligence'
33 | ]
34 | )
35 |
--------------------------------------------------------------------------------
/tutorials/1-hello_world.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 |
4 | waymo_dataset = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"])
5 |
6 | # Go through the loaded sequence
7 | for data in waymo_dataset.stream_loader():
8 | # Select the front frame and display the result with opencv
9 | # `get_view()`, return a `View` object that can be be render using render()
10 | # 'cv' is pass to the render() method to use opencv instead of matplotlib (default)
11 | data["front"].get_view(size=(1280 // 2, 1920 // 2)).render(View.CV)
12 |
--------------------------------------------------------------------------------
/tutorials/2-frame.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 |
4 | waymo_dataset = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"])
5 |
6 | # Get a frame at some position in the dataset
7 | data = waymo_dataset.get(2)
8 |
9 | # The frame object is a special type of Tensor (Labeled Tensor) with special attributes and labels
10 | # attached to it
11 | frame = data["front"]
12 | # With the print method, one can see the attributes and labels attached to the tensor.
13 | print(frame)
14 | # tensor(
15 | # normalization=255,
16 | # boxes2d={'gt_boxes_2d:[11]'},
17 | # .....
18 | # names=('T', 'C', 'H', 'W'))
19 |
20 |
21 | # Render the frame
22 | data["front"].get_view().render()
23 |
--------------------------------------------------------------------------------
/tutorials/2.1-frame.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 |
4 | frame = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"]).get(2)["front"]
5 |
6 | ######
7 | # Here are some example of the operations that can be done on a frame
8 | ######
9 |
10 | # Normalize the values between 0 and 1
11 | frame_01 = frame.norm01()
12 | print(frame_01)
13 | # tensor(
14 | # normalization=01,
15 | # boxes2d={'gt_boxes_2d:[11]'},
16 |
17 |
18 | # Normalize the values between 0 and 255
19 | frame_255 = frame.norm255()
20 | print(frame_255)
21 | # tensor(
22 | # normalization=255,
23 | # boxes2d={'gt_boxes_2d:[11]'},
24 |
25 |
26 | # Get the frame ready to be send into a resnet backbone
27 | frame_resnet = frame.norm_resnet()
28 | print(frame_resnet)
29 | # tensor(
30 | # normalization=resnet, mean_std=((0.485, 0.456, 0.406), (0.229, 0.224, 0.225)),
31 | # boxes2d={'gt_boxes_2d:[11]'},
32 |
33 |
34 | # Custom mean/std normalization. Note: the mean/std must be normalized
35 | # with values within the range 0 and 1
36 | my_frame = frame.mean_std_norm((0.42, 0.4, 0.40), (0.41, 0.2, 0.45), name="my_norm")
37 | print(my_frame)
38 | # tensor(
39 | # normalization=my_norm, mean_std=((0.42, 0.4, 0.4), (0.41, 0.2, 0.45)),
40 | # boxes2d={'gt_boxes_2d:[11]'},
41 |
42 |
43 | # Note that even after all the normalization, you can still render your frame properly
44 | # at any moment
45 | my_frame.get_view().render()
46 |
--------------------------------------------------------------------------------
/tutorials/2.2-frame.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 | import torch
4 |
5 | frame = WaymoDataset(
6 | split=Split.VAL,
7 | cameras=["front"],
8 | labels=["gt_boxes_2d"],
9 | sequence_size=2, # --> Let's use sequence of two frame
10 | ).get(2)["front"]
11 |
12 | ######
13 | # The frame tensors and its labels
14 | ######
15 |
16 | # Let's inspect the frame shape as well as the dim names.
17 | # Named dim make it possible to track the frame dimension.
18 | # It also come at cose since the number of possible operations with names on the frame get limited
19 | # For instance, you con't reshape the tensor as you wish.
20 | # print(frame.shape, frame.names)
21 | # torch.Size([2, 3, 1280, 1920]) ('T', 'C', 'H', 'W')
22 |
23 | # As we can se, the frame has one label: boxes2d
24 | # This label is store as a dict with onw set of boxes: gt_boxes_2d
25 | # This set of boxes is a list with two element (the size of the sequence)
26 | # In the sequence, each set of boxes is maide of 11boxes.
27 | print(frame)
28 | # tensor(
29 | # normalization=255,
30 | # boxes2d={'gt_boxes_2d:[11, 11]'},
31 |
32 | # If we Select the first frame of the sequence
33 | # the list of boxes is now a simply a set of boxes instead of a list
34 | frame_t0 = frame[0]
35 | frame_t1 = frame[1]
36 | print(frame_t0)
37 | # tensor(
38 | # normalization=255,
39 | # boxes2d={gt_boxes_2d:torch.Size([11, 4])}
40 | # ....
41 | # [116., 115., 115., ..., 87., 84., 85.]]], names=('C', 'H', 'W'))
42 |
43 | # tensor(
44 | # normalization=255,
45 | # boxes2d={gt_boxes_2d:torch.Size([11, 4])}
46 |
47 |
48 | # You can't for now add one dimension on the frame using the pytorch api
49 | # (the named dim will block the operation)
50 | # > frame_t0 = torch.unsqueeze(frame_t0, dim=0) << Will throw an error
51 | # Instead, you can call the `temporal method` to add a temporal dimension T on the frame.
52 | n_frame_t0 = frame_t0.temporal()
53 | n_frame_t1 = frame_t1.temporal()
54 |
55 | # Now we can also concat the two frame together on the temporal dimension
56 | frames = torch.cat([n_frame_t0, n_frame_t1], dim=0)
57 |
58 | frames.get_view().render()
59 |
--------------------------------------------------------------------------------
/tutorials/2.3-frame.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 | import torch
4 |
5 | frame = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"], sequence_size=1,).get( #
6 | 2
7 | )["front"]
8 |
9 | ######
10 | # Special & usefull operations on the frame
11 | ######
12 |
13 | # We can resize the frame using the following method.
14 | # This will automaticly resize the boxes accordingly if needed
15 | # Note that is you call F.resize instead of frame.resize() this will only change
16 | # the content of the tensor without changing the labels
17 | # TODO: Raise a warning is this is the case ?
18 | resized_frame = frame.resize((100, 200))
19 | resized_frame.get_view().render()
20 |
21 | # Crop a frame
22 | # When croping, the associated label will be cropped to if needed
23 | cropped_frame = frame[0, :, 400:900, 500:800]
24 | print("cropped_frame", cropped_frame.shape, cropped_frame.names)
25 | # > cropped_frame torch.Size([3, 500, 300]) ('C', 'H', 'W')
26 | # Additionally, you can also use F.crop on the frame tensor.
27 |
28 |
29 | # Horizontal flip
30 | cropped_frame_hflip = cropped_frame.hflip()
31 |
32 | # Render both frame
33 | cropped_frame.get_view().add(cropped_frame_hflip.get_view()).render()
34 |
--------------------------------------------------------------------------------
/tutorials/3-boxes.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 | import torch
4 |
5 | frames = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"], sequence_size=2,).get( #
6 | 2
7 | )["front"]
8 |
9 | ######
10 | # Boxes
11 | ######
12 |
13 | # Each frame can have multiple set of 2D boxes ("gt", "pred", ...)
14 | # The following line (both do the same) get the set of boxes from the first frame of the sequence
15 | boxes = frames[0].boxes2d["gt_boxes_2d"]
16 | # The same can be done without slicing the frames but by slicing the boxes (to select the first set of boxes in the sequence)
17 | boxes = frames.boxes2d["gt_boxes_2d"][0]
18 |
19 | print("boxes", boxes)
20 | # boxes tensor(
21 | # boxes_format=xcyc, absolute=True, labels={}, frame_size=(1280, 1920),
22 | # ....
23 |
24 | # To view the boxes, a frame must be passed to the get_view method
25 | boxes.get_view(frames[0]).render()
26 |
--------------------------------------------------------------------------------
/tutorials/3.1-boxes.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 | import torch
4 |
5 | frames = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"], sequence_size=2,).get(
6 | 2
7 | )["front"]
8 |
9 | ######
10 | # Boxes manipulation
11 | ######
12 |
13 | boxes_t0 = frames[0].boxes2d["gt_boxes_2d"]
14 | boxes_t1 = frames[1].boxes2d["gt_boxes_2d"]
15 |
16 | print(boxes_t0.shape, boxes_t0)
17 | # torch.Size([11, 4]) tensor(
18 | # boxes_format=xcyc, absolute=True, frame_size=(1280, 1920),
19 | # labels=torch.Size([11, 1])
20 | # ...
21 |
22 | boxes = torch.cat([boxes_t0, boxes_t1], dim=0)
23 | print(boxes.shape, boxes)
24 | # torch.Size([22, 4]) tensor(
25 | # boxes_format=xcyc, absolute=True, frame_size=(1280, 1920),
26 | # labels=torch.Size([22, 1])
27 | # ...
28 |
--------------------------------------------------------------------------------
/tutorials/4.0-rendering.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 |
4 | waymo_dataset = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"])
5 |
6 | for data in waymo_dataset.stream_loader():
7 | data["front"].get_view(size=(500, 700)).render(View.CV)
8 |
--------------------------------------------------------------------------------
/tutorials/4.1-sequence.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 | import torch
4 |
5 | waymo_dataset = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"])
6 |
7 | for data in waymo_dataset.stream_loader():
8 |
9 | front_t01 = data["front"]
10 | front_t02 = data["front"].hflip()
11 |
12 | front = torch.cat([front_t01, front_t02], dim=0)
13 |
14 | front.get_view(size=(500, 700)).render(View.CV)
15 |
--------------------------------------------------------------------------------
/tutorials/4.2-custom_get_view.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import WaymoDataset, Split
3 | import torch
4 |
5 | waymo_dataset = WaymoDataset(split=Split.VAL, cameras=["front"], labels=["gt_boxes_2d"])
6 |
7 | for data in waymo_dataset.stream_loader():
8 |
9 | front_t01 = data["front"]
10 | front_t02 = data["front"].hflip()
11 |
12 | front = torch.cat([front_t01, front_t02], dim=0)
13 |
14 | # Display only boxes2D
15 | front.get_view([front.boxes2d], size=(500, 700)).render()
16 |
17 | # Display everything but boxes2D
18 | front.get_view(exclude=[front.boxes2d], size=(500, 700)).render()
19 |
20 | # Display everything only boxes with custom params
21 | front.get_view([front.boxes2d["gt_boxes_2d"][0].get_view(front[0])], size=(500, 700)).render()
22 |
23 | # View composition
24 | # Display only boxes2D
25 | front.get_view([front.boxes2d], size=(500, 700)).add(front.get_view(exclude=[front.boxes2d], size=(500, 700))).add(
26 | front.get_view([front.boxes2d["gt_boxes_2d"][0].get_view(front[0])], size=(500, 700))
27 | ).render()
28 |
--------------------------------------------------------------------------------
/tutorials/4.3-get_view_flow.py:
--------------------------------------------------------------------------------
1 | from aloscene.renderer import View
2 | from alodataset import ChairsSDHomDataset, Split
3 | import torch
4 |
5 | dataset = ChairsSDHomDataset(split=Split.VAL)
6 |
7 | for frame in dataset.stream_loader():
8 |
9 | # Display everything
10 | frame.get_view(size=(500, 700)).render()
11 |
12 | # Display only flow
13 | frame.get_view([frame.flow], size=(500, 700)).render()
14 |
15 | # Display only flow, with some custom parameters
16 | # frame.get_view([frame.flow[0].__get_view__(convert_to_bgr=True, magnitude_max=50)], size=(500,700)).render()
17 | frame.get_view(
18 | [
19 | frame.flow[0].get_view(convert_to_bgr=True, magnitude_max=50),
20 | ]
21 | ).render()
22 |
23 | # View only flow
24 | frame.flow[0].get_view([frame.flow[0]]).render()
25 |
--------------------------------------------------------------------------------
/tutorials/5.5-custom_datamod.py:
--------------------------------------------------------------------------------
1 | from typing import Optional
2 | import torch
3 |
4 | from alodataset import Mot17, Split
5 | from alonet.detr import CocoDetection2Detr
6 | from aloscene.renderer import View
7 |
8 | device = torch.device("cuda:0") if torch.cuda.is_available() else torch.device("cpu")
9 |
10 | ######
11 | # Aloception Intro
12 | ######
13 | #
14 | # Aloception is developed under the pytorchlightning framework.
15 | # For its use, aloception provides different modules that facilitate its use.
16 | # For more information, see https://www.pytorchlightning.ai/
17 |
18 |
19 | ######
20 | # Module customization (custom dataset)
21 | ######
22 | #
23 | # Aloception allows flexibility in custom modules creation.
24 | # This tutorial explains how to load and manipulate the MOT17 dataset to detect people, using the CocoDetection2Detr module.
25 | #
26 | # All information available at:
27 | # [x] MOT17 dataset: https://motchallenge.net/data/MOT17/
28 | # [x] LightningDataModule: https://pytorch-lightning.readthedocs.io/en/latest/extensions/datamodules.html
29 |
30 |
31 | # MOT17 dataset implement as a LightningDataModule, based on CocoDetectio2Detr module
32 | class Mot17DetectionDetr(CocoDetection2Detr):
33 |
34 | # Method overwrite
35 | def setup(self, stage: Optional[str] = None) -> None:
36 | self.coco_train = Mot17( # Change default dataset to MOT17
37 | split=Split.TRAIN,
38 | sequence_size=1,
39 | mot_sequences=["MOT17-02-DPM", "MOT17-02-SDP"],
40 | transform_fn=self.train_transform,
41 | )
42 | self.coco_val = Mot17( # Change default dataset to MOT17
43 | split=Split.TRAIN,
44 | sequence_size=1,
45 | mot_sequences=["MOT17-05-DPM", "MOT17-05-SDP"],
46 | transform_fn=self.val_transform,
47 | )
48 |
49 |
50 | # Use of the new modules with their new functionalities
51 | mot_loader = Mot17DetectionDetr()
52 |
53 | for frames in mot_loader.val_dataloader():
54 | frames = frames[0].batch_list(frames) # Remove temporal dim
55 | frames.get_view(
56 | frames.boxes2d,
57 | ).render(View.CV)
58 |
--------------------------------------------------------------------------------
/unittest/test_flow.py:
--------------------------------------------------------------------------------
1 | import numpy as np
2 | import torch
3 |
4 | from aloscene.frame import Frame
5 | from aloscene.flow import Flow
6 |
7 |
8 | def test_flow_hflip():
9 | # create a frame with a 3 x 3 image
10 | image = torch.full((1, 3, 3, 3), 255, dtype=torch.float32)
11 | frame = Frame(image, normalization="255", names=("T", "C", "H", "W"))
12 |
13 | # create Ground-Truth original flow
14 | flow_np = np.arange(1, 10).reshape(3, 3)
15 | flow_np = np.repeat(flow_np[np.newaxis, np.newaxis, ...], 2, axis=1)
16 | flow_torch = torch.from_numpy(flow_np.astype(np.float32))
17 | flow = Flow(flow_torch, names=("T", "C", "H", "W"))
18 | frame.append_flow(flow)
19 |
20 | # create Ground-Truth horizontally flipped flow
21 | flow_flip_GT = np.empty_like(flow_np)
22 | flow_flip_GT[0, 0, ...] = [[-3, -2, -1], [-6, -5, -4], [-9, -8, -7]]
23 | flow_flip_GT[0, 1, ...] = [[3, 2, 1], [6, 5, 4], [9, 8, 7]]
24 |
25 | # compute flow flipped
26 | frame_flip = frame.hflip()
27 | flow_flip = frame_flip.flow.numpy()
28 |
29 | # compare ground truth to result
30 | assert np.allclose(flow_flip_GT, flow_flip)
31 |
32 |
33 | if __name__ == "__main__":
34 | test_flow_hflip()
35 |
--------------------------------------------------------------------------------
/unittest/test_points2d.py:
--------------------------------------------------------------------------------
1 | # from aloscene.renderer import View
2 | from alodataset import WaymoDataset # , Split
3 | import aloscene
4 | import torch
5 | import numpy as np
6 |
7 |
8 | def test_crop_abs():
9 | image = np.zeros((3, 843, 1500))
10 | corners = [[298, 105], [1250, 105], [298, 705], [1250, 705]]
11 | frame = aloscene.Frame(image)
12 | labels = aloscene.Labels([0, 0, 0, 0], labels_names=["corners"])
13 | corners = aloscene.Points2D(
14 | corners, points_format="xy", frame_size=(frame.H, frame.W), absolute=True, labels=labels
15 | )
16 | frame.append_points2d(corners)
17 | frame = frame.crop(H_crop=(0.0, 0.5), W_crop=(0.0, 0.5))
18 | assert torch.allclose(frame.points2d[0].as_tensor(), corners[0].as_tensor())
19 | assert np.allclose(frame.points2d.frame_size[0], frame.HW[0])
20 | assert np.allclose(frame.points2d.frame_size[1], frame.HW[1])
21 |
22 |
23 | if __name__ == "__main__":
24 | test_crop_abs()
25 |
--------------------------------------------------------------------------------
/unittest/test_train.py:
--------------------------------------------------------------------------------
1 | import argparse
2 | from unittest import mock
3 |
4 | # GithubActionsIgnore : cuda
5 |
6 | def get_argparse_defaults(parser):
7 | defaults = {}
8 | for action in parser._actions:
9 | if not action.required and action.dest != "help":
10 | defaults[action.dest] = action.default
11 | return defaults
12 |
13 |
14 | # DETR TEST
15 |
16 | from alonet.detr.train_on_coco import main as detr_train_on_coco, get_arg_parser as detr_get_arg_parser
17 |
18 | detr_args = get_argparse_defaults(detr_get_arg_parser())
19 | detr_args["weights"] = "detr-r50"
20 | detr_args["train_on_val"] = True
21 | detr_args["fast_dev_run"] = True
22 | detr_args["sample"] = True
23 |
24 |
25 | @mock.patch("argparse.ArgumentParser.parse_args", return_value=argparse.Namespace(**detr_args))
26 | def test_detr(mock_args):
27 | detr_train_on_coco()
28 |
29 |
30 | # DeforambleDETR TEST
31 |
32 | from alonet.deformable_detr.train_on_coco import (
33 | main as def_detr_train_on_coco,
34 | get_arg_parser as def_detr_get_arg_parser,
35 | )
36 |
37 | def_detr_args = get_argparse_defaults(def_detr_get_arg_parser())
38 | def_detr_args["weights"] = "deformable-detr-r50"
39 | def_detr_args["model_name"] = "deformable-detr-r50"
40 | def_detr_args["train_on_val"] = True
41 | def_detr_args["fast_dev_run"] = True
42 | def_detr_args["sample"] = True
43 |
44 |
45 | @mock.patch("argparse.ArgumentParser.parse_args", return_value=argparse.Namespace(**def_detr_args))
46 | def test_deformable_detr(mock_args):
47 | def_detr_train_on_coco()
48 |
49 |
50 | # RAFT TEST
51 |
52 | from alonet.raft.train_on_chairs import main as raft_train_on_chairs, get_args_parser as raft_get_args_parser
53 |
54 | raft_args = get_argparse_defaults(raft_get_args_parser())
55 | raft_args["weights"] = "raft-things"
56 | raft_args["train_on_val"] = True
57 | raft_args["fast_dev_run"] = True
58 | raft_args["sample"] = True
59 |
60 |
61 | @mock.patch("argparse.ArgumentParser.parse_args", return_value=argparse.Namespace(**raft_args))
62 | def test_raft(mock_args):
63 | raft_train_on_chairs()
64 |
65 |
66 | if __name__ == "__main__":
67 | test_deformable_detr()
68 | test_detr()
69 | test_raft()
70 |
--------------------------------------------------------------------------------