├── docs ├── faq.md ├── apis │ ├── datasets │ │ ├── semantickitti_seg_dataset.md │ │ ├── kitti_mono_dataset.md │ │ ├── kitti_pointcloud_dataset.md │ │ └── nuscenes_pointcloud_dataset.md │ ├── models │ │ └── smoke.md │ ├── scheduler.md │ ├── config.md │ ├── trainer.md │ └── checkpoint.md └── api.md ├── contrib └── PaddleRendering │ ├── docs │ └── faq.md │ ├── requirements.txt │ ├── pprndr │ ├── cpp_extensions │ │ ├── radial_n_tangential_undistort │ │ │ └── setup.py │ │ ├── trunc_exp │ │ │ ├── src │ │ │ │ └── trunc_exp.cu │ │ │ └── setup.py │ │ ├── ray_marching │ │ │ └── setup.py │ │ └── sh_encoder │ │ │ └── src │ │ │ └── sh_encoder.cc │ ├── metrics │ │ └── __init__.py │ ├── models │ │ ├── nerf │ │ │ └── __init__.py │ │ ├── neus │ │ │ └── __init__.py │ │ ├── mip_nerf │ │ │ └── __init__.py │ │ ├── ref_nerf │ │ │ └── __init__.py │ │ ├── renderers │ │ │ └── __init__.py │ │ ├── tensorf │ │ │ └── __init__.py │ │ ├── plenoxels │ │ │ └── __init__.py │ │ ├── instant_ngp │ │ │ └── __init__.py │ │ ├── layers │ │ │ └── __init__.py │ │ ├── ray_samplers │ │ │ ├── __init__.py │ │ │ └── base.py │ │ ├── encoders │ │ │ ├── __init__.py │ │ │ └── sh_encoder.py │ │ ├── __init__.py │ │ ├── fields │ │ │ └── __init__.py │ │ └── ray_generators.py │ ├── utils │ │ ├── __init__.py │ │ └── colors.py │ ├── optimizers │ │ └── __init__.py │ ├── geometries │ │ └── __init__.py │ ├── data │ │ ├── dataloaders │ │ │ └── __init__.py │ │ ├── transforms │ │ │ ├── __init__.py │ │ │ ├── base.py │ │ │ └── normal_transforms.py │ │ ├── __init__.py │ │ └── datasets │ │ │ ├── __init__.py │ │ │ └── base.py │ ├── apis │ │ └── __init__.py │ ├── __init__.py │ └── cameras │ │ └── __init__.py │ ├── README.md │ └── configs │ └── plenoxels │ ├── blender_data.yml │ └── blender_data_grad_accum.yml ├── configs ├── caddn │ └── README.md ├── paconv │ ├── README.md │ └── paconv_modelnet40.yml ├── smoke │ ├── README.md │ ├── smoke_hrnet18_no_dcn_kitti.yml │ ├── smoke_dla34_no_dcn_kitti.yml │ └── smoke_hrnet18_no_dcn_kitti_mini.yml ├── pv_rcnn │ └── README.md ├── bevformer │ └── README.md ├── centerpoint │ └── README.md ├── voxel_rcnn │ └── README.md ├── pointpillars │ └── README.md ├── squeezesegv3 │ ├── README.md │ ├── squeezesegv3_rangenet21_semantickitti.yml │ └── squeezesegv3_rangenet53_semantickitti.yml ├── quant │ ├── smoke_kitti.yml │ ├── centerpoint_kitti.yml │ ├── bevformer.yml │ ├── bevformer_PACT.yml │ └── README.md ├── _base_ │ ├── kitti_mono.yml │ └── semantickitti.yml └── bev_lanedet │ └── bev_lanedet_apollo_576x1024.yml ├── paddle3d ├── thirdparty │ ├── semantic_kitti_api │ │ ├── auxiliary │ │ │ ├── __init__.py │ │ │ └── shaders │ │ │ │ ├── empty.frag │ │ │ │ ├── empty.vert │ │ │ │ ├── passthrough.frag │ │ │ │ ├── check_uniforms.vert │ │ │ │ ├── draw_voxels.frag │ │ │ │ ├── draw_pose.geom │ │ │ │ └── draw_voxels.vert │ │ ├── .pep8 │ │ ├── .gitignore │ │ ├── requirements.txt │ │ ├── docker.sh │ │ └── LICENSE │ ├── __init__.py │ └── kitti_object_eval_python │ │ ├── evaluate.py │ │ └── LICENSE ├── models │ ├── detection │ │ ├── bevdet │ │ │ └── __init__.py │ │ ├── caddn │ │ │ ├── ffe │ │ │ │ ├── ddn_loss │ │ │ │ │ └── __init__.py │ │ │ │ └── __init__.py │ │ │ ├── f2v │ │ │ │ └── __init__.py │ │ │ └── __init__.py │ │ ├── bev_lanedet │ │ │ └── __init__.py │ │ ├── bevformer │ │ │ └── __init__.py │ │ ├── rtebev │ │ │ └── __init__.py │ │ ├── pv_rcnn │ │ │ └── __init__.py │ │ ├── voxel_rcnn │ │ │ └── __init__.py │ │ ├── dd3d │ │ │ └── __init__.py │ │ ├── iassd │ │ │ └── __init__.py │ │ ├── petr │ │ │ └── __init__.py │ │ ├── bevfusion │ │ │ ├── __init__.py │ │ │ └── mvx_faster_rcnn.py │ │ ├── centerpoint │ │ │ └── __init__.py │ │ ├── pointpillars │ │ │ └── __init__.py │ │ ├── smoke │ │ │ └── __init__.py │ │ └── __init__.py │ ├── transformers │ │ ├── match_costs │ │ │ └── __init__.py │ │ ├── samplers │ │ │ └── __init__.py │ │ ├── assigners │ │ │ └── __init__.py │ │ ├── attentions │ │ │ └── __init__.py │ │ └── __init__.py │ ├── heads │ │ ├── dense_heads │ │ │ ├── samplers │ │ │ │ └── __init__.py │ │ │ ├── match_costs │ │ │ │ └── __init__.py │ │ │ ├── target_assigner │ │ │ │ └── __init__.py │ │ │ └── __init__.py │ │ ├── class_heads │ │ │ └── __init__.py │ │ ├── fcos_heads │ │ │ └── __init__.py │ │ ├── roi_heads │ │ │ ├── target_assigner │ │ │ │ └── __init__.py │ │ │ └── __init__.py │ │ └── __init__.py │ ├── classification │ │ ├── __init__.py │ │ └── paconv │ │ │ └── __init__.py │ ├── segmentation │ │ ├── __init__.py │ │ └── squeezesegv3 │ │ │ └── __init__.py │ ├── voxelizers │ │ └── __init__.py │ ├── point_encoders │ │ └── __init__.py │ ├── common │ │ ├── __init__.py │ │ └── pointnet2_stack │ │ │ └── __init__.py │ ├── voxel_encoders │ │ └── __init__.py │ ├── middle_encoders │ │ └── __init__.py │ ├── optimizers │ │ ├── utils.py │ │ └── __init__.py │ ├── necks │ │ └── __init__.py │ ├── base │ │ ├── __init__.py │ │ └── base_detection.py │ ├── backbones │ │ └── __init__.py │ ├── __init__.py │ ├── layers │ │ └── __init__.py │ └── losses │ │ └── __init__.py ├── datasets │ ├── modelnet40 │ │ ├── __init__.py │ │ └── modelnet40_metric.py │ ├── apollo │ │ └── __init__.py │ ├── semantic_kitti │ │ └── __init__.py │ ├── waymo │ │ └── __init__.py │ ├── kitti │ │ └── __init__.py │ ├── nuscenes │ │ ├── __init__.py │ │ └── nuscenes_manager.py │ ├── metrics.py │ └── __init__.py ├── utils │ ├── __init__.py │ ├── amp_utils.py │ ├── common.py │ └── box_utils.py ├── geometries │ ├── __init__.py │ └── structure.py ├── ops │ ├── setup.py │ └── iou3d_nms │ │ ├── iou3d_cpu.h │ │ └── iou3d_nms.h ├── apis │ └── __init__.py ├── transforms │ ├── __init__.py │ └── base.py ├── __init__.py └── slim │ ├── __init__.py │ └── quant.py ├── .style.yapf ├── test_tipc ├── docs │ └── guide.png ├── configs │ ├── paconv │ │ ├── paconv_modelnet40.yml │ │ └── train_infer_python.txt │ ├── caddn │ │ └── caddn_ocrnet_hrnet_w18_kitti_train_infer_python.txt │ ├── petrv1 │ │ ├── petr_vovnet_gridmask_p4_800x320_fp32_ultra_train_infer_python.txt │ │ └── petr_vovnet_gridmask_p4_800x320_ampO2_ultra_train_infer_python.txt │ ├── petrv2 │ │ ├── petrv2_vovnet_gridmask_p4_800x320_dn_centerview_train_infer_python.txt │ │ └── petrv2_vovnet_gridmask_p4_800x320_train_infer_python.txt │ ├── centerpoint │ │ ├── centerpoint_pillars_02voxel_nuscenes_10sweep_ampO2_ultra_train_infer_python.txt │ │ ├── centerpoint_pillars_02voxel_nuscenes_10sweep_fp32_ultra_train_infer_python.txt │ │ └── centerpoint_pillars_016voxel_kitti_train_infer_python.txt │ └── pointpillars │ │ └── train_infer_python.txt ├── test_train_inference_python_npu.sh ├── test_train_inference_python_xpu.sh ├── common_func.sh └── README.md ├── deploy ├── rtebev │ └── python │ │ └── plugin_ops │ │ ├── install.sh │ │ ├── cudaComputeVersion.cu │ │ ├── plugin │ │ └── bevpoolv2 │ │ │ └── trt_bev_pool_kernel.hpp │ │ └── CMakeLists.txt ├── caddn │ └── cpp │ │ ├── custom_ops │ │ ├── iou3d_cpu.h │ │ ├── iou3d_nms.h │ │ └── iou3d_nms_api.cpp │ │ ├── compile.sh │ │ └── cmake │ │ └── external │ │ └── boost.cmake ├── iassd │ └── cpp │ │ ├── custom_ops │ │ ├── iou3d_cpu.h │ │ └── iou3d_nms.h │ │ ├── compile.sh │ │ └── cmake │ │ └── external │ │ └── boost.cmake ├── pointpillars │ └── cpp │ │ ├── custom_ops │ │ ├── iou3d_cpu.h │ │ └── iou3d_nms.h │ │ └── compile.sh ├── pv_rcnn │ └── cpp │ │ ├── custom_ops │ │ └── iou3d_nms │ │ │ ├── iou3d_cpu.h │ │ │ └── iou3d_nms.h │ │ └── compile.sh ├── voxel_rcnn │ └── cpp │ │ ├── custom_ops │ │ └── iou3d_nms │ │ │ ├── iou3d_cpu.h │ │ │ └── iou3d_nms.h │ │ └── compile.sh ├── smoke │ └── cpp │ │ └── compile.sh ├── centerpoint │ └── cpp │ │ └── compile.sh └── petr │ └── cpp │ ├── compile.sh │ └── cmake │ └── external │ └── boost.cmake ├── requirements.txt ├── requirements_pdx.txt ├── .gitmodules ├── .clang_format.hook ├── tests ├── apis │ └── test_scheduler.py └── datasets │ └── test_nuscenes_dataset.py └── .pre-commit-config.yaml /docs/faq.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/docs/faq.md: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /configs/caddn/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/caddn/README.md -------------------------------------------------------------------------------- /configs/paconv/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/paconv/README.md -------------------------------------------------------------------------------- /configs/smoke/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/smoke/README.md -------------------------------------------------------------------------------- /configs/pv_rcnn/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/pv_rcnn/README.md -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/auxiliary/__init__.py: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /configs/bevformer/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/bevformer/README.md -------------------------------------------------------------------------------- /configs/centerpoint/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/centerpoint/README.md -------------------------------------------------------------------------------- /configs/voxel_rcnn/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/voxel_rcnn/README.md -------------------------------------------------------------------------------- /.style.yapf: -------------------------------------------------------------------------------- 1 | [style] 2 | based_on_style = pep8 3 | column_limit = 80 4 | -------------------------------------------------------------------------------- /configs/pointpillars/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/pointpillars/README.md -------------------------------------------------------------------------------- /configs/squeezesegv3/README.md: -------------------------------------------------------------------------------- 1 | ../../docs/models/squeezesegv3/README.md -------------------------------------------------------------------------------- /paddle3d/models/detection/bevdet/__init__.py: -------------------------------------------------------------------------------- 1 | from .bevdet4d import * 2 | -------------------------------------------------------------------------------- /paddle3d/datasets/modelnet40/__init__.py: -------------------------------------------------------------------------------- 1 | from .modelnet40_cls import ModelNet40 2 | -------------------------------------------------------------------------------- /paddle3d/models/transformers/match_costs/__init__.py: -------------------------------------------------------------------------------- 1 | from .match_cost import * 2 | -------------------------------------------------------------------------------- /paddle3d/models/transformers/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | from .pseudo_sampler import * 2 | -------------------------------------------------------------------------------- /paddle3d/models/detection/caddn/ffe/ddn_loss/__init__.py: -------------------------------------------------------------------------------- 1 | from .ddn_loss import DDNLoss 2 | -------------------------------------------------------------------------------- /paddle3d/models/transformers/assigners/__init__.py: -------------------------------------------------------------------------------- 1 | from .hungarian_assigner_3d import * 2 | -------------------------------------------------------------------------------- /paddle3d/models/detection/caddn/f2v/__init__.py: -------------------------------------------------------------------------------- 1 | from .frustum_to_voxel import FrustumToVoxel 2 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/.pep8: -------------------------------------------------------------------------------- 1 | [pep8] 2 | max-line-length = 120 3 | indent-size = 2 -------------------------------------------------------------------------------- /paddle3d/models/detection/caddn/ffe/__init__.py: -------------------------------------------------------------------------------- 1 | from .ddn_loss import * 2 | from .ffe import FFE 3 | -------------------------------------------------------------------------------- /paddle3d/models/heads/dense_heads/samplers/__init__.py: -------------------------------------------------------------------------------- 1 | from .pseudo_sampler import PseudoSampler 2 | -------------------------------------------------------------------------------- /test_tipc/docs/guide.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PaddlePaddle/Paddle3D/HEAD/test_tipc/docs/guide.png -------------------------------------------------------------------------------- /paddle3d/models/detection/bev_lanedet/__init__.py: -------------------------------------------------------------------------------- 1 | from . import bev_lanedet 2 | from .bev_lanedet import * 3 | -------------------------------------------------------------------------------- /paddle3d/datasets/apollo/__init__.py: -------------------------------------------------------------------------------- 1 | from .apollo_lane_det import ApolloOffsetValDataset, ApolloOffsetDataset 2 | -------------------------------------------------------------------------------- /paddle3d/models/heads/dense_heads/match_costs/__init__.py: -------------------------------------------------------------------------------- 1 | from .match_cost import BBox3DL1Cost, FocalLossCost, IoUCost 2 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/auxiliary/shaders/empty.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | 4 | void main() 5 | { 6 | 7 | } -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/auxiliary/shaders/empty.vert: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | 4 | void main() 5 | { 6 | 7 | } -------------------------------------------------------------------------------- /deploy/rtebev/python/plugin_ops/install.sh: -------------------------------------------------------------------------------- 1 | mkdir build 2 | cd build 3 | cmake .. -DCMAKE_TENSORRT_PATH=/Path/To/TensorRT 4 | make -j$(nproc) 5 | -------------------------------------------------------------------------------- /paddle3d/models/detection/bevformer/__init__.py: -------------------------------------------------------------------------------- 1 | from . import bevformer, bevformer_head 2 | from .bevformer import * 3 | from .bevformer_head import * 4 | -------------------------------------------------------------------------------- /paddle3d/models/detection/rtebev/__init__.py: -------------------------------------------------------------------------------- 1 | from . import rtebev 2 | from . import rtebev_head 3 | from .rtebev import * 4 | from .rtebev_head import * 5 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.pyo 3 | *.o 4 | *.so 5 | *.a 6 | **build 7 | .vscode 8 | *.cxx 9 | RangeNet.py 10 | 11 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/auxiliary/shaders/passthrough.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | in vec4 color; 4 | out vec4 out_color; 5 | 6 | void main() 7 | { 8 | out_color = color; 9 | } -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/requirements.txt: -------------------------------------------------------------------------------- 1 | matplotlib>=2.2.3 2 | vispy>=0.5.3 3 | torch>=1.1.0 4 | numpy>=1.14.0 5 | PyYAML>=5.1.1 6 | imgui[glfw]>=1.0.0 7 | glfw>=1.8.3 8 | PyOpenGL>=3.1.0 9 | pyqt5>=5.8.1.1 10 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/requirements.txt: -------------------------------------------------------------------------------- 1 | colorlog 2 | filelock 3 | numpy 4 | imageio==2.21.1 5 | opencv-python 6 | pyyaml 7 | pillow 8 | rarfile 9 | visualdl 10 | easydict 11 | scipy==1.7.0 12 | PyMCubes==0.1.2 13 | trimesh==3.9.8 14 | -------------------------------------------------------------------------------- /deploy/rtebev/python/plugin_ops/cudaComputeVersion.cu: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | cudaDeviceProp prop; 5 | cudaGetDeviceProperties(&prop, 0); 6 | int v = prop.major * 10 + prop.minor; 7 | printf("%d", v); 8 | return 0; 9 | } -------------------------------------------------------------------------------- /paddle3d/models/transformers/attentions/__init__.py: -------------------------------------------------------------------------------- 1 | from . import (multihead_attention, spatial_cross_attention, 2 | temporal_self_attention) 3 | from .multihead_attention import * 4 | from .spatial_cross_attention import * 5 | from .temporal_self_attention import * 6 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | colorlog 2 | easydict 3 | filelock 4 | numba >= 0.56 5 | numpy 6 | nuscenes-devkit 7 | opencv-python <= 4.6.0.66 8 | opencv-python-headless <= 4.6.0.66 9 | pandas 10 | paddledet 11 | paddleseg 12 | pyquaternion 13 | pyyaml 14 | pillow 15 | rarfile 16 | scikit-image 17 | scikit-learn 18 | visualdl 19 | h5py 20 | einops 21 | albumentations 22 | -------------------------------------------------------------------------------- /requirements_pdx.txt: -------------------------------------------------------------------------------- 1 | colorlog 2 | easydict 3 | filelock 4 | numba >= 0.56 5 | numpy 6 | nuscenes-devkit 7 | opencv-python <= 4.6.0.66 8 | opencv-python-headless == 4.10.0.84 9 | pandas 10 | paddledet 11 | paddleseg 12 | pyquaternion 13 | pyyaml 14 | pillow 15 | rarfile 16 | scikit-image 17 | scikit-learn 18 | visualdl 19 | h5py 20 | einops 21 | albumentations 22 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/docker.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # This file is covered by the LICENSE file in the root of this project. 3 | docker build -t api --build-arg uid=$(id -g) --build-arg gid=$(id -g) . 4 | docker run --privileged \ 5 | -ti --rm -e DISPLAY=$DISPLAY \ 6 | -v /tmp/.X11-unix:/tmp/.X11-unix \ 7 | -v $1:/home/developer/data/ \ 8 | api -------------------------------------------------------------------------------- /paddle3d/models/transformers/__init__.py: -------------------------------------------------------------------------------- 1 | from .assigners import * 2 | from .attentions import * 3 | from .decoder_layers import * 4 | from .decoders import * 5 | from .encoder_layers import * 6 | from .encoders import * 7 | from .match_costs import * 8 | from .positional_encoding import * 9 | from .samplers import * 10 | from .transformer import * 11 | from .utils import * 12 | from .bevdet_transformer import * 13 | -------------------------------------------------------------------------------- /deploy/caddn/cpp/custom_ops/iou3d_cpu.h: -------------------------------------------------------------------------------- 1 | #ifndef IOU3D_CPU_H 2 | #define IOU3D_CPU_H 3 | 4 | #include 5 | #include 6 | 7 | #include 8 | 9 | #include "paddle/include/experimental/ext_all.h" 10 | 11 | int boxes_iou_bev_cpu(paddle::Tensor boxes_a_tensor, 12 | paddle::Tensor boxes_b_tensor, 13 | paddle::Tensor ans_iou_tensor); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /docs/apis/datasets/semantickitti_seg_dataset.md: -------------------------------------------------------------------------------- 1 | # paddle3d.datasets.SemanticKITTIDataset 2 | 3 | SemanticKITTI点云分割数据集,数据集信息请参考[SemanticKITTI官网](http://www.semantic-kitti.org/) 4 | 5 | ## \_\_init\_\_ 6 | 7 | * **参数** 8 | 9 | * dataset_root: 数据集的根目录 10 | 11 | * mode: 数据集模式,支持 `train` / `val` / `trainval` / `test` 等格式 12 | 13 | * sequences: 数据划分序列,可以不指定,默认使用官网推荐的划分方式 14 | 15 | * transforms: 数据增强方法 16 | -------------------------------------------------------------------------------- /docs/apis/datasets/kitti_mono_dataset.md: -------------------------------------------------------------------------------- 1 | # paddle3d.datasets.KittiMonoDataset 2 | 3 | KITTI单目3D检测数据集,数据集信息请参考[KITTI官网](http://www.cvlibs.net/datasets/kitti/) 4 | 5 | *注意:KITTI官网只区分了训练集和测试集,我们遵循业界的普遍做法,将7481个训练集样本,进一步划分为3712个训练集样本和3769个验证集样本* 6 | 7 | ## \_\_init\_\_ 8 | 9 | * **参数** 10 | 11 | * dataset_root: 数据集的根目录 12 | 13 | * mode: 数据集模式,支持 `train` / `val` / `trainval` / `test` 等格式 14 | 15 | * transforms: 数据增强方法 16 | -------------------------------------------------------------------------------- /docs/apis/datasets/kitti_pointcloud_dataset.md: -------------------------------------------------------------------------------- 1 | # paddle3d.datasets.KittiPCDataset 2 | 3 | KITTI点云检测数据集,数据集信息请参考[KITTI官网](http://www.cvlibs.net/datasets/kitti/) 4 | 5 | *注意:KITTI官网只区分了训练集和测试集,我们遵循业界的普遍做法,将7481个训练集样本,进一步划分为3712个训练集样本和3769个验证集样本* 6 | 7 | ## \_\_init\_\_ 8 | 9 | * **参数** 10 | 11 | * dataset_root: 数据集的根目录 12 | 13 | * mode: 数据集模式,支持 `train` / `val` / `trainval` / `test` 等格式 14 | 15 | * transforms: 数据增强方法 16 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/auxiliary/shaders/check_uniforms.vert: -------------------------------------------------------------------------------- 1 | 2 | #version 330 core 3 | 4 | 5 | uniform mat4 test; 6 | 7 | out vec4 color; 8 | 9 | void main() { 10 | 11 | float value = float(gl_VertexID); 12 | 13 | gl_Position = vec4(value/16.0, value/16.0, 0, 1); 14 | if(test[int(value/4)][int(value)%4] == value) 15 | { 16 | color = vec4(0,1,0,1); 17 | } 18 | else 19 | { 20 | color = vec4(1,0,0,1); 21 | } 22 | } -------------------------------------------------------------------------------- /paddle3d/utils/__init__.py: -------------------------------------------------------------------------------- 1 | from .amp_utils import dtype2float32 2 | from .box import * 3 | from .box_coder import * 4 | from .box_utils import * 5 | from .checkpoint import * 6 | from .common import * 7 | from .depth import * 8 | from .download import * 9 | from .grid import * 10 | from .logger import * 11 | from .timer import * 12 | from .transform import * 13 | from .xarfile import * 14 | from .transform3d import * 15 | from .profiler import * 16 | from .ema import * 17 | -------------------------------------------------------------------------------- /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "contrib/PaddleRendering/pprndr/cpp_extensions/ffmlp/dependencies/cutlass"] 2 | path = contrib/PaddleRendering/pprndr/cpp_extensions/ffmlp/dependencies/cutlass 3 | url = https://github.com/NVIDIA/cutlass.git 4 | [submodule "contrib/PaddleRendering/pprndr/cpp_extensions/ray_marching/dependencies/cuda-samples"] 5 | path = contrib/PaddleRendering/pprndr/cpp_extensions/ray_marching/dependencies/cuda-samples 6 | url = https://github.com/NVIDIA/cuda-samples.git 7 | -------------------------------------------------------------------------------- /.clang_format.hook: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | readonly VERSIONS=("10.0.0" "10.0.1") 5 | version=$(clang-format -version) 6 | 7 | for v in ${VERSIONS[*]}; do 8 | if [[ "${version}" == *"${v}"* ]]; then 9 | clang-format $@ 10 | exit 0 11 | fi 12 | done 13 | 14 | echo "clang-format version check failed." 15 | echo "a version in ${VERSIONS[*]} is needed, but get ${version}" 16 | echo "please install the right version via 'pip install clang-format==version'" 17 | exit -1 18 | -------------------------------------------------------------------------------- /configs/quant/smoke_kitti.yml: -------------------------------------------------------------------------------- 1 | slim_type: QAT 2 | 3 | quant_config: 4 | weight_quantize_type: channel_wise_abs_max 5 | activation_quantize_type: moving_average_abs_max 6 | weight_bits: 8 7 | activation_bits: 8 8 | dtype: int8 9 | window_size: 10000 10 | moving_rate: 0.9 11 | quantizable_layer_type: ['Conv2D', 'Linear'] 12 | 13 | finetune_config: 14 | iters: 40000 15 | 16 | lr_scheduler: 17 | type: MultiStepDecay 18 | milestones: [32000, 36000] 19 | learning_rate: 1.25e-4 20 | -------------------------------------------------------------------------------- /configs/_base_/kitti_mono.yml: -------------------------------------------------------------------------------- 1 | train_dataset: 2 | type: KittiMonoDataset 3 | dataset_root: datasets/KITTI 4 | transforms: 5 | - type: LoadImage 6 | - type: Normalize 7 | mean: [0.485, 0.456, 0.406] 8 | std: [0.229, 0.224, 0.225] 9 | mode: train 10 | 11 | val_dataset: 12 | type: KittiMonoDataset 13 | dataset_root: datasets/KITTI 14 | transforms: 15 | - type: LoadImage 16 | - type: Normalize 17 | mean: [0.485, 0.456, 0.406] 18 | std: [0.229, 0.224, 0.225] 19 | mode: val 20 | -------------------------------------------------------------------------------- /configs/quant/centerpoint_kitti.yml: -------------------------------------------------------------------------------- 1 | slim_type: QAT 2 | 3 | quant_config: 4 | weight_quantize_type: channel_wise_abs_max 5 | activation_quantize_type: moving_average_abs_max 6 | weight_bits: 8 7 | activation_bits: 8 8 | dtype: int8 9 | window_size: 10000 10 | moving_rate: 0.9 11 | quantizable_layer_type: ['Conv2D', 'Linear'] 12 | 13 | finetune_config: 14 | epochs: 80 15 | 16 | lr_scheduler: 17 | type: OneCycleWarmupDecayLr 18 | base_learning_rate: 0.001 19 | lr_ratio_peak: 10 20 | lr_ratio_trough: 0.0001 21 | step_ratio_peak: 0.4 22 | -------------------------------------------------------------------------------- /paddle3d/utils/amp_utils.py: -------------------------------------------------------------------------------- 1 | from collections.abc import Mapping, Sequence 2 | from typing import List 3 | 4 | import paddle 5 | 6 | 7 | def dtype2float32(src_tensors): 8 | if isinstance(src_tensors, 9 | paddle.Tensor) and src_tensors.dtype != 'float32': 10 | return src_tensors.astype('float32') 11 | elif isinstance(src_tensors, Sequence): 12 | return type(src_tensors)([dtype2float32(x) for x in src_tensors]) 13 | elif isinstance(src_tensors, Mapping): 14 | return {key: dtype2float32(x) for key, x in src_tensors.items()} 15 | return src_tensors 16 | -------------------------------------------------------------------------------- /docs/apis/datasets/nuscenes_pointcloud_dataset.md: -------------------------------------------------------------------------------- 1 | # paddle3d.datasets.NuscenesPCDataset 2 | 3 | Nuscenes点云检测数据集,数据集信息请参考[NuScenes官网](https://www.nuscenes.org/) 4 | 5 | ## \_\_init\_\_ 6 | 7 | * **参数** 8 | 9 | * dataset_root: 数据集的根目录 10 | 11 | * mode: 数据集模式,支持 `train` / `val` / `trainval` / `test` / `mini_train` / `mini_val` 等格式 12 | 13 | *注意:当使用NuScenes官方提供的mini数据集时,请指定mode为 mini_train 或者 mini_val* 14 | 15 | * transforms: 数据增强方法 16 | 17 | * max_sweeps: 用于增强每一帧点云的sweeps数量,默认为10 18 | 19 | * class_balanced_sampling: 是否做类别均衡采样,默认为False 20 | 21 | * class_names: 类别名,可以不指定 22 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/cpp_extensions/radial_n_tangential_undistort/setup.py: -------------------------------------------------------------------------------- 1 | import paddle 2 | from paddle.utils.cpp_extension import CppExtension, CUDAExtension, setup 3 | 4 | if paddle.device.is_compiled_with_cuda(): 5 | setup( 6 | name='undistort', 7 | version='1.0.0', 8 | ext_modules=CUDAExtension( 9 | sources=['./src/undist_gpu.cc', './src/undist_gpu.cu']), 10 | extra_compile_args={'cxx': ['-DPADDLE_WITH_CUDA']}) 11 | else: 12 | setup( 13 | name='undistort', 14 | version='1.0.0', 15 | ext_modules=CppExtension(sources=['./src/undist_gpu.cc'])) 16 | -------------------------------------------------------------------------------- /deploy/rtebev/python/plugin_ops/plugin/bevpoolv2/trt_bev_pool_kernel.hpp: -------------------------------------------------------------------------------- 1 | #ifndef TRT_BEV_POOL_KERNEL_HPP 2 | #define TRT_BEV_POOL_KERNEL_HPP 3 | #include 4 | 5 | #include "common_cuda_helper.hpp" 6 | 7 | // CUDA function declarations 8 | void bev_pool_v2(int c, int n_intervals, const float* depth, const float* feat, 9 | const int* ranks_depth, const int* ranks_feat, 10 | const int* ranks_bev, const int* interval_starts, 11 | const int* interval_lengths, float* out, cudaStream_t stream); 12 | 13 | void bev_pool_v2_set_zero(int n_points, float* out); 14 | #endif // TRT_BEV_POOL_KERNEL_HPP 15 | -------------------------------------------------------------------------------- /configs/quant/bevformer.yml: -------------------------------------------------------------------------------- 1 | slim_type: QAT 2 | 3 | quant_config: 4 | weight_quantize_type: channel_wise_abs_max 5 | activation_quantize_type: moving_average_abs_max 6 | weight_bits: 8 7 | activation_bits: 8 8 | dtype: int8 9 | window_size: 10000 10 | moving_rate: 0.9 11 | quantizable_layer_type: ['Conv2D', 'Linear'] 12 | 13 | finetune_config: 14 | epochs: 5 15 | batch_size: 2 16 | lr_scheduler: 17 | type: LinearWarmup 18 | learning_rate: 19 | type: CosineAnnealingDecayByEpoch 20 | learning_rate: 0.00002 21 | T_max: 5 22 | eta_min: 0.0000002 23 | warmup_steps: 500 24 | start_lr: 0.000006666666 25 | end_lr: 0.00002 26 | -------------------------------------------------------------------------------- /docs/api.md: -------------------------------------------------------------------------------- 1 | # 训练 2 | 3 | * [paddle3d.apis.Checkpoint](apis/checkpoint.md) 4 | 5 | * [paddle3d.apis.Config](apis/config.md) 6 | 7 | * [paddle3d.apis.Scheduler](apis/scheduler.md) 8 | 9 | * [paddle3d.apis.Trainer](apis/trainer.md) 10 | 11 | # 模型 12 | 13 | * [paddle3d.models.SMOKE](apis/models/smoke.md) 14 | 15 | # 数据集 16 | 17 | * [paddle3d.datasets.KittiMonoDataset](apis/datasets/kitti_mono_dataset.md) 18 | 19 | * [paddle3d.datasets.KittiPCDataset](apis/datasets/kitti_pointcloud_dataset.md) 20 | 21 | * [paddle3d.datasets.NuscenesPCDataset](apis/datasets/nuscenes_pointcloud_dataset.md) 22 | 23 | * [paddle3d.datasets.SemanticKITTIDataset](apis/datasets/semantickitti_seg_dataset.md) 24 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/cpp_extensions/trunc_exp/src/trunc_exp.cu: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "paddle/extension.h" 5 | 6 | #define CHECK_CUDA_INPUT(x) PD_CHECK(x.is_gpu(), #x " must be a GPU Tensor.") 7 | 8 | std::vector trunc_exp_cuda_forward(const paddle::Tensor& x) { 9 | CHECK_CUDA_INPUT(x); 10 | 11 | return {paddle::exp(x)}; 12 | } 13 | 14 | std::vector trunc_exp_cuda_backward( 15 | const paddle::Tensor& x, const paddle::Tensor& grad_out) { 16 | CHECK_CUDA_INPUT(x); 17 | CHECK_CUDA_INPUT(grad_out); 18 | 19 | return { 20 | paddle::multiply(paddle::exp(paddle::clip(x, -15.0f, 15.0f)), grad_out)}; 21 | } 22 | -------------------------------------------------------------------------------- /docs/apis/models/smoke.md: -------------------------------------------------------------------------------- 1 | # paddle3d.models.SMOKE 2 | 3 | 单目3D检测模型 《Single-Stage Monocular 3D Object Detection via Keypoint Estimation》 4 | 5 | ## \_\_init\_\_ 6 | 7 | * **参数** 8 | 9 | * backbone: 所用的骨干网络 10 | 11 | * head: 预测头,目前只支持 `SMOKEPredictor` 12 | 13 | * depth_ref: 深度参考值 14 | 15 | * dim_ref: 每个类别的维度参考值 16 | 17 | * max_detection: 最大检测目标数量,默认为50 18 | 19 | * pred_2d: 是否同时预测2D检测框结果,默认为True 20 | 21 |
22 | 23 | # paddle3d.models.SMOKEPredictor 24 | 25 | SMOKE模型的预测头 26 | 27 | ## \_\_init\_\_ 28 | 29 | * **参数** 30 | 31 | * num_classe:检测类别数 32 | 33 | * norm_type: NormLayer的类型,默认为gn 34 | 35 | * in_channels: 输入channel数量 36 | -------------------------------------------------------------------------------- /configs/quant/bevformer_PACT.yml: -------------------------------------------------------------------------------- 1 | slim_type: QAT 2 | 3 | quant_config: 4 | weight_quantize_type: channel_wise_abs_max 5 | activation_preprocess_type: PACT 6 | activation_quantize_type: moving_average_abs_max 7 | weight_bits: 8 8 | activation_bits: 8 9 | dtype: int8 10 | window_size: 10000 11 | moving_rate: 0.9 12 | quantizable_layer_type: ['Conv2D', 'Linear'] 13 | 14 | finetune_config: 15 | epochs: 5 16 | batch_size: 2 17 | lr_scheduler: 18 | type: LinearWarmup 19 | learning_rate: 20 | type: CosineAnnealingDecayByEpoch 21 | learning_rate: 0.00002 22 | T_max: 5 23 | eta_min: 0.0000002 24 | warmup_steps: 500 25 | start_lr: 0.000006666666 26 | end_lr: 0.00002 27 | -------------------------------------------------------------------------------- /paddle3d/models/classification/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from .paconv import PAConv 15 | -------------------------------------------------------------------------------- /docs/apis/scheduler.md: -------------------------------------------------------------------------------- 1 | # paddle3d.apis.SchedulerABC 2 | 3 | 调度器抽象基类,定义调度器应该实现的方法 4 | 5 | ## step 6 | 7 | 通知调度器对象步进一次,并返回当前步的调度状态 `SchedulerStatus` 8 | 9 |
10 | 11 | # paddle3d.apis.Scheduler 12 | 13 | 调度器类,继承自SchedulerABC,用于决定Trainer训练过程中的调度行为,包括: 14 | 15 | * 是否打印日志 16 | 17 | * 是否保存检查点 18 | 19 | * 是否执行评估操作 20 | 21 | ## \_\_init\_\_ 22 | 23 | * **参数** 24 | 25 | * save_interval: 保存检查点的间隔步数 26 | 27 | * log_interval: 打印日志的间隔步数 28 | 29 | * do_eval: 是否在保存检查点时启动评估 30 | 31 |
32 | 33 | # paddle3d.apis.SchedulerStatus 34 | 35 | namedtuple对象,包含了调度状态 36 | 37 | ## do_eval 38 | 39 | 是否执行评估操作 40 | 41 | ## do_log 42 | 43 | 是否打印日志 44 | 45 | ## save_checkpoint 46 | 47 | 是否保存检查点 48 | -------------------------------------------------------------------------------- /paddle3d/models/classification/paconv/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from .paconv import PAConv 15 | -------------------------------------------------------------------------------- /paddle3d/models/segmentation/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .squeezesegv3 import * 16 | -------------------------------------------------------------------------------- /paddle3d/models/detection/pv_rcnn/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .pv_rcnn import PVRCNN 16 | -------------------------------------------------------------------------------- /paddle3d/models/voxelizers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .voxelize import HardVoxelizer 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/metrics/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .metrics import * 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/nerf/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .nerf import NeRF 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/neus/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .neus import NeuS 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/utils/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .colors import get_color 16 | -------------------------------------------------------------------------------- /paddle3d/models/detection/voxel_rcnn/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .voxel_rcnn import VoxelRCNN 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/optimizers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import lr_schedulers 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/mip_nerf/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .mip_nerf import MipNeRF 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/ref_nerf/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .ref_nerf import RefNeRF 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/renderers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .renderers import * 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/tensorf/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .tensorf import TensoRF 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/plenoxels/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .plenoxels import Plenoxels 16 | -------------------------------------------------------------------------------- /paddle3d/datasets/semantic_kitti/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .semantic_kitti_seg import SemanticKITTISegDataset 16 | -------------------------------------------------------------------------------- /paddle3d/datasets/waymo/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .waymo_pointcloud_det import WaymoPCDataset 16 | -------------------------------------------------------------------------------- /paddle3d/models/detection/dd3d/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .dd3d import * 16 | from .prepare_targets import * 17 | -------------------------------------------------------------------------------- /paddle3d/models/point_encoders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .voxel_set_abstraction import VoxelSetAbstraction 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/instant_ngp/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .instant_ngp import InstantNGP 16 | -------------------------------------------------------------------------------- /paddle3d/models/heads/class_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .deeplabv3_head import * 16 | from .ocrnet_head import * 17 | -------------------------------------------------------------------------------- /paddle3d/models/heads/fcos_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .fcos2d_head import * 16 | from .fcos3d_head import * 17 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/geometries/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .scene_box import ContractionType, SceneBox 16 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/data/dataloaders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .data_loaders import PrefetchDataLoader 16 | -------------------------------------------------------------------------------- /paddle3d/models/segmentation/squeezesegv3/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .squeezesegv3 import * 16 | from .squeezesegv3_loss import * 17 | -------------------------------------------------------------------------------- /paddle3d/models/common/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .box_utils import * 16 | from .model_nms_utils import * 17 | from .pointnet2_stack import * 18 | -------------------------------------------------------------------------------- /paddle3d/models/detection/iassd/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .iassd import * 16 | from .iassd_backbone import * 17 | from .iassd_head import * 18 | -------------------------------------------------------------------------------- /paddle3d/models/heads/roi_heads/target_assigner/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .iou3d_nms_utils import * 16 | from .proposal_target_layer import * 17 | -------------------------------------------------------------------------------- /paddle3d/models/detection/caddn/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .bev import * 16 | from .caddn import * 17 | from .f2v import * 18 | from .ffe import * 19 | -------------------------------------------------------------------------------- /paddle3d/models/detection/petr/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .petr3d import Petr3D 16 | from .petr3d_seg import Petr3D_seg 17 | from .cape import CAPE 18 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/README.md: -------------------------------------------------------------------------------- 1 |

2 | 特性 | 3 | 安装 | 4 | 快速开始 | 5 |

6 | 7 | # PaddleRendering – A 3D Neural Rendering and Reconstruction Platform Based on PaddlePaddle 8 | 9 | **PaddleRtendering**是一个3D神经渲染及重建开发平台,依托于[**PaddlePaddle**](https://www.paddlepaddle.org.cn/)框架。 10 | 11 | ## News 📢 12 | 13 | ## 特性 14 | #### 📦 SOTA神经渲染模型集合 15 | 我们提供 **SOTA(State-of-the-Art)** 的神经渲染及重建模型集合。 16 | 目前 **PaddleRendering** 已经集成了主流的神经渲染模型,并通过**CUDA自定义算子**、**自动混合精度训练 (AMP)**、**光线行进策略优化**等策略对训练速度进行极致优化。如果想要了解当前支持的所有模型的详细信息以及使用方法,可以阅读 🔥 [PaddleRendering](./docs) 文档。 17 | 18 | ## [安装](./docs/installation.md) 19 | 20 | ## [快速开始](./docs/quickstart.md) 21 | 22 | ## License 23 | PaddleRendering 遵循 [Apache-2.0开源协议](../../LICENSE)。 24 | -------------------------------------------------------------------------------- /deploy/caddn/cpp/custom_ops/iou3d_nms.h: -------------------------------------------------------------------------------- 1 | #ifndef IOU3D_NMS_H 2 | #define IOU3D_NMS_H 3 | 4 | // #include 5 | #include 6 | #include 7 | 8 | #include 9 | 10 | #include "paddle/include/experimental/ext_all.h" 11 | 12 | int boxes_overlap_bev_gpu(paddle::Tensor boxes_a, paddle::Tensor boxes_b, 13 | paddle::Tensor ans_overlap); 14 | int boxes_iou_bev_gpu(paddle::Tensor boxes_a, paddle::Tensor boxes_b, 15 | paddle::Tensor ans_iou); 16 | std::vector nms_gpu(const paddle::Tensor& boxes, 17 | float nms_overlap_thresh); 18 | int nms_normal_gpu(paddle::Tensor boxes, paddle::Tensor keep, 19 | float nms_overlap_thresh); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /paddle3d/models/heads/roi_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .pvrcnn_head import * 16 | from .target_assigner import * 17 | from .voxelrcnn_head import * 18 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .grids import * 16 | from .mlps import * 17 | from .weight_initializers import * 18 | -------------------------------------------------------------------------------- /paddle3d/models/detection/bevfusion/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .bevf_faster_rcnn import * 16 | from .bevf_transforms import * 17 | from .mvx_faster_rcnn import * 18 | -------------------------------------------------------------------------------- /paddle3d/models/detection/centerpoint/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import center_head, centerpoint 16 | from .center_head import * 17 | from .centerpoint import * 18 | -------------------------------------------------------------------------------- /paddle3d/models/detection/pointpillars/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .pointpillars import * 16 | from .pointpillars_head import * 17 | from .pointpillars_loss import * 18 | -------------------------------------------------------------------------------- /paddle3d/models/heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .class_heads import * 16 | from .dense_heads import * 17 | from .fcos_heads import * 18 | from .roi_heads import * 19 | -------------------------------------------------------------------------------- /paddle3d/models/voxel_encoders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import pillar_encoder, voxel_encoder 16 | from .pillar_encoder import * 17 | from .voxel_encoder import * 18 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/__init__.py: -------------------------------------------------------------------------------- 1 | from collections.abc import Iterable 2 | from typing import List, Union 3 | 4 | 5 | def kitti_eval(gt_annos: List[dict], 6 | dt_annos: List[dict], 7 | current_classes: Union[None, int, List[int]] = (0, 1, 2), 8 | metric_types=("bbox", "bev", "3d"), 9 | recall_type='R40'): 10 | """ 11 | """ 12 | from paddle3d.thirdparty.kitti_object_eval_python.eval import \ 13 | get_official_eval_result 14 | if not isinstance(current_classes, Iterable): 15 | current_classes = [current_classes] 16 | 17 | return get_official_eval_result( 18 | gt_annos, 19 | dt_annos, 20 | current_classes=current_classes, 21 | metric_types=metric_types, 22 | recall_type=recall_type) 23 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/data/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .base import * 16 | from .image_transforms import * 17 | from .normal_transforms import * 18 | -------------------------------------------------------------------------------- /paddle3d/geometries/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .bbox import BBoxes2D, BBoxes3D, CoordMode 16 | from .pointcloud import PointCloud 17 | from .structure import StructureEncoder 18 | -------------------------------------------------------------------------------- /paddle3d/ops/setup.py: -------------------------------------------------------------------------------- 1 | import paddle 2 | from paddle.utils.cpp_extension import CppExtension, CUDAExtension, setup 3 | 4 | from paddle3d.ops import custom_ops 5 | 6 | for op_name, op_dict in custom_ops.items(): 7 | sources = op_dict.pop('sources', []) 8 | flags = None 9 | 10 | if paddle.device.is_compiled_with_cuda(): 11 | extension = CUDAExtension 12 | flags = {'cxx': ['-DPADDLE_WITH_CUDA']} 13 | if 'extra_cuda_cflags' in op_dict: 14 | flags['nvcc'] = op_dict.pop('extra_cuda_cflags') 15 | else: 16 | sources = filter(lambda x: x.endswith('cu'), sources) 17 | extension = CppExtension 18 | 19 | if len(sources) == 0: 20 | continue 21 | 22 | extension = extension(sources=sources, extra_compile_args=flags) 23 | setup(name=op_name, ext_modules=extension) 24 | -------------------------------------------------------------------------------- /configs/squeezesegv3/squeezesegv3_rangenet21_semantickitti.yml: -------------------------------------------------------------------------------- 1 | _base_: '../_base_/semantickitti.yml' 2 | 3 | batch_size: 2 4 | iters: 179250 # 150 epochs 5 | 6 | optimizer: 7 | type: Momentum 8 | momentum: 0.9 9 | weight_decay: 0.0008 10 | 11 | lr_scheduler: 12 | type: LinearWarmup 13 | learning_rate: 14 | type: ExponentialDecay 15 | learning_rate: 0.008 16 | gamma: 0.999995805413129 # .995 ** (1 / steps_per_epoch) 17 | warmup_steps: 1195 # 1 epoch 18 | start_lr: 0.0 19 | end_lr: 0.008 20 | 21 | model: 22 | type: SqueezeSegV3 23 | num_classes: 20 24 | backbone: 25 | type: SACRangeNet21 26 | in_channels: 5 27 | encoder_dropout_prob: 0.01 28 | decoder_dropout_prob: 0.01 29 | loss: 30 | type: SSGLossComputation 31 | num_classes: 20 32 | epsilon_w: 0.001 33 | ignore_index: 0 34 | -------------------------------------------------------------------------------- /configs/squeezesegv3/squeezesegv3_rangenet53_semantickitti.yml: -------------------------------------------------------------------------------- 1 | _base_: '../_base_/semantickitti.yml' 2 | 3 | batch_size: 1 4 | iters: 179250 # 150 epochs 5 | 6 | optimizer: 7 | type: Momentum 8 | momentum: 0.9 9 | weight_decay: 0.0008 10 | 11 | lr_scheduler: 12 | type: LinearWarmup 13 | learning_rate: 14 | type: ExponentialDecay 15 | learning_rate: 0.004 16 | gamma: 0.999995805413129 # .995 ** (1 / steps_per_epoch) 17 | warmup_steps: 1195 # 1 epoch 18 | start_lr: 0.0 19 | end_lr: 0.004 20 | 21 | model: 22 | type: SqueezeSegV3 23 | num_classes: 20 24 | backbone: 25 | type: SACRangeNet53 26 | in_channels: 5 27 | encoder_dropout_prob: 0.01 28 | decoder_dropout_prob: 0.01 29 | loss: 30 | type: SSGLossComputation 31 | num_classes: 20 32 | epsilon_w: 0.001 33 | ignore_index: 0 34 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/apis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .config import Config 16 | from .scheduler import Scheduler, SchedulerABC, SchedulerStatus 17 | from .trainer import Trainer 18 | -------------------------------------------------------------------------------- /paddle3d/datasets/kitti/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .kitti_depth_det import KittiDepthDataset 16 | from .kitti_mono_det import KittiMonoDataset 17 | from .kitti_pointcloud_det import KittiPCDataset 18 | -------------------------------------------------------------------------------- /paddle3d/models/common/pointnet2_stack/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .pointnet2_modules import * 16 | from .pointnet2_utils import * 17 | from .voxel_pool_modules import * 18 | from .voxel_query_utils import * 19 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/data/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .data_manager import DataManager 16 | from .dataloaders import * 17 | from .datasets import * 18 | from .pixel_sampler import PixelSampler 19 | -------------------------------------------------------------------------------- /paddle3d/models/detection/smoke/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .processor import PostProcessor 16 | from .smoke import SMOKE 17 | from .smoke_coder import SMOKECoder 18 | from .smoke_predictor import SMOKEPredictor 19 | -------------------------------------------------------------------------------- /paddle3d/models/middle_encoders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import pillar_scatter 16 | from .pillar_scatter import PointPillarsScatter 17 | from .sparse_resnet import SparseResNet3D 18 | from .sparsenet import SparseNet3D 19 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import (apis, cameras, cpp_extensions, data, geometries, metrics, models, 16 | optimizers, ray_marching, utils) 17 | 18 | __version__ = "0.5.0" 19 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/data/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .base import BaseDataset 16 | from .blender import BlenderDataset 17 | from .instant_ngp import InstantNGPDataset 18 | from .llff import LLFFDataset 19 | -------------------------------------------------------------------------------- /paddle3d/models/optimizers/utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from math import cos, pi 16 | 17 | 18 | def annealing_cos(start, end, factor, weight=1): 19 | cos_out = cos(pi * factor) + 1 20 | return end + 0.5 * weight * (start - end) * cos_out 21 | -------------------------------------------------------------------------------- /configs/_base_/semantickitti.yml: -------------------------------------------------------------------------------- 1 | train_dataset: 2 | type: SemanticKITTISegDataset 3 | dataset_root: datasets/SemanticKITTI 4 | sequences: [ 0, 1, 2, 3, 4, 5, 6, 7, 9, 10 ] 5 | transforms: 6 | - type: LoadSemanticKITTIRange 7 | project_label: true 8 | - type: NormalizeRangeImage 9 | mean: [ 12.12, 10.88, 0.23, -1.04, 0.21 ] # range, x, y, z, remission 10 | std: [ 12.32, 11.47, 6.91, 0.86, 0.16 ] # range, x, y, z, remission 11 | mode: train 12 | 13 | val_dataset: 14 | type: SemanticKITTISegDataset 15 | dataset_root: datasets/SemanticKITTI 16 | sequences: [ 8, ] 17 | transforms: 18 | - type: LoadSemanticKITTIRange 19 | project_label: false 20 | - type: NormalizeRangeImage 21 | mean: [ 12.12, 10.88, 0.23, -1.04, 0.21 ] # range, x, y, z, remission 22 | std: [ 12.32, 11.47, 6.91, 0.86, 0.16 ] # range, x, y, z, remission 23 | mode: val 24 | -------------------------------------------------------------------------------- /paddle3d/models/necks/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import second_fpn 16 | from . import fpn 17 | from .cp_fpn import CPFPN 18 | from .fpnc import * 19 | from .second_fpn import * 20 | from .fpn import * 21 | from .custom_fpn import CustomFPN 22 | from .lss_fpn import FPN_LSS 23 | -------------------------------------------------------------------------------- /paddle3d/models/heads/dense_heads/target_assigner/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .anchor3d_generator import * 16 | from .anchor_generator import * 17 | from .axis_aligned_target_assigner import * 18 | from .hungarian_assigner import HungarianAssigner3D 19 | from .max_iou_assigner import * 20 | -------------------------------------------------------------------------------- /paddle3d/models/optimizers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .lr_schedulers import (CosineAnnealingDecayByEpoch, OneCycle, 16 | OneCycleWarmupDecayLr) 17 | from .momentum_schedulers import OneCycleDecayWarmupMomentum 18 | from .optimizers import AdamWOnecycle, OneCycleAdam 19 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/auxiliary/shaders/draw_voxels.frag: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | // simple Blinn-Phong Shading. 4 | 5 | out vec4 out_color; 6 | 7 | in vec4 color; 8 | in vec3 position; 9 | in vec3 normal; 10 | 11 | uniform mat4 view_mat; 12 | uniform vec3 lightPos; 13 | 14 | void main() 15 | { 16 | vec3 viewPos = view_mat[3].xyz; 17 | 18 | vec3 ambient = 0.05 * color.xyz; 19 | 20 | vec3 lightDir = normalize(lightPos - position); 21 | vec3 normal1 = normalize(normal); 22 | float diff = max(dot(lightDir, normal1), 0.0); 23 | vec3 diffuse = diff * color.xyz; 24 | 25 | vec3 viewDir = normalize(viewPos - position); 26 | vec3 reflectDir = reflect(-lightDir, normal); 27 | vec3 halfwayDir = normalize(lightDir + viewDir); 28 | 29 | float spec = pow(max(dot(normal, halfwayDir), 0.0), 32.0); 30 | vec3 specular = vec3(0.1) * spec; 31 | 32 | out_color = vec4(ambient + diffuse + specular, 1.0); 33 | } 34 | -------------------------------------------------------------------------------- /configs/paconv/paconv_modelnet40.yml: -------------------------------------------------------------------------------- 1 | batch_size: 32 2 | epochs: 350 3 | 4 | train_dataset: 5 | type: ModelNet40 6 | dataset_root: datasets/modelnet40_ply_hdf5_2048 7 | num_points: 1024 8 | transforms: 9 | - type: GlobalScale 10 | min_scale: 0.667 11 | max_scale: 1.5 12 | size: 3 13 | - type: GlobalTranslate 14 | translation_std: 0.2 15 | distribution: uniform 16 | - type: ShufflePoint 17 | mode: train 18 | 19 | val_dataset: 20 | type: ModelNet40 21 | dataset_root: datasets/modelnet40_ply_hdf5_2048 22 | num_points: 1024 23 | mode: test 24 | 25 | optimizer: 26 | type: Momentum 27 | momentum: 0.9 28 | weight_decay: 0.0001 29 | 30 | lr_scheduler: 31 | type: CosineAnnealingDecay 32 | learning_rate: 0.1 33 | T_max: 107450 34 | eta_min: 0.001 35 | 36 | model: 37 | type: PAConv 38 | k_neighbors: 20 39 | calc_scores: softmax 40 | num_matrices: [8, 8, 8, 8] 41 | dropout: 0.5 42 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/ray_samplers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .base import BaseSampler 16 | from .grid_intersection_samplers import GridIntersectionSampler 17 | from .pdf_samplers import * 18 | from .spaced_samplers import * 19 | from .volumetric_samplers import VolumetricSampler 20 | -------------------------------------------------------------------------------- /test_tipc/configs/paconv/paconv_modelnet40.yml: -------------------------------------------------------------------------------- 1 | batch_size: 1 2 | epochs: 1 3 | 4 | train_dataset: 5 | type: ModelNet40 6 | dataset_root: ./test_tipc/data/mini_modelnet40 7 | num_points: 1024 8 | transforms: 9 | - type: GlobalScale 10 | min_scale: 0.667 11 | max_scale: 1.5 12 | size: 3 13 | - type: GlobalTranslate 14 | translation_std: 0.2 15 | distribution: uniform 16 | - type: ShufflePoint 17 | mode: train 18 | 19 | val_dataset: 20 | type: ModelNet40 21 | dataset_root: ./test_tipc/data/mini_modelnet40 22 | num_points: 1024 23 | mode: test 24 | 25 | optimizer: 26 | type: Momentum 27 | momentum: 0.9 28 | weight_decay: 0.0001 29 | 30 | lr_scheduler: 31 | type: CosineAnnealingDecay 32 | learning_rate: 0.1 33 | T_max: 107450 34 | eta_min: 0.001 35 | 36 | model: 37 | type: PAConv 38 | k_neighbors: 20 39 | calc_scores: softmax 40 | num_matrices: [8, 8, 8, 8] 41 | dropout: 0.5 42 | -------------------------------------------------------------------------------- /paddle3d/models/base/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .base_model import add_export_args, Base3DModel 16 | from .base_detection import BaseDetectionModel 17 | from .base_lidar_detection import BaseLidarModel 18 | from .base_mono_detection import BaseMonoModel 19 | from .base_multiview_detection import BaseMultiViewModel 20 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/auxiliary/shaders/draw_pose.geom: -------------------------------------------------------------------------------- 1 | #version 330 core 2 | 3 | layout(points) in; 4 | layout(line_strip, max_vertices = 6) out; 5 | 6 | uniform mat4 mvp; 7 | uniform mat4 pose; 8 | uniform float size; 9 | 10 | out vec4 color; 11 | 12 | void main() 13 | { 14 | color = vec4(1, 0, 0, 1); 15 | gl_Position = mvp * pose * vec4(0, 0, 0, 1); 16 | EmitVertex(); 17 | gl_Position = mvp * pose * vec4(size, 0, 0, 1); 18 | EmitVertex(); 19 | EndPrimitive(); 20 | 21 | color = vec4(0, 1, 0, 1); 22 | gl_Position = mvp * pose * vec4(0, 0, 0, 1); 23 | EmitVertex(); 24 | gl_Position = mvp * pose * vec4(0, size, 0, 1); 25 | EmitVertex(); 26 | EndPrimitive(); 27 | 28 | color = vec4(0, 0, 1, 1); 29 | gl_Position = mvp * pose * vec4(0, 0, 0, 1); 30 | EmitVertex(); 31 | gl_Position = mvp * pose * vec4(0, 0, size, 1); 32 | EmitVertex(); 33 | EndPrimitive(); 34 | 35 | } 36 | -------------------------------------------------------------------------------- /paddle3d/apis/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .checkpoint import Checkpoint, CheckpointABC 16 | from .config import Config 17 | from .manager import ComponentManager 18 | from .pipeline import training_step, validation_step, apply_to_static 19 | from .scheduler import Scheduler, SchedulerABC, SchedulerStatus 20 | from .trainer import Trainer 21 | -------------------------------------------------------------------------------- /paddle3d/models/backbones/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .cbnet import * 16 | from .dla import * 17 | from .hrnet import * 18 | from .resnet import * 19 | from .sac import * 20 | from .second_backbone import * 21 | from .vovnet import * 22 | from .vovnetcp import VoVNetCP 23 | from .mm_resnet import MMResNet 24 | from .custom_resnet import CustomResNet 25 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/cameras/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .camera_functionals import (get_distortion_coeffs, 16 | radial_n_tangential_undistort) 17 | from .cameras import Cameras, CameraType 18 | from .math_functionals import Gaussians, conical_frustum_to_gaussian 19 | from .rays import Frustums, RayBundle, RaySamples 20 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/encoders/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .grid_encoder import GridEncoder 16 | from .nerf_encoder import NeRFEncoder 17 | from .ref_nerf_encoder import IntegDirEncoder 18 | from .sh_encoder import SHEncoder 19 | from .neus_encoder import NeuSEncoder 20 | from .tensorf_encoder import TensorVMEncoder, TensorCPEncoder, TriplaneEncoder 21 | -------------------------------------------------------------------------------- /paddle3d/models/heads/dense_heads/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .anchor3d_head import * 16 | from .anchor_head import * 17 | from .petr_head import PETRHead 18 | from .petr_head_seg import PETRHeadseg 19 | from .point_head import PointHeadSimple 20 | from .target_assigner import * 21 | from .cape_dn_head import CAPETemporalDNHead 22 | from .bevdet_centerhead import CenterHeadMatch 23 | -------------------------------------------------------------------------------- /tests/apis/test_scheduler.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import paddle3d 4 | 5 | 6 | class SchedulerTestCase(unittest.TestCase): 7 | """ 8 | """ 9 | 10 | def __init__(self, *args, **kwargs): 11 | super().__init__(*args, **kwargs) 12 | self.scheduler = paddle3d.apis.Scheduler( 13 | save_interval=10, log_interval=5, do_eval=True) 14 | 15 | def test_status(self): 16 | for i in range(1, 21): 17 | status = self.scheduler.step() 18 | if i % 5 == 0: 19 | self.assertEqual(status.do_log, True) 20 | else: 21 | self.assertEqual(status.do_log, False) 22 | 23 | if i % 10 == 0: 24 | self.assertEqual(status.save_checkpoint, True) 25 | self.assertEqual(status.do_eval, True) 26 | else: 27 | self.assertEqual(status.save_checkpoint, False) 28 | self.assertEqual(status.do_eval, False) 29 | 30 | 31 | if __name__ == "__main__": 32 | unittest.main() 33 | -------------------------------------------------------------------------------- /paddle3d/ops/iou3d_nms/iou3d_cpu.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_CPU_H 16 | #define IOU3D_CPU_H 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | std::vector boxes_iou_bev_cpu( 25 | const paddle::Tensor& boxes_a_tensor, const paddle::Tensor& boxes_b_tensor); 26 | 27 | #endif 28 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .encoders import * 16 | from .fields import * 17 | from .instant_ngp import * 18 | from .layers import * 19 | from .mip_nerf import * 20 | from .plenoxels import * 21 | from .nerf import * 22 | from .tensorf import * 23 | from .ray_samplers import * 24 | from .ref_nerf import * 25 | from .renderers import * 26 | from .neus import * 27 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/fields/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .base import BaseDensityField, BaseSDFField 16 | from .instant_ngp_field import InstantNGPField 17 | from .nerf_field import NeRFField, NeRFPPField 18 | from .plenoxels_field import PlenoxelGrid 19 | from .ref_nerf_field import RefNeRFField 20 | from .neus_fields import NeuSField 21 | from .tensorf_field import TensoRFField 22 | -------------------------------------------------------------------------------- /paddle3d/datasets/nuscenes/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .nuscenes_multiview_det import NuscenesMVDataset, NuscenesMVSegDataset 16 | from .nuscenes_multi_modality import NuscenesMMDataset 17 | from .nuscenes_pointcloud_det import NuscenesPCDataset 18 | from .bevdet_custom_3d import Custom3DDataset 19 | from .bevdet_nuscenes_dataset import BEVDetNuScenesDataset 20 | from .dataset_wrapper import CBGSDataset 21 | -------------------------------------------------------------------------------- /deploy/iassd/cpp/custom_ops/iou3d_cpu.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_CPU_H 16 | #define IOU3D_CPU_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "paddle/include/experimental/ext_all.h" 24 | 25 | std::vector boxes_iou_bev_cpu( 26 | const paddle::Tensor& boxes_a_tensor, const paddle::Tensor& boxes_b_tensor); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /deploy/pointpillars/cpp/custom_ops/iou3d_cpu.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_CPU_H 16 | #define IOU3D_CPU_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "paddle/include/experimental/ext_all.h" 24 | 25 | std::vector boxes_iou_bev_cpu( 26 | const paddle::Tensor& boxes_a_tensor, const paddle::Tensor& boxes_b_tensor); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /deploy/pv_rcnn/cpp/custom_ops/iou3d_nms/iou3d_cpu.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_CPU_H 16 | #define IOU3D_CPU_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "paddle/include/experimental/ext_all.h" 24 | 25 | std::vector boxes_iou_bev_cpu( 26 | const paddle::Tensor& boxes_a_tensor, const paddle::Tensor& boxes_b_tensor); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /deploy/voxel_rcnn/cpp/custom_ops/iou3d_nms/iou3d_cpu.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_CPU_H 16 | #define IOU3D_CPU_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "paddle/include/experimental/ext_all.h" 24 | 25 | std::vector boxes_iou_bev_cpu( 26 | const paddle::Tensor& boxes_a_tensor, const paddle::Tensor& boxes_b_tensor); 27 | 28 | #endif 29 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/kitti_object_eval_python/evaluate.py: -------------------------------------------------------------------------------- 1 | import time 2 | import fire 3 | import kitti_common as kitti 4 | from eval import get_official_eval_result, get_coco_eval_result 5 | 6 | 7 | def _read_imageset_file(path): 8 | with open(path, 'r') as f: 9 | lines = f.readlines() 10 | return [int(line) for line in lines] 11 | 12 | 13 | def evaluate(label_path, 14 | result_path, 15 | label_split_file, 16 | current_class=0, 17 | coco=False, 18 | score_thresh=-1): 19 | dt_annos = kitti.get_label_annos(result_path) 20 | if score_thresh > 0: 21 | dt_annos = kitti.filter_annos_low_score(dt_annos, score_thresh) 22 | val_image_ids = _read_imageset_file(label_split_file) 23 | gt_annos = kitti.get_label_annos(label_path, val_image_ids) 24 | if coco: 25 | print(get_coco_eval_result(gt_annos, dt_annos, current_class)) 26 | else: 27 | print(get_official_eval_result(gt_annos, dt_annos, current_class)) 28 | 29 | 30 | if __name__ == '__main__': 31 | fire.Fire() 32 | -------------------------------------------------------------------------------- /paddle3d/datasets/metrics.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import abc 16 | from typing import List 17 | 18 | from paddle3d.sample import Sample 19 | 20 | 21 | class MetricABC(abc.ABC): 22 | @abc.abstractmethod 23 | def update(self, 24 | predictions: List[Sample], 25 | ground_truths: List[Sample] = None): 26 | """ 27 | """ 28 | 29 | @abc.abstractmethod 30 | def compute(self): 31 | """ 32 | """ 33 | -------------------------------------------------------------------------------- /.pre-commit-config.yaml: -------------------------------------------------------------------------------- 1 | repos: 2 | - repo: local 3 | hooks: 4 | - id: yapf 5 | name: yapf 6 | entry: yapf --style .style.yapf -i 7 | language: system 8 | files: \.py$ 9 | 10 | - repo: https://github.com/pre-commit/pre-commit-hooks 11 | rev: a11d9314b22d8f8c7556443875b731ef05965464 12 | hooks: 13 | - id: check-merge-conflict 14 | - id: check-symlinks 15 | - id: end-of-file-fixer 16 | - id: trailing-whitespace 17 | - id: detect-private-key 18 | - id: check-added-large-files 19 | 20 | - repo: local 21 | hooks: 22 | - id: flake8 23 | name: flake8 24 | entry: flake8 --count --select=E9,F63,F7,F82 --show-source --statistics 25 | language: system 26 | files: \.py$ 27 | 28 | - repo: local 29 | hooks: 30 | - id: clang-format-with-version-check 31 | name: clang-format 32 | description: Format files with ClangFormat 33 | entry: bash .clang_format.hook -style=Google -i 34 | language: system 35 | files: \.(c|cc|cxx|cpp|cu|h|hpp|hxx|cuh|proto)$ 36 | -------------------------------------------------------------------------------- /paddle3d/transforms/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from paddle3d.transforms.anchor_generator import * 16 | from paddle3d.transforms.base import * 17 | from paddle3d.transforms.functional import * 18 | from paddle3d.transforms.normalize import * 19 | from paddle3d.transforms.reader import * 20 | from paddle3d.transforms.sampling import * 21 | from paddle3d.transforms.target_generator import * 22 | from paddle3d.transforms.transform import * 23 | from paddle3d.transforms.bevdet_reader import * 24 | -------------------------------------------------------------------------------- /paddle3d/models/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from .backbones import * 15 | from .classification import * 16 | from .common import * 17 | from .detection import * 18 | from .heads import * 19 | from .layers import * 20 | from .losses import * 21 | from .middle_encoders import * 22 | from .necks import * 23 | from .optimizers import * 24 | from .point_encoders import * 25 | from .segmentation import * 26 | from .transformers import * 27 | from .voxel_encoders import * 28 | from .voxelizers import * 29 | -------------------------------------------------------------------------------- /paddle3d/models/detection/bevfusion/mvx_faster_rcnn.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from paddle3d.apis import manager 16 | from paddle3d.models.detection.bevfusion.mvx_two_stage import \ 17 | MVXTwoStageDetector 18 | 19 | __all__ = ['MVXFasterRCNN'] 20 | 21 | 22 | @manager.MODELS.add_component 23 | class MVXFasterRCNN(MVXTwoStageDetector): 24 | """Multi-modality model using Faster R-CNN.""" 25 | 26 | def __init__(self, **kwargs): 27 | super(MVXFasterRCNN, self).__init__(**kwargs) 28 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/kitti_object_eval_python/LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /paddle3d/models/layers/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .layer_norm import * 16 | from .layer_libs import * 17 | from .param_init import * 18 | from .petr_transformer import (PETRDNTransformer, PETRTransformer, 19 | PETRTransformerDecoder, 20 | PETRTransformerDecoderLayer) 21 | from .positional_encoding import SinePositionalEncoding3D 22 | from .pyramid_pool import * 23 | from .normalization import * 24 | from .cape_transformer import CrossAttention, CAPETransformer, CrossViewAttention 25 | -------------------------------------------------------------------------------- /paddle3d/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | __version__ = "1.0.0" 16 | 17 | import paddle 18 | from packaging.version import Version 19 | 20 | paddle_version = Version(paddle.__version__) 21 | minimum_paddle_version = Version("2.4.0") 22 | develop_version = Version("0.0.0") 23 | 24 | if paddle_version < minimum_paddle_version and paddle_version != develop_version: 25 | raise RuntimeError("Please upgrade PaddlePaddle version to {}".format( 26 | minimum_paddle_version)) 27 | 28 | from . import datasets, models, transforms 29 | -------------------------------------------------------------------------------- /paddle3d/models/detection/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from . import bevformer, bevfusion, caddn, centerpoint, iassd, petr, pointpillars, smoke, pv_rcnn, voxel_rcnn 16 | from .bevformer import * 17 | from .bevfusion import * 18 | from .caddn import * 19 | from .centerpoint import * 20 | from .iassd import * 21 | from .petr import * 22 | from .pointpillars import * 23 | from .pv_rcnn import * 24 | from .smoke import * 25 | from .dd3d import * 26 | from .voxel_rcnn import * 27 | from .bevdet import * 28 | from .rtebev import * 29 | from .bev_lanedet import * 30 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License 2 | 3 | Copyright (c) 2019, University of Bonn 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /test_tipc/test_train_inference_python_npu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source test_tipc/common_func.sh 3 | 4 | function readlinkf() { 5 | perl -MCwd -e 'print Cwd::abs_path shift' "$1"; 6 | } 7 | 8 | function func_parser_config() { 9 | strs=$1 10 | IFS=" " 11 | array=(${strs}) 12 | tmp=${array[2]} 13 | echo ${tmp} 14 | } 15 | 16 | BASEDIR=$(dirname "$0") 17 | REPO_ROOT_PATH=$(readlinkf ${BASEDIR}/../) 18 | 19 | FILENAME=$1 20 | 21 | # change gpu to npu in tipc txt configs 22 | sed -i "s/state=GPU/state=NPU/g" $FILENAME 23 | sed -i "s/--device:gpu/--device:npu/g" $FILENAME 24 | sed -i "s/--benchmark:True/--benchmark:False/g" $FILENAME 25 | dataline=`cat $FILENAME` 26 | 27 | # change gpu to npu in execution script 28 | sed -i 's/\"gpu\"/\"npu\"/g' test_tipc/test_train_inference_python.sh 29 | sed -i 's/--gpus/--npus/g' test_tipc/test_train_inference_python.sh 30 | 31 | # python has been updated to version 3.9 for npu backend 32 | sed -i "s/python3.7/python3.9/g" $FILENAME 33 | 34 | # parser params 35 | IFS=$'\n' 36 | lines=(${dataline}) 37 | 38 | # pass parameters to test_train_inference_python.sh 39 | cmd="bash test_tipc/test_train_inference_python.sh ${FILENAME} $2" 40 | echo $cmd 41 | eval $cmd 42 | -------------------------------------------------------------------------------- /test_tipc/test_train_inference_python_xpu.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | source test_tipc/common_func.sh 3 | 4 | function readlinkf() { 5 | perl -MCwd -e 'print Cwd::abs_path shift' "$1"; 6 | } 7 | 8 | function func_parser_config() { 9 | strs=$1 10 | IFS=" " 11 | array=(${strs}) 12 | tmp=${array[2]} 13 | echo ${tmp} 14 | } 15 | 16 | BASEDIR=$(dirname "$0") 17 | REPO_ROOT_PATH=$(readlinkf ${BASEDIR}/../) 18 | 19 | FILENAME=$1 20 | 21 | # change gpu to npu in tipc txt configs 22 | sed -i "s/state=GPU/state=XPU/g" $FILENAME 23 | sed -i "s/--device:gpu/--device:xpu/g" $FILENAME 24 | sed -i "s/--benchmark:True/--benchmark:False/g" $FILENAME 25 | dataline=`cat $FILENAME` 26 | 27 | # change gpu to npu in execution script 28 | sed -i 's/\"gpu\"/\"xpu\"/g' test_tipc/test_train_inference_python.sh 29 | sed -i 's/--gpus/--xpus/g' test_tipc/test_train_inference_python.sh 30 | 31 | # python has been updated to version 3.9 for xpu backend 32 | sed -i "s/python3.7/python3.9/g" $FILENAME 33 | 34 | # parser params 35 | IFS=$'\n' 36 | lines=(${dataline}) 37 | 38 | # pass parameters to test_train_inference_python.sh 39 | cmd="bash test_tipc/test_train_inference_python.sh ${FILENAME} $2" 40 | echo $cmd 41 | eval $cmd 42 | -------------------------------------------------------------------------------- /deploy/smoke/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set +x 3 | set -e 4 | 5 | work_path=$(dirname $(readlink -f $0)) 6 | 7 | # 1. check paddle_inference exists 8 | if [ ! -d "${work_path}/lib/paddle_inference" ]; then 9 | echo "Please download paddle_inference lib and move it in ${work_path}/lib" 10 | exit 1 11 | fi 12 | 13 | # 2. check CMakeLists exists 14 | if [ ! -f "${work_path}/CMakeLists.txt" ]; then 15 | cp -a "${work_path}/lib/CMakeLists.txt" "${work_path}/" 16 | fi 17 | 18 | # 3. compile 19 | mkdir -p build 20 | cd build 21 | rm -rf * 22 | 23 | DEMO_NAME=infer 24 | 25 | WITH_MKL=ON 26 | WITH_GPU=ON 27 | USE_TENSORRT=OFF 28 | 29 | LIB_DIR=${work_path}/lib/paddle_inference 30 | CUDNN_LIB=/usr/lib/x86_64-linux-gnu/ 31 | CUDA_LIB=/usr/local/cuda/lib64 32 | TENSORRT_ROOT=/usr/local/TensorRT-6.0.1.5 33 | 34 | WITH_ROCM=OFF 35 | ROCM_LIB=/opt/rocm/lib 36 | 37 | cmake .. -DPADDLE_LIB=${LIB_DIR} \ 38 | -DWITH_MKL=${WITH_MKL} \ 39 | -DDEMO_NAME=${DEMO_NAME} \ 40 | -DWITH_GPU=${WITH_GPU} \ 41 | -DWITH_STATIC_LIB=OFF \ 42 | -DUSE_TENSORRT=${USE_TENSORRT} \ 43 | -DWITH_ROCM=${WITH_ROCM} \ 44 | -DROCM_LIB=${ROCM_LIB} \ 45 | -DCUDNN_LIB=${CUDNN_LIB} \ 46 | -DCUDA_LIB=${CUDA_LIB} \ 47 | -DTENSORRT_ROOT=${TENSORRT_ROOT} 48 | 49 | make -j 50 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/cpp_extensions/trunc_exp/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import paddle 16 | from paddle.utils.cpp_extension import CppExtension, CUDAExtension, setup 17 | 18 | if paddle.device.is_compiled_with_cuda(): 19 | setup( 20 | name='trunc_exp', 21 | version='1.0.0', 22 | ext_modules=CUDAExtension( 23 | sources=['src/trunc_exp.cc', 'src/trunc_exp.cu']), 24 | extra_compile_args={'cxx': ['-DPADDLE_WITH_CUDA']}) 25 | else: 26 | setup( 27 | name='trunc_exp', 28 | version='1.0.0', 29 | ext_modules=CppExtension(sources=['src/trunc_exp.cc'])) 30 | -------------------------------------------------------------------------------- /paddle3d/geometries/structure.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from json import JSONEncoder 16 | 17 | import numpy as np 18 | 19 | 20 | class StructureEncoder(JSONEncoder): 21 | def default(self, obj): 22 | if isinstance(obj, _Structure): 23 | return obj.tolist() 24 | return super().default(obj) 25 | 26 | 27 | class _Structure(np.ndarray): 28 | """ 29 | """ 30 | 31 | def __new__(cls, data: np.ndarray, *args, **kwargs): 32 | if not isinstance(data, np.ndarray): 33 | data = np.array(data) 34 | 35 | data = data.astype(np.float32) 36 | 37 | obj = np.asarray(data).view(cls) 38 | return obj 39 | -------------------------------------------------------------------------------- /deploy/caddn/cpp/custom_ops/iou3d_nms_api.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include 5 | 6 | #include "iou3d_cpu.h" 7 | #include "iou3d_nms.h" 8 | #include "paddle/include/experimental/ext_all.h" 9 | 10 | std::vector> NMSInferShape( 11 | std::vector boxes_shape) { 12 | int64_t keep_num = 1; 13 | return {{boxes_shape[0]}, {keep_num}}; 14 | } 15 | 16 | std::vector NMSInferDtype(paddle::DataType boxes_dtype) { 17 | return {paddle::DataType::INT64, paddle::DataType::INT64}; 18 | } 19 | 20 | // PYBIND11_MODULE(TORCH_EXTENSION_NAME, m) { 21 | // m.def("boxes_overlap_bev_gpu", &boxes_overlap_bev_gpu, "oriented boxes 22 | // overlap"); 23 | // m.def("boxes_iou_bev_gpu", &boxes_iou_bev_gpu, "oriented boxes iou"); 24 | // m.def("nms_gpu", &nms_gpu, "oriented nms gpu"); 25 | // m.def("nms_normal_gpu", &nms_normal_gpu, "nms gpu"); 26 | // m.def("boxes_iou_bev_cpu", &boxes_iou_bev_cpu, "oriented boxes iou"); 27 | // } 28 | 29 | PD_BUILD_OP(nms_gpu) 30 | .Inputs({"boxes"}) 31 | .Outputs({"keep", "num_to_keep"}) 32 | .Attrs({"nms_overlap_thresh: float"}) 33 | .SetKernelFn(PD_KERNEL(nms_gpu)) 34 | .SetInferDtypeFn(PD_INFER_DTYPE(NMSInferDtype)) 35 | .SetInferShapeFn(PD_INFER_SHAPE(NMSInferShape)); 36 | -------------------------------------------------------------------------------- /docs/apis/config.md: -------------------------------------------------------------------------------- 1 | # paddle3d.apis.Config 2 | 3 | 配置类方法,用于解析配置文件(yaml格式),提取文件中指定的组件并实例化成对应的Paddle3D对象 4 | 5 | ## \_\_init\_\_ 6 | 7 | * **参数** 8 | 9 | * path: 配置文件路径 10 | 11 | * learning_rate: 更新的学习率参数,可以不指定 12 | 13 | * batch_size: 更新的batch_size,可以不指定 14 | 15 | * iters: 更新的训练步数,可以不指定 16 | 17 | * epochs: 更新的训练轮次,可以不指定 18 | 19 | *注意:使用一个 batch 数据对模型进行一次参数更新的过程称之为一步,iters 即为训练过程中的训练步数。完整遍历一次数据对模型进行训练的过程称之为一次迭代,epochs 即为训练过程中的训练迭代次数。一个epoch包含多个iter。* 20 | 21 | * **异常值** 22 | 23 | * ValueError: 未指定配置文件路径时抛出该异常 24 | 25 | * FileNotFoundError: 指定文件不存在时抛出该异常 26 | 27 | * RuntimeError: 指定文件不是 yaml 格式时抛出该异常 28 | 29 | ## update 30 | 31 | 更新配置类的特定超参 32 | 33 | * **参数** 34 | 35 | * learning_rate: 更新的学习率参数,可以不指定 36 | 37 | * batch_size: 更新的batch_size,可以不指定 38 | 39 | * iters: 更新的训练步数,可以不指定 40 | 41 | * epochs: 更新的训练轮次,可以不指定 42 | 43 | ## to_dict 44 | 45 | 将配置类中的组件信息转成字典形式并返回 46 | 47 | ## batch_size 48 | 49 | 单卡batch_size大小 50 | 51 | ## iters 52 | 53 | 训练步数,与epochs互斥,当指定iters时,epochs不生效 54 | 55 | ## epochs 56 | 57 | 训练轮次 58 | 59 | ## lr_scheduler 60 | 61 | 调度器对象 62 | 63 | ## optimizer 64 | 65 | 优化器对象 66 | 67 | ## model 68 | 69 | 模型对象 70 | 71 | ## train_dataset 72 | 73 | 训练数据集 74 | 75 | ## val_dataset 76 | 77 | 评估数据集 78 | -------------------------------------------------------------------------------- /paddle3d/models/losses/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .focal_loss import (FastFocalLoss, FocalLoss, MultiFocalLoss, 16 | SigmoidFocalClassificationLoss, sigmoid_focal_loss, 17 | WeightedFocalLoss, GaussianFocalLoss) 18 | from .reg_loss import RegLoss, L1Loss 19 | from .iou_loss import IOULoss, GIoULoss 20 | from .smooth_l1_loss import smooth_l1_loss, SmoothL1Loss 21 | from .disentangled_box3d_loss import DisentangledBox3DLoss, unproject_points2d 22 | from .weight_loss import (WeightedCrossEntropyLoss, WeightedSmoothL1Loss, 23 | get_corner_loss_lidar) 24 | from .sigmoid_ce_loss import SigmoidCeLoss 25 | from .cross_entropy_loss import CrossEntropyLoss 26 | -------------------------------------------------------------------------------- /paddle3d/datasets/nuscenes/nuscenes_manager.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from nuscenes import NuScenes 16 | 17 | from paddle3d.utils.logger import logger 18 | 19 | 20 | class NuScenesManager: 21 | _instance_map = {} 22 | 23 | @classmethod 24 | def get(cls, version: str, dataroot: str) -> NuScenes: 25 | key = "{}+{}".format(version, dataroot) 26 | 27 | if key not in cls._instance_map: 28 | with logger.processing( 29 | 'Loading nuscenes metadata, this may take a few minutes'): 30 | nusc = NuScenes( 31 | version=version, dataroot=dataroot, verbose=False) 32 | cls._instance_map[key] = nusc 33 | return cls._instance_map[key] 34 | -------------------------------------------------------------------------------- /paddle3d/utils/common.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import contextlib 16 | import tempfile 17 | 18 | from paddle3d.env import TMP_HOME 19 | 20 | 21 | @contextlib.contextmanager 22 | def generate_tempfile(directory: str = None, **kwargs): 23 | '''Generate a temporary file''' 24 | directory = TMP_HOME if not directory else directory 25 | with tempfile.NamedTemporaryFile(dir=directory, **kwargs) as file: 26 | yield file 27 | 28 | 29 | @contextlib.contextmanager 30 | def generate_tempdir(directory: str = None, **kwargs): 31 | '''Generate a temporary directory''' 32 | directory = TMP_HOME if not directory else directory 33 | with tempfile.TemporaryDirectory(dir=directory, **kwargs) as _dir: 34 | yield _dir 35 | -------------------------------------------------------------------------------- /paddle3d/models/base/base_detection.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from paddle3d.models.base import Base3DModel 16 | 17 | from typing import List 18 | 19 | 20 | class BaseDetectionModel(Base3DModel): 21 | def __init__(self, box_with_velocity: bool = False): 22 | super().__init__() 23 | self.box_with_velocity = box_with_velocity 24 | 25 | @property 26 | def outputs(self) -> List[dict]: 27 | """Model output description.""" 28 | 29 | boxdim = 7 if not self.box_with_velocity else 9 30 | box3ds = {'name': 'box3d', 'dtype': 'float32', 'shape': [-1, boxdim]} 31 | labels = {'name': 'label', 'dtype': 'int32', 'shape': [-1]} 32 | confidences = {'name': 'confidence', 'dtype': 'float32', 'shape': [-1]} 33 | return [box3ds, labels, confidences] 34 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/data/transforms/base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import abc 16 | from typing import Dict, List 17 | 18 | __all__ = ["TransformABC", "Compose"] 19 | 20 | 21 | class TransformABC(abc.ABC): 22 | @abc.abstractmethod 23 | def __call__(self, sample: Dict) -> Dict: 24 | """ 25 | """ 26 | 27 | 28 | class Compose(TransformABC): 29 | """ 30 | """ 31 | 32 | def __init__(self, transforms: List): 33 | if not isinstance(transforms, list): 34 | raise TypeError('The transforms must be a list!') 35 | self.transforms = transforms 36 | 37 | def __call__(self, sample: Dict) -> Dict: 38 | """ 39 | """ 40 | for t in self.transforms: 41 | sample = t(sample) 42 | 43 | return sample 44 | -------------------------------------------------------------------------------- /paddle3d/ops/iou3d_nms/iou3d_nms.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_NMS_H 16 | #define IOU3D_NMS_H 17 | 18 | #include 19 | #include 20 | #include 21 | 22 | #include 23 | 24 | std::vector boxes_overlap_bev_gpu( 25 | const paddle::Tensor &boxes_a, const paddle::Tensor &boxes_b); 26 | std::vector boxes_iou_bev_gpu( 27 | const paddle::Tensor &boxes_a_tensor, const paddle::Tensor &boxes_b_tensor); 28 | std::vector nms_gpu(const paddle::Tensor &boxes, 29 | float nms_overlap_thresh); 30 | std::vector nms_normal_gpu(const paddle::Tensor &boxes, 31 | float nms_overlap_thresh); 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /deploy/iassd/cpp/custom_ops/iou3d_nms.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_NMS_H 16 | #define IOU3D_NMS_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "paddle/include/experimental/ext_all.h" 24 | 25 | std::vector boxes_overlap_bev_gpu( 26 | const paddle::Tensor &boxes_a, const paddle::Tensor &boxes_b); 27 | std::vector boxes_iou_bev_gpu( 28 | const paddle::Tensor &boxes_a_tensor, const paddle::Tensor &boxes_b_tensor); 29 | std::vector nms_gpu(const paddle::Tensor &boxes, 30 | float nms_overlap_thresh); 31 | std::vector nms_normal_gpu(const paddle::Tensor &boxes, 32 | float nms_overlap_thresh); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /docs/apis/trainer.md: -------------------------------------------------------------------------------- 1 | # paddle3d.apis.Trainer 2 | 3 | 训练器对象,支持在指定的数据集上训练和评估模型 4 | 5 | ## \_\_init\_\_ 6 | 7 | * **参数** 8 | 9 | * model: 待训练或者评估的模型 10 | 11 | * iters: 更新的训练步数,可以不指定,与epochs互斥,当指定iters时,epochs不生效 12 | 13 | * epochs: 更新的训练轮次,可以不指定 14 | 15 | * optimizer: 训练所用的优化器 16 | 17 | * train_dataset: 训练数据集 18 | 19 | * val_dataset: 评估数据集,可以不指定 20 | 21 | * resume: 是否从检查点中恢复到上一次训练状态 22 | 23 | * checkpoint: 检查点参数,用于保存训练过程中的模型参数和训练状态,该参数可以是: 24 | 25 | * `dict` 类型,指定构建默认 [Checkpoint](./checkpoint.md) 类对象的参数。 26 | 27 | * 继承了 [paddle3d.apis.CheckpointABC](./checkpoint.md) 的类对象 28 | 29 | * scheduler: 调度器参数,用于决定训练过程中的调度行为,该参数可以是: 30 | 31 | * `dict` 类型,指定构建默认 [Scheduler](./scheduler.md) 类对象的参数。 32 | 33 | * 继承了 [paddle3d.apis.SchedulerABC](./scheduler.md) 的类对象 34 | 35 | * dataloader_fn: 数据加载器参数,用于构建数据加载器,该参数可以是: 36 | 37 | * `dict` 类型,指定构建默认 Dataloader 类对象的参数,如 `batch_size` / `drop_last` / `shuffle` 。 38 | 39 | * 继承了 `paddle3d.apis.CheckpointABC` 的类对象 40 | 41 | *注意:使用一个 batch 数据对模型进行一次参数更新的过程称之为一步,iters 即为训练过程中的训练步数。完整遍历一次数据对模型进行训练的过程称之为一次迭代,epochs 即为训练过程中的训练迭代次数。一个epoch包含多个iter。* 42 | 43 | * **异常值** 44 | 45 | * RuntimeError: 当指定的Checkpoint存在数据且未设置 `resume` 时,此时数据存在被覆写的隐患,因此将抛出该异常 46 | 47 | ## train 48 | 49 | 执行训练流程的接口 50 | 51 | ## evaluate 52 | 53 | 执行评估流程的接口 54 | 55 | * **异常值** 56 | 57 | * RuntimeError: 初始化时如果未指定评估数据集,则抛出该异常 58 | -------------------------------------------------------------------------------- /paddle3d/slim/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import codecs 16 | import yaml 17 | 18 | 19 | def get_qat_config(qat_config_path: str) -> dict: 20 | with codecs.open(qat_config_path, 'r', 'utf-8') as f: 21 | slim_dic = yaml.load(f, Loader=yaml.FullLoader) 22 | 23 | slim_type = slim_dic['slim_type'] 24 | if slim_type != "QAT": 25 | raise ValueError("slim method `{}` is not supported yet") 26 | 27 | return slim_dic 28 | 29 | 30 | def update_dic(dic, another_dic): 31 | """Recursive update dic by another_dic 32 | """ 33 | for k, _ in another_dic.items(): 34 | if (k in dic and isinstance(dic[k], dict)) and isinstance( 35 | another_dic[k], dict): 36 | update_dic(dic[k], another_dic[k]) 37 | else: 38 | dic[k] = another_dic[k] 39 | return dic 40 | -------------------------------------------------------------------------------- /deploy/pointpillars/cpp/custom_ops/iou3d_nms.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_NMS_H 16 | #define IOU3D_NMS_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "paddle/include/experimental/ext_all.h" 24 | 25 | std::vector boxes_overlap_bev_gpu( 26 | const paddle::Tensor &boxes_a, const paddle::Tensor &boxes_b); 27 | std::vector boxes_iou_bev_gpu( 28 | const paddle::Tensor &boxes_a_tensor, const paddle::Tensor &boxes_b_tensor); 29 | std::vector nms_gpu(const paddle::Tensor &boxes, 30 | float nms_overlap_thresh); 31 | std::vector nms_normal_gpu(const paddle::Tensor &boxes, 32 | float nms_overlap_thresh); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /deploy/pv_rcnn/cpp/custom_ops/iou3d_nms/iou3d_nms.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_NMS_H 16 | #define IOU3D_NMS_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "paddle/include/experimental/ext_all.h" 24 | 25 | std::vector boxes_overlap_bev_gpu( 26 | const paddle::Tensor &boxes_a, const paddle::Tensor &boxes_b); 27 | std::vector boxes_iou_bev_gpu( 28 | const paddle::Tensor &boxes_a_tensor, const paddle::Tensor &boxes_b_tensor); 29 | std::vector nms_gpu(const paddle::Tensor &boxes, 30 | float nms_overlap_thresh); 31 | std::vector nms_normal_gpu(const paddle::Tensor &boxes, 32 | float nms_overlap_thresh); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /deploy/rtebev/python/plugin_ops/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.12) 2 | 3 | project(tensorrt_ops LANGUAGES CXX CUDA) 4 | find_package(CUDA REQUIRED) 5 | 6 | execute_process(COMMAND nvcc -lcuda ${CMAKE_CURRENT_SOURCE_DIR}/cudaComputeVersion.cu -o /tmp/cudaComputeVersion) 7 | execute_process(COMMAND /tmp/cudaComputeVersion 8 | RESULT_VARIABLE CUDA_RETURN_CODE 9 | OUTPUT_VARIABLE ARCH) 10 | execute_process(COMMAND rm /tmp/cudaComputeVersion) 11 | 12 | if(NOT CMAKE_TENSORRT_PATH) 13 | message( "Need: -DCMAKE_TENSORRT_PATH=/path/to/TensorRT") 14 | 15 | endif() 16 | 17 | include_directories(common) 18 | include_directories(/usr/local/cuda/include) 19 | include_directories(/usr/local/include) 20 | 21 | message(STATUS "Linking TensorRT directory: ${CMAKE_TENSORRT_PATH}") 22 | link_directories(${CMAKE_TENSORRT_PATH}/lib) 23 | include_directories(${CMAKE_TENSORRT_PATH}/include) 24 | 25 | file(GLOB_RECURSE TENSORRT_OPS_SRCS common/*.cpp common/*.cu plugin/*/*.cu plugin/*/*.cpp) 26 | 27 | set(SHARED_TARGET tensorrt_ops) 28 | add_library(${SHARED_TARGET} SHARED ${TENSORRT_OPS_SRCS}) 29 | target_compile_options(${SHARED_TARGET} PRIVATE $<$:-arch=sm_${ARCH}>) 30 | 31 | target_link_libraries(${SHARED_TARGET} PUBLIC cudnn nvinfer cublas) 32 | set_target_properties(${SHARED_TARGET} PROPERTIES CUDA_ARCHITECTURES "${ARCH}") 33 | 34 | install( 35 | TARGETS ${SHARED_TARGET} 36 | LIBRARY DESTINATION ${CMAKE_SOURCE_DIR}/lib 37 | ) 38 | -------------------------------------------------------------------------------- /deploy/voxel_rcnn/cpp/custom_ops/iou3d_nms/iou3d_nms.h: -------------------------------------------------------------------------------- 1 | // Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef IOU3D_NMS_H 16 | #define IOU3D_NMS_H 17 | 18 | #include 19 | #include 20 | 21 | #include 22 | 23 | #include "paddle/include/experimental/ext_all.h" 24 | 25 | std::vector boxes_overlap_bev_gpu( 26 | const paddle::Tensor &boxes_a, const paddle::Tensor &boxes_b); 27 | std::vector boxes_iou_bev_gpu( 28 | const paddle::Tensor &boxes_a_tensor, const paddle::Tensor &boxes_b_tensor); 29 | std::vector nms_gpu(const paddle::Tensor &boxes, 30 | float nms_overlap_thresh); 31 | std::vector nms_normal_gpu(const paddle::Tensor &boxes, 32 | float nms_overlap_thresh); 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /paddle3d/datasets/__init__.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from .base import BaseDataset 16 | from .kitti import KittiDepthDataset, KittiMonoDataset, KittiPCDataset 17 | from .modelnet40 import ModelNet40 18 | from .nuscenes import NuscenesMVDataset, NuscenesPCDataset, NuscenesMVSegDataset 19 | from .waymo import WaymoPCDataset 20 | from .apollo import ApolloOffsetDataset, ApolloOffsetValDataset 21 | from paddle3d.apis import manager 22 | 23 | # for PaddleX 24 | NuscenesPCDetDataset = NuscenesPCDataset 25 | KittiDepthMonoDetDataset = KittiDepthDataset 26 | NuscenesMVDetDataset = NuscenesMVDataset 27 | manager.DATASETS._components_dict['NuscenesPCDetDataset'] = NuscenesPCDetDataset 28 | manager.DATASETS._components_dict[ 29 | 'KittiDepthMonoDetDataset'] = KittiDepthMonoDetDataset 30 | manager.DATASETS._components_dict['NuscenesMVDetDataset'] = NuscenesMVDetDataset 31 | -------------------------------------------------------------------------------- /docs/apis/checkpoint.md: -------------------------------------------------------------------------------- 1 | # paddle3d.apis.CheckpointABC 2 | 3 | 检查点抽象基类,定义检查点应该实现的方法 4 | 5 | ## have 6 | 7 | 检查点中是否保存了指定tag的信息 8 | 9 | * **参数** 10 | 11 | * tag: 数据tag 12 | 13 | ## get 14 | 15 | 获取检查点中的指定信息 16 | 17 | * **参数** 18 | 19 | * tag: 数据tag 20 | 21 | ## push 22 | 23 | 保存一组模型参数和优化器参数到检查点中 24 | 25 | * **参数** 26 | 27 | * params_dict: 待保存的模型参数 28 | 29 | * opt_dict: 待保存的优化器参数 30 | 31 | * kwargs: 其余参数,和各个继承类实现有关 32 | 33 | ## pop 34 | 35 | 删除检查点队列中最先保存的数据 36 | 37 | * **参数** 38 | 39 | * kwargs: 其余参数,和各个继承类实现有关 40 | 41 | ## empty 42 | 43 | 检查点是否为空 44 | 45 | ## record 46 | 47 | 记录一组训练信息到检查点中 48 | 49 | * **参数** 50 | 51 | * key: 训练信息标签 52 | 53 | * value: 训练信息内容 54 | 55 | ## meta 56 | 57 | 检查点的元数据 58 | 59 | ## metafile 60 | 61 | 检查点保存元数据的文件路径 62 | 63 | ## rootdir 64 | 65 | 检查点的根路径 66 | 67 |
68 | 69 | # paddle3d.apis.Checkpoint 70 | 71 | 检查点类方法,支持保存模型和优化器参数,以及训练过程中的状态信息,继承自抽象基类CheckpointABC 72 | 73 | ## push 74 | 75 | 保存一组模型参数和优化器参数到检查点中 76 | 77 | * **参数** 78 | 79 | * params_dict: 待保存的模型参数 80 | 81 | * opt_dict: 待保存的优化器参数 82 | 83 | * tag: 参数的标签,可以不填写 84 | 85 | * enqueue: 保存的参数是否放入队列中,队列中的参数在超过限制时会被自动删除,默认为True 86 | 87 | * verbose: 是否打印详细日志 88 | 89 | ## pop 90 | 91 | 删除检查点队列中最先保存的数据 92 | 93 | * **参数** 94 | 95 | * verbose: 是否打印详细日志 96 | 97 | ## rwlock 98 | 99 | 读写锁,用于保护多进程场景下不会读写检查点不会造成数据冲突 100 | -------------------------------------------------------------------------------- /deploy/pointpillars/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | mkdir -p build 16 | cd build 17 | rm -rf * 18 | 19 | DEMO_NAME=main 20 | 21 | WITH_MKL=ON 22 | WITH_GPU=ON 23 | USE_TENSORRT=ON 24 | 25 | LIB_DIR=/home/dependency/paddle_inference_install_dir 26 | CUDNN_LIB=/usr/lib/x86_64-linux-gnu 27 | CUDA_LIB=/usr/local/cuda/lib64 28 | TENSORRT_ROOT=/home/dependency/TensorRT-8.2.5.1 29 | CUSTOM_OPERATOR_FILES="custom_ops/iou3d_cpu.cpp;custom_ops/iou3d_nms_api.cpp;custom_ops/iou3d_nms.cpp;custom_ops/iou3d_nms_kernel.cu" 30 | 31 | cmake .. -DPADDLE_LIB=${LIB_DIR} \ 32 | -DWITH_MKL=${WITH_MKL} \ 33 | -DDEMO_NAME=${DEMO_NAME} \ 34 | -DWITH_GPU=${WITH_GPU} \ 35 | -DWITH_STATIC_LIB=OFF \ 36 | -DUSE_TENSORRT=${USE_TENSORRT} \ 37 | -DCUDNN_LIB=${CUDNN_LIB} \ 38 | -DCUDA_LIB=${CUDA_LIB} \ 39 | -DTENSORRT_ROOT=${TENSORRT_ROOT} \ 40 | -DCUSTOM_OPERATOR_FILES=${CUSTOM_OPERATOR_FILES} 41 | 42 | make -j 43 | -------------------------------------------------------------------------------- /paddle3d/slim/quant.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from paddle3d.utils.logger import logger 16 | 17 | 18 | class QAT: 19 | def __init__(self, quant_config, verbose: bool = False): 20 | self.quant_config = quant_config 21 | self.verbose = verbose 22 | 23 | def __call__(self, model): 24 | if self.verbose: 25 | logger.info("model before quant") 26 | logger.info(model) 27 | 28 | # lazy import 29 | import paddleslim 30 | self.quanter = paddleslim.QAT(config=self.quant_config) 31 | self.quanter.quantize(model) 32 | 33 | if self.verbose: 34 | logger.info("model after quant") 35 | logger.info(model) 36 | 37 | return model 38 | 39 | def save_quantized_model(self, model, path, input_spec, **kwargs): 40 | self.quanter.save_quantized_model( 41 | model=model, path=path, input_spec=input_spec, **kwargs) 42 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/data/transforms/normal_transforms.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import os.path as osp 16 | from typing import Dict 17 | 18 | import numpy as np 19 | from PIL import Image 20 | 21 | from pprndr.apis import manager 22 | from pprndr.data.transforms.base import TransformABC 23 | from pprndr.utils.logger import logger 24 | 25 | __all__ = ["LoadNormal"] 26 | 27 | 28 | @manager.TRANSFORMS.add_component 29 | class LoadNormal(TransformABC): 30 | """ 31 | Load normal from file path, default backend is pillow. 32 | """ 33 | 34 | @staticmethod 35 | def pillow_reader(normal_path): 36 | return np.asarray( 37 | Image.open(normal_path), dtype=np.uint8).astype( 38 | np.float32, copy=False) 39 | 40 | def __call__(self, sample: Dict) -> Dict: 41 | """ 42 | """ 43 | sample["normal"] = LoadNormal.pillow_reader(sample["normal"]) 44 | 45 | return sample 46 | -------------------------------------------------------------------------------- /configs/bev_lanedet/bev_lanedet_apollo_576x1024.yml: -------------------------------------------------------------------------------- 1 | batch_size: 4 2 | epochs: 50 3 | 4 | train_dataset: 5 | type: ApolloOffsetDataset 6 | data_json_path: data/apollo/data_splits/standard/train.json 7 | dataset_base_dir: data/apollo/Apollo_Sim_3D_Lane_Release 8 | x_range: [3, 103] 9 | y_range: [-12, 12] 10 | meter_per_pixel: 0.5 11 | input_shape: [576, 1024] 12 | output_2d_shape: [144, 256] 13 | virtual_camera_config: 14 | use_virtual_camera: True 15 | vc_intrinsic: camera_K_virtual 16 | vc_image_shape: [1920, 1080] 17 | 18 | val_dataset: 19 | type: ApolloOffsetValDataset 20 | data_json_path: data/apollo/data_splits/standard/test.json 21 | dataset_base_dir: data/apollo/Apollo_Sim_3D_Lane_Release 22 | x_range: [3, 103] 23 | meter_per_pixel: 0.5 24 | virtual_camera_config: 25 | use_virtual_camera: True 26 | vc_intrinsic: camera_K_virtual 27 | vc_image_shape: [1920, 1080] 28 | 29 | transforms: 30 | - type: Resize 31 | size: [576, 1024] 32 | - type: Transpose 33 | - type: NormalizeVision 34 | mean: [123.675, 116.28, 103.53] 35 | std: [58.395, 57.12, 57.375] 36 | 37 | optimizer: 38 | type: AdamW 39 | weight_decay: 0.01 40 | 41 | 42 | lr_scheduler: 43 | type: LinearWarmup 44 | learning_rate: 45 | type: CosineAnnealingDecay 46 | learning_rate: 0.001 47 | T_max: 37450 # 749.0 * 50 48 | eta_min: 0.0000002 49 | warmup_steps: 200 50 | start_lr: 0.00006666666 51 | end_lr: 0.001 52 | 53 | 54 | model: 55 | type: BEVLaneDet 56 | bev_shape: [200, 48] 57 | output_2d_shape: [144, 256] 58 | train: True 59 | -------------------------------------------------------------------------------- /deploy/centerpoint/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | mkdir -p build 16 | cd build 17 | rm -rf * 18 | 19 | DEMO_NAME=main 20 | 21 | WITH_MKL=ON 22 | WITH_GPU=ON 23 | USE_TENSORRT=ON 24 | 25 | LIB_DIR=/centerpoint/two_three/Paddle/build_apollo/paddle_inference_install_dir/ 26 | CUDNN_LIB=/usr/lib/x86_64-linux-gnu 27 | CUDA_LIB=/usr/local/cuda/lib64 28 | TENSORRT_ROOT=/centerpoint/two_three/Paddle/TensorRT-8.2.5.1 29 | CUSTOM_OPERATOR_FILES="custom_ops/voxelize_op.cu;custom_ops/voxelize_op.cc;custom_ops/iou3d_nms_kernel.cu;custom_ops/postprocess.cc;custom_ops/postprocess.cu" 30 | 31 | 32 | cmake .. -DPADDLE_LIB=${LIB_DIR} \ 33 | -DWITH_MKL=${WITH_MKL} \ 34 | -DDEMO_NAME=${DEMO_NAME} \ 35 | -DWITH_GPU=${WITH_GPU} \ 36 | -DWITH_STATIC_LIB=OFF \ 37 | -DUSE_TENSORRT=${USE_TENSORRT} \ 38 | -DCUDNN_LIB=${CUDNN_LIB} \ 39 | -DCUDA_LIB=${CUDA_LIB} \ 40 | -DTENSORRT_ROOT=${TENSORRT_ROOT} \ 41 | -DCUSTOM_OPERATOR_FILES=${CUSTOM_OPERATOR_FILES} 42 | 43 | make -j 44 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/cpp_extensions/ray_marching/setup.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import os 16 | 17 | from paddle.utils.cpp_extension import BuildExtension, CUDAExtension, setup 18 | 19 | nvcc_flags = ['-O3', '-std=c++14'] 20 | 21 | if os.name == "posix": 22 | c_flags = ['-O3', '-std=c++14'] 23 | else: 24 | raise NotImplemented("Only support Linux") 25 | 26 | c_flags += ['-DPADDLE_WITH_CUDA'] 27 | 28 | setup( 29 | name='ray_marching_lib', 30 | version='1.0.0', 31 | ext_modules=[ 32 | CUDAExtension( 33 | sources=[ 34 | 'src/ray_marching.cc', 'src/ray_marching.cu', 35 | 'src/rendering.cc', 'src/rendering.cu' 36 | ], 37 | extra_compile_args={ 38 | 'cxx': c_flags, 39 | 'nvcc': nvcc_flags 40 | }, 41 | include_dirs=['dependencies/cuda-samples/Common']), 42 | ], 43 | cmdclass={'build_ext': BuildExtension}) 44 | -------------------------------------------------------------------------------- /deploy/petr/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | mkdir -p build 16 | cd build 17 | rm -rf * 18 | 19 | DEMO_NAME=main 20 | 21 | WITH_MKL=ON 22 | WITH_GPU=ON 23 | USE_TENSORRT=ON 24 | 25 | # paddle inference dir 26 | LIB_DIR=/workspace/codes/Paddle3D02/paddle_inference 27 | 28 | OPENCV_DIR=/workspace/codes/opencv/build/ 29 | # OPENCV_DIR=/ssd1/wangna11/caddn_test/opencv-3.4.7/build/ 30 | 31 | CUDNN_LIB=/usr/local/x86_64-pc-linux-gnu/ 32 | CUDA_LIB=/usr/local/cuda/lib64 33 | TENSORRT_ROOT=/workspace/trt/TensorRT-8.2.3.0 34 | CUSTOM_OPERATOR_FILES="" 35 | 36 | 37 | cmake .. -DPADDLE_LIB=${LIB_DIR} \ 38 | -DOPENCV_DIR=${OPENCV_DIR} \ 39 | -DWITH_MKL=${WITH_MKL} \ 40 | -DDEMO_NAME=${DEMO_NAME} \ 41 | -DWITH_GPU=${WITH_GPU} \ 42 | -DWITH_STATIC_LIB=OFF \ 43 | -DUSE_TENSORRT=${USE_TENSORRT} \ 44 | -DCUDNN_LIB=${CUDNN_LIB} \ 45 | -DCUDA_LIB=${CUDA_LIB} \ 46 | -DTENSORRT_ROOT=${TENSORRT_ROOT} \ 47 | -DCUSTOM_OPERATOR_FILES=${CUSTOM_OPERATOR_FILES} 48 | 49 | make -j 50 | -------------------------------------------------------------------------------- /tests/datasets/test_nuscenes_dataset.py: -------------------------------------------------------------------------------- 1 | import unittest 2 | 3 | import numpy as np 4 | import paddle 5 | 6 | import paddle3d 7 | 8 | 9 | class NuscenesPCDatasetTestCase(unittest.TestCase): 10 | """ 11 | """ 12 | 13 | def __init__(self, *args, **kwargs): 14 | super().__init__(*args, **kwargs) 15 | #prepare dataset to temp dir 16 | self.nuscenes_minitrain = paddle3d.datasets.NuscenesPCDataset( 17 | dataset_root='../../datasets/nuscenes/', mode='mini_train') 18 | self.nuscenes_minival = paddle3d.datasets.NuscenesPCDataset( 19 | dataset_root='../../datasets/nuscenes/', mode='mini_val') 20 | 21 | def test_size(self): 22 | """ 23 | """ 24 | self.assertEqual(len(self.nuscenes_minitrain), 323) 25 | self.assertEqual(len(self.nuscenes_minival), 81) 26 | 27 | def test_evaluation(self): 28 | """ 29 | """ 30 | samples = [s for s in self.nuscenes_minitrain] 31 | # add confidences 32 | for s in samples: 33 | num_boxes = s.bboxes_3d.shape[0] 34 | s.confidences = np.ones([num_boxes]) 35 | 36 | metric_obj = self.nuscenes_minitrain.metric 37 | metric_obj.update(samples) 38 | print(metric_obj.compute()) 39 | 40 | def test_batching(self): 41 | loader = paddle.io.DataLoader( 42 | self.nuscenes_minitrain, 43 | batch_size=4, 44 | collate_fn=self.nuscenes_minitrain.collate_fn) 45 | for _ in loader: 46 | ... 47 | 48 | 49 | if __name__ == "__main__": 50 | unittest.main() 51 | -------------------------------------------------------------------------------- /test_tipc/common_func.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | function func_parser_key(){ 4 | strs=$1 5 | IFS=":" 6 | array=(${strs}) 7 | tmp=${array[0]} 8 | echo ${tmp} 9 | } 10 | 11 | function func_parser_value(){ 12 | strs=$1 13 | IFS=":" 14 | array=(${strs}) 15 | tmp=${array[1]} 16 | echo ${tmp} 17 | } 18 | 19 | function func_set_params(){ 20 | key=$1 21 | value=$2 22 | if [ ${key}x = "null"x ];then 23 | echo " " 24 | elif [[ ${value} = "null" ]] || [[ ${value} = " " ]] || [ ${#value} -le 0 ];then 25 | echo " " 26 | else 27 | echo "${key}=${value}" 28 | fi 29 | } 30 | 31 | function func_parser_params(){ 32 | strs=$1 33 | IFS=":" 34 | array=(${strs}) 35 | key=${array[0]} 36 | tmp=${array[1]} 37 | IFS="|" 38 | res="" 39 | for _params in ${tmp[*]}; do 40 | IFS="=" 41 | array=(${_params}) 42 | mode=${array[0]} 43 | value=${array[1]} 44 | if [[ ${mode} = ${MODE} ]]; then 45 | IFS="|" 46 | #echo (funcsetparams"{mode}" "${value}") 47 | echo $value 48 | break 49 | fi 50 | IFS="|" 51 | done 52 | echo ${res} 53 | } 54 | 55 | function status_check(){ 56 | last_status=$1 # the exit code 57 | run_command=$2 58 | run_log=$3 59 | if [ $last_status -eq 0 ]; then 60 | echo -e "\033[33m Run successfully with command - ${run_command}! \033[0m" | tee -a ${run_log} 61 | else 62 | echo -e "\033[33m Run failed with command - ${run_command}! \033[0m" | tee -a ${run_log} 63 | fi 64 | } 65 | -------------------------------------------------------------------------------- /test_tipc/configs/caddn/caddn_ocrnet_hrnet_w18_kitti_train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:caddn 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=100 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=4 10 | pretrained_model:null 11 | train_model_name:iter_100/model.pdparams 12 | train_infer_img_dir:./datasets/nuscenes 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/caddn/caddn_ocrnet_hrnet_w18_kitti.yml --num_workers 16 --log_interval 1 --seed 123 --save_interval 100 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================train_benchmark_params========================== 52 | batch_size:4 53 | fp_items:fp32|fp16 54 | iters:100 55 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 56 | flags:FLAGS_cudnn_exhaustive_search=0 57 | -------------------------------------------------------------------------------- /deploy/caddn/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | mkdir -p build 16 | cd build 17 | rm -rf * 18 | 19 | DEMO_NAME=main 20 | 21 | WITH_MKL=ON 22 | WITH_GPU=ON 23 | USE_TENSORRT=ON 24 | 25 | # paddle inference dir 26 | LIB_DIR=/workspace/cadnn/paddle_inference 27 | 28 | OPENCV_DIR=/workspace/cadnn/opencv-3.4.7/build/ 29 | 30 | CUDNN_LIB=/usr/local/x86_64-pc-linux-gnu/ 31 | CUDA_LIB=/usr/local/cuda/lib64 32 | TENSORRT_ROOT=/usr/local/TensorRT-8.2.5.1 33 | CUSTOM_OPERATOR_FILES="custom_ops/iou3d_nms.cpp;custom_ops/iou3d_nms_api.cpp;custom_ops/iou3d_nms_kernel.cu" 34 | 35 | 36 | cmake .. -DPADDLE_LIB=${LIB_DIR} \ 37 | -DOPENCV_DIR=${OPENCV_DIR} \ 38 | -DWITH_MKL=${WITH_MKL} \ 39 | -DDEMO_NAME=${DEMO_NAME} \ 40 | -DWITH_GPU=${WITH_GPU} \ 41 | -DWITH_STATIC_LIB=OFF \ 42 | -DUSE_TENSORRT=${USE_TENSORRT} \ 43 | -DCUDNN_LIB=${CUDNN_LIB} \ 44 | -DCUDA_LIB=${CUDA_LIB} \ 45 | -DTENSORRT_ROOT=${TENSORRT_ROOT} \ 46 | -DCUSTOM_OPERATOR_FILES=${CUSTOM_OPERATOR_FILES} 47 | 48 | make -j 49 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/configs/plenoxels/blender_data.yml: -------------------------------------------------------------------------------- 1 | iters: 16000 2 | 3 | image_batch_size: -1 # sample batch of rays from all images at each iteration 4 | ray_batch_size: 4000 5 | eval_pixel_stride: 1 6 | image_resampling_interval: -1 7 | 8 | amp_cfg: 9 | enable: True 10 | level: O1 11 | scaler: 12 | init_loss_scaling: 1024.0 13 | incr_every_n_steps: 3000 14 | 15 | train_metrics: 16 | - type: PSNRMeter 17 | 18 | val_metrics: 19 | - type: PSNRMeter 20 | - type: SSIMMeter 21 | 22 | train_dataset: 23 | type: BlenderDataset 24 | dataset_root: data/nerf_synthetic/lego 25 | camera_scale_factor: 1.0 26 | background_color: white 27 | image_coords_offset: 0.5 28 | transforms: 29 | - type: LoadImage 30 | - type: Normalize 31 | - type: AlphaBlending 32 | - type: LowPass 33 | inter_resolution: 512 34 | split: train 35 | 36 | val_dataset: 37 | type: BlenderDataset 38 | dataset_root: data/nerf_synthetic/lego 39 | camera_scale_factor: 1.0 40 | background_color: white 41 | image_coords_offset: 0.5 42 | transforms: 43 | - type: LoadImage 44 | - type: Normalize 45 | - type: AlphaBlending 46 | - type: LowPass 47 | inter_resolution: 512 48 | split: val 49 | 50 | optimizer: 51 | type: SGD 52 | learning_rate: 1.0 53 | 54 | model: 55 | type: Plenoxels 56 | ray_sampler: 57 | type: GridIntersectionSampler 58 | uniform: 0.5 59 | jitter: 0.0 60 | field: 61 | type: PlenoxelGrid 62 | radius: 1.3 63 | sh_degree: 2 64 | initial_resolution: 256 65 | rgb_renderer: 66 | type: RGBRenderer 67 | background_color: white 68 | rgb_loss: 69 | type: MSELoss 70 | -------------------------------------------------------------------------------- /test_tipc/configs/petrv1/petr_vovnet_gridmask_p4_800x320_fp32_ultra_train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:petr_vovnet_gridmask_p4_800x320 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=100 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=1 10 | pretrained_model:null 11 | train_model_name:iter_100/model.pdparams 12 | train_infer_img_dir:./data/nuscenes 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/petr/petr_vovnet_gridmask_p4_800x320_fp32_ultra.yml --num_workers 24 --log_interval 1 --seed 123 --save_interval 100 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================train_benchmark_params========================== 52 | batch_size:8 53 | fp_items:fp32 54 | iters:100 55 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 56 | flags:FLAGS_cudnn_exhaustive_search=0 57 | -------------------------------------------------------------------------------- /test_tipc/configs/petrv1/petr_vovnet_gridmask_p4_800x320_ampO2_ultra_train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:petr_vovnet_gridmask_p4_800x320 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=100 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=1 10 | pretrained_model:null 11 | train_model_name:iter_100/model.pdparams 12 | train_infer_img_dir:./data/nuscenes 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/petr/petr_vovnet_gridmask_p4_800x320_ampO2_ultra.yml --num_workers 24 --log_interval 1 --seed 123 --save_interval 100 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================train_benchmark_params========================== 52 | batch_size:16 53 | fp_items:fp16 54 | iters:100 55 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 56 | flags:FLAGS_cudnn_exhaustive_search=0 57 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/ray_samplers/base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import abc 16 | from typing import Callable 17 | 18 | import paddle.nn as nn 19 | 20 | from pprndr.cameras.rays import RayBundle, RaySamples 21 | 22 | __all__ = ["BaseSampler"] 23 | 24 | 25 | class BaseSampler(nn.Layer): 26 | def __init__(self, num_samples: int = None): 27 | super(BaseSampler, self).__init__() 28 | 29 | self._num_samples = num_samples 30 | 31 | @property 32 | def num_samples(self): 33 | return self._num_samples 34 | 35 | @abc.abstractmethod 36 | def generate_ray_samples(self, ray_bundle: RayBundle, 37 | **kwargs) -> RaySamples: 38 | """Generate ray samples.""" 39 | 40 | def forward(self, 41 | ray_bundle: RayBundle, 42 | *, 43 | cur_iter: int = None, 44 | density_fn: Callable = None, 45 | **kwargs) -> RaySamples: 46 | return self.generate_ray_samples(ray_bundle, **kwargs) 47 | -------------------------------------------------------------------------------- /test_tipc/configs/petrv2/petrv2_vovnet_gridmask_p4_800x320_dn_centerview_train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:petrv2_vovnet_gridmask_p4_800x320_dn_centerview 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=100 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=1 10 | pretrained_model:null 11 | train_model_name:iter_100/model.pdparams 12 | train_infer_img_dir:./data/nuscenes 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/petr/petrv2_vovnet_gridmask_p4_800x320_dn_centerview.yml --num_workers 24 --log_interval 1 --seed 123 --save_interval 100 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================train_benchmark_params========================== 52 | batch_size:1 53 | fp_items:fp32|fp16 54 | iters:100 55 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 56 | flags:FLAGS_cudnn_exhaustive_search=0 57 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/configs/plenoxels/blender_data_grad_accum.yml: -------------------------------------------------------------------------------- 1 | iters: 64000 2 | 3 | image_batch_size: -1 # sample batch of rays from all images at each iteration 4 | ray_batch_size: 1000 5 | image_resampling_interval: -1 6 | 7 | amp_cfg: 8 | enable: True 9 | level: O1 10 | scaler: 11 | init_loss_scaling: 1024.0 12 | incr_every_n_steps: 3000 13 | 14 | grad_accum_cfg: 15 | accum_steps: 4 # update parameters every 4 iterations 16 | 17 | train_metrics: 18 | - type: PSNRMeter 19 | 20 | val_metrics: 21 | - type: PSNRMeter 22 | - type: SSIMMeter 23 | 24 | train_dataset: 25 | type: BlenderDataset 26 | dataset_root: data/nerf_synthetic/lego 27 | camera_scale_factor: 1.0 28 | background_color: white 29 | transforms: 30 | - type: LoadImage 31 | - type: Normalize 32 | - type: AlphaBlending 33 | - type: LowPass 34 | inter_resolution: 512 35 | split: train 36 | 37 | val_dataset: 38 | type: BlenderDataset 39 | dataset_root: data/nerf_synthetic/lego 40 | camera_scale_factor: 1.0 41 | background_color: white 42 | transforms: 43 | - type: LoadImage 44 | - type: Normalize 45 | - type: AlphaBlending 46 | - type: LowPass 47 | inter_resolution: 512 48 | split: val 49 | 50 | optimizer: 51 | type: SGD 52 | learning_rate: .25 # 1.0 / ${accum_steps} 53 | 54 | model: 55 | type: Plenoxels 56 | ray_sampler: 57 | type: GridIntersectionSampler 58 | uniform: 0.5 59 | jitter: 0.0 60 | field: 61 | type: PlenoxelGrid 62 | radius: 1.3 63 | sh_degree: 2 64 | initial_resolution: 256 65 | rgb_renderer: 66 | type: RGBRenderer 67 | background_color: white 68 | rgb_loss: 69 | type: MSELoss 70 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/ray_generators.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import paddle 16 | import paddle.nn as nn 17 | 18 | from pprndr.cameras import Cameras 19 | 20 | __all__ = ["RayGenerator"] 21 | 22 | 23 | class RayGenerator(nn.Layer): 24 | def __init__(self, cameras: Cameras, offset: float = 0.5): 25 | super(RayGenerator, self).__init__() 26 | 27 | self.cameras = cameras 28 | image_coords = cameras.get_image_coords(offset=offset) 29 | self.register_buffer("image_coords", image_coords) 30 | 31 | def forward(self, camera_ids: paddle.Tensor, pixel_indices: paddle.Tensor): 32 | """ 33 | Generate rays according to ray indices. 34 | Args: 35 | camera_ids: [N] camera ids. 36 | pixel_indices: [N, 2], pixel indices, 2 = (row, col). 37 | """ 38 | image_coords = paddle.gather_nd(self.image_coords, pixel_indices) 39 | 40 | ray_bundle = self.cameras.generate_rays( 41 | camera_ids=camera_ids, image_coords=image_coords) 42 | 43 | return ray_bundle 44 | -------------------------------------------------------------------------------- /test_tipc/configs/centerpoint/centerpoint_pillars_02voxel_nuscenes_10sweep_ampO2_ultra_train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:centerpoint_pillars_02voxel_nuscenes_10sweep 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=100 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=4 10 | pretrained_model:null 11 | train_model_name:iter_100/model.pdparams 12 | train_infer_img_dir:./datasets/KITTI 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/centerpoint/centerpoint_pillars_02voxel_nuscenes_10sweep_ampO2_ultra.yml --num_workers 16 --log_interval 1 --seed 123 --save_interval 100 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================train_benchmark_params========================== 52 | batch_size:8 53 | fp_items:fp16 54 | iters:300 55 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 56 | flags:FLAGS_cudnn_exhaustive_search=0 57 | -------------------------------------------------------------------------------- /test_tipc/configs/centerpoint/centerpoint_pillars_02voxel_nuscenes_10sweep_fp32_ultra_train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:centerpoint_pillars_02voxel_nuscenes_10sweep 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=100 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=4 10 | pretrained_model:null 11 | train_model_name:iter_100/model.pdparams 12 | train_infer_img_dir:./datasets/KITTI 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/centerpoint/centerpoint_pillars_02voxel_nuscenes_10sweep_fp32_ultra.yml --num_workers 16 --log_interval 1 --seed 123 --save_interval 100 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================train_benchmark_params========================== 52 | batch_size:4 53 | fp_items:fp32 54 | iters:300 55 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 56 | flags:FLAGS_cudnn_exhaustive_search=0 57 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/models/encoders/sh_encoder.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import paddle 16 | import paddle.nn as nn 17 | 18 | from pprndr.apis import manager 19 | 20 | try: 21 | import sh_encoder 22 | except ModuleNotFoundError: 23 | from pprndr.cpp_extensions import sh_encoder 24 | 25 | __all__ = ["SHEncoder"] 26 | 27 | 28 | @manager.ENCODERS.add_component 29 | class SHEncoder(nn.Layer): 30 | def __init__(self, input_dim=3, degree=3): 31 | super(SHEncoder, self).__init__() 32 | self.input_dim = input_dim 33 | self.degree = degree 34 | self.output_dim = (self.degree + 1)**2 35 | 36 | assert self.input_dim == 3, "SH encoder only support input dim == 3" 37 | assert 0 <= self.degree < 8, "SH encoder only supports degree in [0, 7]" 38 | 39 | def forward(self, x): 40 | with paddle.amp.auto_cast(enable=False): 41 | x = x.reshape([-1, self.input_dim]) 42 | outputs, _ = sh_encoder.sh_encode( 43 | x, self.degree, (not self.training) or x.stop_gradient) 44 | 45 | return outputs 46 | -------------------------------------------------------------------------------- /paddle3d/thirdparty/semantic_kitti_api/auxiliary/shaders/draw_voxels.vert: -------------------------------------------------------------------------------- 1 | # version 330 core 2 | 3 | layout(location = 0) in vec3 in_position; 4 | layout(location = 1) in vec3 in_normal; 5 | layout(location = 2) in float in_label; // Note: uint with np.uint32 did not work as expected! 6 | 7 | uniform mat4 mvp; 8 | uniform mat4 view_mat; 9 | uniform sampler2DRect label_colors; 10 | uniform bool use_label_colors; 11 | 12 | uniform ivec3 voxel_dims; 13 | uniform float voxel_size; 14 | uniform float voxel_scale; 15 | uniform vec3 voxel_color; 16 | uniform float voxel_alpha; 17 | 18 | out vec3 position; 19 | out vec3 normal; 20 | out vec4 color; 21 | 22 | 23 | void main() 24 | { 25 | // instance id corresponds to the index in the grid. 26 | vec3 idx; 27 | idx.x = int(float(gl_InstanceID) / float(voxel_dims.y * voxel_dims.z)); 28 | idx.y = int(float(gl_InstanceID - idx.x * voxel_dims.y * voxel_dims.z) / float(voxel_dims.z)); 29 | idx.z = int(gl_InstanceID - idx.x * voxel_dims.y * voxel_dims.z - idx.y * voxel_dims.z); 30 | 31 | // centerize the voxelgrid. 32 | vec3 offset = voxel_size * vec3(0, 0.5, 0.5) * voxel_dims; 33 | vec3 pos = voxel_scale * voxel_size * (in_position - 0.5); // centerize the voxel coordinates and resize. 34 | 35 | position = (view_mat * vec4(pos + idx * voxel_size - offset, 1)).xyz; 36 | normal = (view_mat * vec4(in_normal, 0)).xyz; 37 | 38 | uint label = uint(in_label); 39 | 40 | if(label == uint(0)) // empty voxels 41 | gl_Position = vec4(-10, -10, -10, 1); 42 | else 43 | gl_Position = mvp * vec4(pos + idx * voxel_size - offset, 1); 44 | 45 | color = vec4(voxel_color, voxel_alpha); 46 | if (use_label_colors) color = vec4(texture(label_colors, vec2(label, 0)).rgb, voxel_alpha); 47 | } -------------------------------------------------------------------------------- /test_tipc/configs/pointpillars/train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:pointpillars 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=400 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=1 10 | pretrained_model:null 11 | train_model_name:iter_400/model.pdparams 12 | train_infer_img_dir:./datasets/KITTI 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/pointpillars/pointpillars_xyres16_kitti_car.yml --num_workers 8 --log_interval 10 --seed 123 --save_interval 10000 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================to_static_train_benchmark_params=========================== 52 | to_static_train:--to_static True 53 | ===========================train_benchmark_params========================== 54 | batch_size:2 55 | fp_items:fp32|fp16 56 | iters:400 57 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 58 | flags:FLAGS_cudnn_exhaustive_search=0 59 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/data/datasets/base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import abc 16 | 17 | import paddle 18 | 19 | from pprndr.cameras import Cameras 20 | 21 | __all__ = ["BaseDataset"] 22 | 23 | 24 | class _ParseCaller(type): 25 | def __call__(cls, *args, **kwargs): 26 | obj = type.__call__(cls, *args, **kwargs) 27 | obj._parse() 28 | return obj 29 | 30 | 31 | class BaseDataset(paddle.io.Dataset, metaclass=_ParseCaller): 32 | @abc.abstractmethod 33 | def _parse(self) -> dict: 34 | """ 35 | Parse dataset. This is automatically called when create a dataset as a post-initialization method. 36 | """ 37 | 38 | @property 39 | @abc.abstractmethod 40 | def cameras(self) -> Cameras: 41 | """ 42 | Cameras. 43 | """ 44 | 45 | @property 46 | @abc.abstractmethod 47 | def split(self) -> str: 48 | """ 49 | Which split ("train", "val", "trainval", etc.) the dataset belongs to. 50 | """ 51 | 52 | @property 53 | def is_train_mode(self): 54 | return "train" in self.split 55 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/utils/colors.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2023 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License") 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | from typing import List, Union 16 | 17 | __all__ = ["get_color"] 18 | 19 | color_dict = { 20 | "white": [1.0, 1.0, 1.0], 21 | "black": [0.0, 0.0, 0.0], 22 | "red": [1.0, 0.0, 0.0], 23 | "green": [0.0, 1.0, 0.0], 24 | "blue": [0.0, 0.0, 1.0], 25 | } 26 | 27 | 28 | def get_color(color: Union[str, list, tuple]) -> List: 29 | """ 30 | Args: 31 | color (Union[str, list]): Color as a string or a rgb list 32 | 33 | Returns: 34 | TensorType[3]: Parsed color 35 | """ 36 | if isinstance(color, str): 37 | color = color.lower() 38 | if color not in color_dict: 39 | raise ValueError( 40 | "{} is not a valid preset color. please use one of {}".format( 41 | color, color_dict.keys())) 42 | return color_dict[color] 43 | elif isinstance(color, list): 44 | if len(color) != 3: 45 | raise ValueError( 46 | "Color should be 3 values (RGB) instead got {}".format(color)) 47 | return color 48 | -------------------------------------------------------------------------------- /configs/smoke/smoke_hrnet18_no_dcn_kitti.yml: -------------------------------------------------------------------------------- 1 | _base_: '../_base_/kitti_mono.yml' 2 | 3 | batch_size: 8 4 | iters: 70000 5 | 6 | train_dataset: 7 | transforms: 8 | - type: LoadImage 9 | reader: pillow 10 | to_chw: False 11 | - type: Gt2SmokeTarget 12 | mode: train 13 | num_classes: 3 14 | input_size: [1280, 384] 15 | - type: Normalize 16 | mean: [0.485, 0.456, 0.406] 17 | std: [0.229, 0.224, 0.225] 18 | 19 | val_dataset: 20 | transforms: 21 | - type: LoadImage 22 | reader: pillow 23 | to_chw: False 24 | - type: Gt2SmokeTarget 25 | mode: val 26 | num_classes: 3 27 | input_size: [1280, 384] 28 | - type: Normalize 29 | mean: [0.485, 0.456, 0.406] 30 | std: [0.229, 0.224, 0.225] 31 | 32 | optimizer: 33 | type: Adam 34 | 35 | lr_scheduler: 36 | type: MultiStepDecay 37 | milestones: [36000, 55000] 38 | learning_rate: 1.25e-4 39 | 40 | model: 41 | type: SMOKE 42 | backbone: 43 | type: $paddleseg.HRNet_W18 44 | pretrained: https://bj.bcebos.com/paddleseg/dygraph/hrnet_w18_ssld.tar.gz 45 | head: 46 | type: SMOKEPredictor 47 | num_classes: 3 48 | reg_channels: [1, 2, 3, 2, 2] 49 | num_channels: 256 50 | norm_type: "gn" 51 | in_channels: 270 52 | depth_ref: [28.01, 16.32] 53 | # dim_ref is the reference size mentioned in the paper, the order here is [l, h, w] 54 | dim_ref: [[3.88, 1.63, 1.53], [1.78, 1.70, 0.58], [0.88, 1.73, 0.67]] 55 | max_detection: 50 56 | pred_2d: True 57 | 58 | export: 59 | transforms: 60 | - type: LoadImage 61 | reader: pillow 62 | to_chw: False 63 | to_rgb: True 64 | - type: Normalize 65 | mean: [0.485, 0.456, 0.406] 66 | std: [0.229, 0.224, 0.225] 67 | -------------------------------------------------------------------------------- /deploy/iassd/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | mkdir -p build 16 | cd build 17 | rm -rf * 18 | 19 | DEMO_NAME=main 20 | 21 | WITH_MKL=ON 22 | WITH_GPU=ON 23 | USE_TENSORRT=ON 24 | 25 | LIB_DIR=/workspace/Paddle3D/deploy/iassd/cpp/paddle_inference 26 | CUDNN_LIB=/usr/lib/x86_64-linux-gnu 27 | CUDA_LIB=/usr/local/cuda/lib64 28 | TENSORRT_ROOT=/workspace/TensorRT-8.2.5.1 29 | CUSTOM_OPERATOR_FILES="custom_ops/ball_query_gpu.cu;custom_ops/ball_query.cc;\ 30 | custom_ops/gather_points_gpu.cu;custom_ops/gather_points.cc;\ 31 | custom_ops/group_points_gpu.cu;custom_ops/group_points.cc;\ 32 | custom_ops/sampling_gpu.cu;custom_ops/sampling.cc;\ 33 | custom_ops/iou3d_cpu.cpp;custom_ops/iou3d_nms_api.cpp;custom_ops/iou3d_nms.cpp;custom_ops/iou3d_nms_kernel.cu" 34 | 35 | 36 | cmake .. -DPADDLE_LIB=${LIB_DIR} \ 37 | -DWITH_MKL=${WITH_MKL} \ 38 | -DDEMO_NAME=${DEMO_NAME} \ 39 | -DWITH_GPU=${WITH_GPU} \ 40 | -DWITH_STATIC_LIB=OFF \ 41 | -DUSE_TENSORRT=${USE_TENSORRT} \ 42 | -DCUDNN_LIB=${CUDNN_LIB} \ 43 | -DCUDA_LIB=${CUDA_LIB} \ 44 | -DTENSORRT_ROOT=${TENSORRT_ROOT} \ 45 | -DCUSTOM_OPERATOR_FILES=${CUSTOM_OPERATOR_FILES} 46 | 47 | make -j 48 | -------------------------------------------------------------------------------- /test_tipc/README.md: -------------------------------------------------------------------------------- 1 | 2 | # 飞桨训推一体认证(TIPC) 3 | 4 | ## 1. 简介 5 | 6 | 飞桨除了基本的模型训练和预测,还提供了支持多端多平台的高性能推理部署工具。本文档提供了Paddle3D中所有模型的飞桨训推一体认证 (Training and Inference Pipeline Certification(TIPC)) 信息和测试工具,方便用户查阅每种模型的训练推理部署打通情况,并可以进行一键测试。 7 | 8 |
9 | 10 |
11 | 12 | 13 | ## 2. 测试工具简介 14 | ### 目录介绍 15 | 16 | ```shell 17 | test_tipc/ 18 | ├── configs/ # 配置文件目录 19 | ├── paconv # paconv模型的测试配置文件目录 20 | ├── train_infer_python.txt # 测试Linux上python训练预测(基础训练预测)的配置文件 21 | ├── train_infer_python.md # 测试Linux上python训练预测(基础训练预测)的使用文档 22 | ├── results/ # 预测结果 23 | ├── prepare.sh # 完成test_*.sh运行所需要的数据和模型下载 24 | ├── test_train_inference_python.sh # 测试python训练预测的主程序 25 | └── readme.md # 使用文档 26 | ``` 27 | 28 | ### 测试流程概述 29 | 30 | 使用本工具,可以测试不同功能的支持情况,以及预测结果是否对齐,测试流程概括如下: 31 | 32 | 1. 运行prepare.sh准备测试所需数据和模型; 33 | 2. 运行要测试的功能对应的测试脚本`test_train_inference_python.sh`,产出log,由log可以看到不同配置是否运行成功; 34 | 35 | 测试单项功能仅需两行命令,**如需测试不同模型/功能,替换配置文件即可**,命令格式如下: 36 | ```shell 37 | # 功能:准备数据 38 | # 格式:bash + 运行脚本 + 参数1: 配置文件选择 + 参数2: 模式选择 39 | bash test_tipc/prepare.sh configs/[model_name]/[params_file_name] [Mode] 40 | 41 | # 功能:运行测试 42 | # 格式:bash + 运行脚本 + 参数1: 配置文件选择 + 参数2: 模式选择 43 | bash test_tipc/test_train_inference_python.sh configs/[model_name]/[params_file_name] [Mode] 44 | ``` 45 | 46 | 以下为示例: 47 | ```shell 48 | # 功能:准备数据 49 | # 格式:bash + 运行脚本 + 参数1: 配置文件选择 + 参数2: 模式选择 50 | bash test_tipc/prepare.sh ./test_tipc/configs/paconv/train_infer_python.txt 'lite_train_lite_infer' 51 | 52 | # 功能:运行测试 53 | # 格式:bash + 运行脚本 + 参数1: 配置文件选择 + 参数2: 模式选择 54 | bash test_tipc/test_train_inference_python.sh ./test_tipc/configs/paconv/train_infer_python.txt 'lite_train_lite_infer' 55 | ``` 56 | -------------------------------------------------------------------------------- /test_tipc/configs/centerpoint/centerpoint_pillars_016voxel_kitti_train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:centerpoint_pillars_016voxel_kitti 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=100 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=4 10 | pretrained_model:null 11 | train_model_name:iter_100/model.pdparams 12 | train_infer_img_dir:./datasets/KITTI 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/centerpoint/centerpoint_pillars_016voxel_kitti.yml --num_workers 4 --log_interval 1 --seed 123 --save_interval 100 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================to_static_train_benchmark_params=========================== 52 | to_static_train:--to_static True 53 | ===========================train_benchmark_params========================== 54 | batch_size:4 55 | fp_items:fp32|fp16 56 | iters:100 57 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 58 | flags:FLAGS_cudnn_exhaustive_search=0 59 | -------------------------------------------------------------------------------- /paddle3d/datasets/modelnet40/modelnet40_metric.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | from typing import List 15 | 16 | import paddle 17 | 18 | from paddle3d.datasets.metrics import MetricABC 19 | from paddle3d.sample import Sample 20 | from paddle3d.utils.logger import logger 21 | 22 | __all__ = ["AccuracyMetric"] 23 | 24 | 25 | class AccuracyMetric(MetricABC): 26 | def __init__(self, num_classes: int): 27 | # classes 28 | self.num_classes = num_classes 29 | self.predictions = [] 30 | self.ground_truths = [] 31 | 32 | def update(self, 33 | predictions: List[Sample], 34 | ground_truths: List[Sample] = None): 35 | self.predictions.append(predictions) 36 | self.ground_truths.append(ground_truths) 37 | 38 | def compute(self, verbose=False): 39 | self.predictions = paddle.concat(self.predictions, axis=0) 40 | self.ground_truths = paddle.concat(self.ground_truths, axis=0) 41 | accuracy = paddle.metric.accuracy(self.predictions, self.ground_truths) 42 | if verbose: 43 | logger.info("Acc {:.3f}".format(float(accuracy))) 44 | return dict(accuracy=accuracy) 45 | -------------------------------------------------------------------------------- /configs/smoke/smoke_dla34_no_dcn_kitti.yml: -------------------------------------------------------------------------------- 1 | _base_: '../_base_/kitti_mono.yml' 2 | 3 | batch_size: 8 4 | iters: 70000 5 | 6 | train_dataset: 7 | transforms: 8 | - type: LoadImage 9 | reader: pillow 10 | to_chw: False 11 | - type: Gt2SmokeTarget 12 | mode: train 13 | num_classes: 3 14 | input_size: [1280, 384] 15 | - type: Normalize 16 | mean: [0.485, 0.456, 0.406] 17 | std: [0.229, 0.224, 0.225] 18 | 19 | val_dataset: 20 | transforms: 21 | - type: LoadImage 22 | reader: pillow 23 | to_chw: False 24 | - type: Gt2SmokeTarget 25 | mode: val 26 | num_classes: 3 27 | input_size: [1280, 384] 28 | - type: Normalize 29 | mean: [0.485, 0.456, 0.406] 30 | std: [0.229, 0.224, 0.225] 31 | 32 | optimizer: 33 | type: Adam 34 | 35 | lr_scheduler: 36 | type: MultiStepDecay 37 | milestones: [36000, 55000] 38 | learning_rate: 1.25e-4 39 | 40 | model: 41 | type: SMOKE 42 | backbone: 43 | type: DLA34 44 | # This will automatically save to ~/.paddle3d/pretrained/dla34/dla34.pdparams 45 | pretrained: "https://bj.bcebos.com/paddle3d/pretrained/dla34.pdparams" 46 | head: 47 | type: SMOKEPredictor 48 | num_classes: 3 49 | reg_channels: [1, 2, 3, 2, 2] 50 | num_channels: 256 51 | norm_type: "gn" 52 | in_channels: 64 53 | depth_ref: [28.01, 16.32] 54 | # dim_ref is the reference size mentioned in the paper, the order here is [l, h, w] 55 | dim_ref: [[3.88, 1.63, 1.53], [1.78, 1.70, 0.58], [0.88, 1.73, 0.67]] 56 | max_detection: 50 57 | pred_2d: True 58 | 59 | export: 60 | transforms: 61 | - type: LoadImage 62 | reader: pillow 63 | to_chw: False 64 | to_rgb: True 65 | - type: Normalize 66 | mean: [0.485, 0.456, 0.406] 67 | std: [0.229, 0.224, 0.225] 68 | -------------------------------------------------------------------------------- /test_tipc/configs/petrv2/petrv2_vovnet_gridmask_p4_800x320_train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:petrv2_vovnet_gridmask_p4_800x320 3 | python:python3.7 4 | gpu_list:0 5 | ## 6 | auto_cast:null 7 | --iters:lite_train_lite_infer=100 8 | --save_dir:./output/ 9 | --batch_size:lite_train_lite_infer=1 10 | pretrained_model:null 11 | train_model_name:iter_100/model.pdparams 12 | train_infer_img_dir:./data/nuscenes 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:tools/train.py --config configs/petr/petrv2_vovnet_gridmask_p4_800x320.yml --num_workers 2 --log_interval 1 --seed 123 --model fcos3d_vovnet_imgbackbone-remapped.pdparams --save_interval 100 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | --output_dir:./output/ 29 | load:null 30 | norm_export:null 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:null 38 | infer_export:null 39 | infer_quant:False 40 | inference:null 41 | null:null 42 | null:null 43 | null:null 44 | null:null 45 | null:null 46 | --model_path: 47 | null:null 48 | null:null 49 | --benchmark:True 50 | null:null 51 | ===========================to_static_train_benchmark_params=========================== 52 | to_static_train:--to_static True 53 | ===========================train_benchmark_params========================== 54 | batch_size:1 55 | fp_items:fp32|fp16 56 | iters:100 57 | --profiler_options:batch_range=[10,20];state=GPU;tracer_option=Default;profile_path=model.profile 58 | flags:FLAGS_cudnn_exhaustive_search=0 59 | -------------------------------------------------------------------------------- /contrib/PaddleRendering/pprndr/cpp_extensions/sh_encoder/src/sh_encoder.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "paddle/extension.h" 4 | 5 | #ifdef PADDLE_WITH_CUDA 6 | std::vector sh_encode_forward(const paddle::Tensor &inputs, 7 | const int64_t degree, 8 | const bool stop_gradient); 9 | 10 | std::vector sh_encode_backward(const paddle::Tensor &grad, 11 | const paddle::Tensor &inputs, 12 | const paddle::Tensor &dy_dx, 13 | const int64_t degree, 14 | const bool stop_gradient); 15 | #endif 16 | 17 | std::vector> SHEncoderInferShape( 18 | std::vector inputs_shape, const int64_t degree, 19 | const bool stop_gradient) { 20 | int64_t B = inputs_shape[0]; 21 | int64_t input_dim = inputs_shape[1]; 22 | int64_t output_dim = degree * degree; 23 | return {{B, output_dim}, {B, input_dim, output_dim}}; 24 | } 25 | 26 | std::vector SHEncoderInferDtype( 27 | paddle::DataType inputs_dtype) { 28 | return {inputs_dtype, inputs_dtype}; 29 | } 30 | 31 | PD_BUILD_OP(sh_encode) 32 | .Inputs({"inputs"}) 33 | .Outputs({"outputs", "dy_dx"}) 34 | .Attrs({"degree: int64_t", "stop_gradient: bool"}) 35 | .SetKernelFn(PD_KERNEL(sh_encode_forward)) 36 | .SetInferShapeFn(PD_INFER_SHAPE(SHEncoderInferShape)) 37 | .SetInferDtypeFn(PD_INFER_DTYPE(SHEncoderInferDtype)); 38 | 39 | PD_BUILD_GRAD_OP(sh_encode) 40 | .Inputs({paddle::Grad("outputs"), "inputs", "dy_dx"}) 41 | .Outputs({paddle::Grad("inputs")}) 42 | .Attrs({"degree: int64_t", "stop_gradient: bool"}) 43 | .SetKernelFn(PD_KERNEL(sh_encode_backward)); 44 | -------------------------------------------------------------------------------- /deploy/pv_rcnn/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | mkdir -p build 16 | cd build 17 | rm -rf * 18 | 19 | DEMO_NAME=main 20 | 21 | WITH_MKL=ON 22 | WITH_GPU=ON 23 | USE_TENSORRT=OFF 24 | 25 | LIB_DIR=/centerpoint/kaihuo/Paddle/build/paddle_inference_install_dir 26 | CUDNN_LIB=/usr/lib/x86_64-linux-gnu 27 | CUDA_LIB=/usr/local/cuda/lib64 28 | TENSORRT_ROOT=/centerpoint/two_three/Paddle/TensorRT-8.2.5.1 29 | CUSTOM_OPERATOR_FILES="custom_ops/voxel/voxelize_op.cc;custom_ops/voxel/voxelize_op.cu;custom_ops/iou3d_nms/iou3d_cpu.cpp;custom_ops/iou3d_nms/iou3d_nms_api.cpp;custom_ops/iou3d_nms/iou3d_nms.cpp;custom_ops/iou3d_nms/iou3d_nms_kernel.cu;custom_ops/pointnet2/sampling_gpu.cu;custom_ops/pointnet2/sampling.cc;custom_ops/pointnet2/ball_query_gpu.cu;custom_ops/pointnet2/ball_query.cc;custom_ops/pointnet2/group_points.cc;custom_ops/pointnet2/group_points_gpu.cu" 30 | 31 | 32 | cmake .. -DPADDLE_LIB=${LIB_DIR} \ 33 | -DWITH_MKL=${WITH_MKL} \ 34 | -DDEMO_NAME=${DEMO_NAME} \ 35 | -DWITH_GPU=${WITH_GPU} \ 36 | -DWITH_STATIC_LIB=OFF \ 37 | -DUSE_TENSORRT=${USE_TENSORRT} \ 38 | -DCUDNN_LIB=${CUDNN_LIB} \ 39 | -DCUDA_LIB=${CUDA_LIB} \ 40 | -DTENSORRT_ROOT=${TENSORRT_ROOT} \ 41 | -DCUSTOM_OPERATOR_FILES=${CUSTOM_OPERATOR_FILES} 42 | 43 | make -j 44 | -------------------------------------------------------------------------------- /paddle3d/utils/box_utils.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import numpy as np 16 | 17 | 18 | def limit_period(val, offset: float = 0.5, period: float = np.pi): 19 | return val - np.floor(val / period + offset) * period 20 | 21 | 22 | def boxes3d_kitti_lidar_to_lidar(boxes3d_lidar): 23 | """ 24 | convert boxes from [x, y, z, w, l, h, yaw] to [x, y, z, l, w, h, heading], bottom_center -> obj_center 25 | """ 26 | # yapf: disable 27 | w, l, h, r = boxes3d_lidar[:, 3:4], boxes3d_lidar[:, 4:5], boxes3d_lidar[:, 5:6], boxes3d_lidar[:, 6:7] 28 | boxes3d_lidar[:, 2] += h[:, 0] / 2 29 | # yapf: enable 30 | return np.concatenate([boxes3d_lidar[:, 0:3], l, w, h, -(r + np.pi / 2)], 31 | axis=-1) 32 | 33 | 34 | def boxes3d_lidar_to_kitti_lidar(boxes3d_lidar): 35 | """ 36 | convert boxes from [x, y, z, l, w, h, heading] to [x, y, z, w, l, h, yaw], obj_center -> bottom_center 37 | """ 38 | # yapf: disable 39 | l, w, h, heading = boxes3d_lidar[:, 3:4], boxes3d_lidar[:, 4:5], boxes3d_lidar[:, 5:6], boxes3d_lidar[:,6:7] 40 | boxes3d_lidar[:, 2] -= h[:, 0] / 2 41 | # yapf: enable 42 | return np.concatenate( 43 | [boxes3d_lidar[:, 0:3], w, l, h, -(heading + np.pi / 2)], axis=-1) 44 | -------------------------------------------------------------------------------- /configs/quant/README.md: -------------------------------------------------------------------------------- 1 | # 动态图量化训练 2 | 3 | ## 目录 4 | * [量化训练 & 评估](#4) 5 | * [量化模型导出](#8) 6 | 7 | ##

量化训练 & 评估

8 | 9 | #### 数据准备 10 | 参考具体各个模型的数据集准备 11 | 12 | #### 量化训练 13 | 14 | 以BEVFormer在nuScenes数据集上的量化训练为例: 15 | 16 | 使用已训练好的模型为预训练模型参数。 17 | ``` 18 | python -m paddle.distributed.launch --gpus 0,1,2,3 tools/train.py --config configs/bevformer/bevformer_tiny_r50_fpn_nuscenes.yml --quant_config configs/quant/bevformer_PACT.yml --save_dir ./output_bevformer_tiny_quant --num_workers 4 --save_interval 1 --model ./output_bevformer_tiny/epoch_24/model.pdparams 19 | ``` 20 | 21 | 训练启动参数介绍可参考文档[全流程速览](../../quickstart.md#模型训练)。 22 | 23 | #### 评估 24 | 25 | ``` 26 | python tools/evaluate.py --quant_config configs/quant/bevformer_PACT.yml --config configs/bevformer/bevformer_tiny_r50_fpn_nuscenes.yml --model ./output_bevformer_tiny_quant/epoch_5/model.pdparams --num_workers 4 27 | ``` 28 | 29 | 评估启动参数介绍可参考文档[全流程速览](../../quickstart.md#模型评估)。 30 | 31 | ##

量化模型导出

32 | 33 | 运行以下命令,将训练时保存的动态图模型文件导出成推理引擎能够加载的静态图模型文件。 34 | 35 | ``` 36 | python tools/export.py --quant_config configs/quant/bevformer.yml --config configs/bevformer/bevformer_tiny.yml --model ./output_bevformer_tiny_quant/epoch_5/model.pdparams --save_dir ./output_bevformer_tiny_quant_inference 37 | ``` 38 | **注意:模型导出无论是否使用PACT量化训练方法,导出模型的配置文件一律删除PACT配置,参考configs/quant/bevformer.yml和configs/quant/bevformer_PACT.yml可知。** 39 | | 参数 | 说明 | 40 | | -- | -- | 41 | | config | **[必填]** 训练配置文件所在路径 | 42 | | quant_config | **[必填]** 量化配置文件所在路径 | 43 | | model | **[必填]** 训练时保存的量化模型文件`model.pdparams`所在路径 | 44 | | save_dir | **[必填]** 保存导出模型的路径,`save_dir`下将会生成三个文件:`bevformer_inference.pdiparams `、`bevformer_inference.pdiparams.info`和`bevformer_inference.pdmodel` | 45 | 46 | - 量化的BEVFormer在nuScenes Val set数据集上的表现 47 | 48 | | 模型 | mAP | NDS | 49 | | ---- | --- | ----| 50 | | 原模型| 26.22 | 36.53 | 51 | | 量化模型 | 26.35 | 36.54 | 52 | -------------------------------------------------------------------------------- /deploy/voxel_rcnn/cpp/compile.sh: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | mkdir -p build 16 | cd build 17 | rm -rf * 18 | 19 | DEMO_NAME=main 20 | 21 | WITH_MKL=ON 22 | WITH_GPU=ON 23 | USE_TENSORRT=OFF 24 | 25 | LIB_DIR=/centerpoint/kaihuo/Paddle/build_develop/paddle_inference_install_dir 26 | CUDNN_LIB=/usr/lib/x86_64-linux-gnu 27 | CUDA_LIB=/usr/local/cuda/lib64 28 | TENSORRT_ROOT=/centerpoint/two_three/Paddle/TensorRT-8.2.5.1 29 | CUSTOM_OPERATOR_FILES="custom_ops/voxel/voxelize_op.cc;custom_ops/voxel/voxelize_op.cu;custom_ops/iou3d_nms/iou3d_cpu.cpp;custom_ops/iou3d_nms/iou3d_nms_api.cpp;custom_ops/iou3d_nms/iou3d_nms.cpp;custom_ops/iou3d_nms/iou3d_nms_kernel.cu;custom_ops/pointnet2/sampling_gpu.cu;custom_ops/pointnet2/sampling.cc;custom_ops/pointnet2/voxel_query_gpu.cu;custom_ops/pointnet2/voxel_query.cc;custom_ops/pointnet2/group_points.cc;custom_ops/pointnet2/group_points_gpu.cu" 30 | 31 | 32 | cmake .. -DPADDLE_LIB=${LIB_DIR} \ 33 | -DWITH_MKL=${WITH_MKL} \ 34 | -DDEMO_NAME=${DEMO_NAME} \ 35 | -DWITH_GPU=${WITH_GPU} \ 36 | -DWITH_STATIC_LIB=OFF \ 37 | -DUSE_TENSORRT=${USE_TENSORRT} \ 38 | -DCUDNN_LIB=${CUDNN_LIB} \ 39 | -DCUDA_LIB=${CUDA_LIB} \ 40 | -DTENSORRT_ROOT=${TENSORRT_ROOT} \ 41 | -DCUSTOM_OPERATOR_FILES=${CUSTOM_OPERATOR_FILES} 42 | 43 | make -j 44 | -------------------------------------------------------------------------------- /paddle3d/transforms/base.py: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2022 PaddlePaddle Authors. All Rights Reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | 15 | import abc 16 | from typing import Optional 17 | 18 | import numpy as np 19 | 20 | from paddle3d.apis import manager 21 | from paddle3d.sample import Sample 22 | 23 | 24 | class TransformABC(abc.ABC): 25 | @abc.abstractmethod 26 | def __call__(self, sample: Sample): 27 | """ 28 | """ 29 | 30 | 31 | @manager.TRANSFORMS.add_component 32 | class Compose(TransformABC): 33 | """ 34 | """ 35 | 36 | def __init__(self, transforms): 37 | if not isinstance(transforms, list): 38 | raise TypeError('The transforms must be a list!') 39 | self.transforms = transforms 40 | 41 | def __call__(self, sample: Sample): 42 | """ 43 | """ 44 | for t in self.transforms: 45 | sample = t(sample) 46 | 47 | if sample.modality == 'image' and sample.meta.channel_order == 'hwc': 48 | sample.data = sample.data.transpose((2, 0, 1)) 49 | sample.meta.channel_order = "chw" 50 | 51 | elif sample.modality == 'multimodal' or sample.modality == 'multiview': 52 | if 'img' in sample.keys(): 53 | sample.img = np.stack( 54 | [img.transpose(2, 0, 1) for img in sample.img], axis=0) 55 | 56 | return sample 57 | -------------------------------------------------------------------------------- /configs/smoke/smoke_hrnet18_no_dcn_kitti_mini.yml: -------------------------------------------------------------------------------- 1 | # This is a training configuration for a simplified version of KITTI. It is just for a quick start, 2 | # all the hyperparameters are not strictly tuned, so the training result is not optimal 3 | _base_: '../_base_/kitti_mono.yml' 4 | 5 | batch_size: 8 6 | iters: 10000 7 | 8 | train_dataset: 9 | transforms: 10 | - type: LoadImage 11 | reader: pillow 12 | to_chw: False 13 | - type: Gt2SmokeTarget 14 | mode: train 15 | num_classes: 3 16 | input_size: [1280, 384] 17 | - type: Normalize 18 | mean: [0.485, 0.456, 0.406] 19 | std: [0.229, 0.224, 0.225] 20 | 21 | val_dataset: 22 | transforms: 23 | - type: LoadImage 24 | reader: pillow 25 | to_chw: False 26 | - type: Gt2SmokeTarget 27 | mode: val 28 | num_classes: 3 29 | input_size: [1280, 384] 30 | - type: Normalize 31 | mean: [0.485, 0.456, 0.406] 32 | std: [0.229, 0.224, 0.225] 33 | 34 | optimizer: 35 | type: Adam 36 | 37 | lr_scheduler: 38 | type: MultiStepDecay 39 | milestones: [5000, 8000] 40 | learning_rate: 1.25e-4 41 | 42 | model: 43 | type: SMOKE 44 | backbone: 45 | type: $paddleseg.HRNet_W18 46 | pretrained: https://bj.bcebos.com/paddleseg/dygraph/hrnet_w18_ssld.tar.gz 47 | head: 48 | type: SMOKEPredictor 49 | num_classes: 3 50 | reg_channels: [1, 2, 3, 2, 2] 51 | num_channels: 256 52 | norm_type: "gn" 53 | in_channels: 270 54 | depth_ref: [28.01, 16.32] 55 | # dim_ref is the reference size mentioned in the paper, the order here is [l, h, w] 56 | dim_ref: [[3.88, 1.63, 1.53], [1.78, 1.70, 0.58], [0.88, 1.73, 0.67]] 57 | max_detection: 50 58 | pred_2d: True 59 | 60 | export: 61 | transforms: 62 | - type: LoadImage 63 | reader: pillow 64 | to_chw: False 65 | to_rgb: True 66 | - type: Normalize 67 | mean: [0.485, 0.456, 0.406] 68 | std: [0.229, 0.224, 0.225] 69 | -------------------------------------------------------------------------------- /test_tipc/configs/paconv/train_infer_python.txt: -------------------------------------------------------------------------------- 1 | ===========================train_params=========================== 2 | model_name:PAConv 3 | python:python3.7 4 | gpu_list:0 5 | Global.use_gpu:True|True 6 | Global.auto_cast:fp32 7 | Global.epoch_num:lite_train_lite_infer=1|whole_train_whole_infer=500 8 | Global.save_model_dir:./output/ 9 | Train.loader.batch_size_per_card:lite_train_lite_infer=2|whole_train_whole_infer=4 10 | Global.pretrained_model:null 11 | train_model_name:latest 12 | train_infer_img_dir:./train_data/icdar2015/text_localization/ch4_test_images/ 13 | null:null 14 | ## 15 | trainer:norm_train 16 | norm_train:./tools/train.py --config ./test_tipc/configs/paconv/paconv_modelnet40.yml --num_workers 0 --save_interval 1 --do_eval --save_dir ./test_tipc/output 17 | pact_train:null 18 | fpgm_train:null 19 | distill_train:null 20 | null:null 21 | null:null 22 | ## 23 | ===========================eval_params=========================== 24 | eval:null 25 | null:null 26 | ## 27 | ===========================infer_params=========================== 28 | Global.save_inference_dir:./output/ 29 | Global.pretrained_model: 30 | norm_export:./tools/export.py --config ./test_tipc/configs/paconv/paconv_modelnet40.yml --model ./test_tipc/output/epoch_1/model.pdparams --save_dir ./test_tipc/output/exported_model --input_shape 1 1024 3 31 | quant_export:null 32 | fpgm_export:null 33 | distill_export:null 34 | export1:null 35 | export2:null 36 | inference_dir:null 37 | infer_model:test_tipc/output/exported_model/paconv.pdmodel 38 | infer_export:null 39 | infer_quant:False 40 | inference:deploy/paconv/python/infer.py 41 | --use_gpu:True|False 42 | --enable_mkldnn:False 43 | --cpu_threads:1|2 44 | --batch_size:1 45 | null:null 46 | --precision:fp32|fp16 47 | --model_file:test_tipc/output/exported_model/paconv.pdmodel 48 | --input_file:test_tipc/data/mini_modelnet40/ply_data_test0.h5 49 | null:null 50 | --enable_benchmark:True 51 | --params_file:test_tipc/output/exported_model/paconv.pdiparams 52 | -------------------------------------------------------------------------------- /deploy/caddn/cpp/cmake/external/boost.cmake: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | set(BOOST_PROJECT "extern_boost") 4 | # To release PaddlePaddle as a pip package, we have to follow the 5 | # manylinux1 standard, which features as old Linux kernels and 6 | # compilers as possible and recommends CentOS 5. Indeed, the earliest 7 | # CentOS version that works with NVIDIA CUDA is CentOS 6. And a new 8 | # version of boost, say, 1.66.0, doesn't build on CentOS 6. We 9 | # checked that the devtools package of CentOS 6 installs boost 1.41.0. 10 | # So we use 1.41.0 here. 11 | set(BOOST_VER "1.41.0") 12 | set(BOOST_TAR "boost_1_41_0" CACHE STRING "" FORCE) 13 | set(BOOST_URL "http://paddlepaddledeps.bj.bcebos.com/${BOOST_TAR}.tar.gz" CACHE STRING "" FORCE) 14 | 15 | MESSAGE(STATUS "BOOST_TAR: ${BOOST_TAR}, BOOST_URL: ${BOOST_URL}") 16 | 17 | set(BOOST_SOURCES_DIR ${THIRD_PARTY_PATH}/boost) 18 | set(BOOST_DOWNLOAD_DIR "${BOOST_SOURCES_DIR}/src/${BOOST_PROJECT}") 19 | 20 | set(BOOST_INCLUDE_DIR "${BOOST_DOWNLOAD_DIR}" CACHE PATH "boost include directory." FORCE) 21 | set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) 22 | include_directories(${BOOST_INCLUDE_DIR}) 23 | 24 | ExternalProject_Add( 25 | ${BOOST_PROJECT} 26 | ${EXTERNAL_PROJECT_LOG_ARGS} 27 | DOWNLOAD_DIR ${BOOST_DOWNLOAD_DIR} 28 | URL ${BOOST_URL} 29 | DOWNLOAD_NO_PROGRESS 1 30 | PREFIX ${BOOST_SOURCES_DIR} 31 | CONFIGURE_COMMAND "" 32 | BUILD_COMMAND "" 33 | INSTALL_COMMAND "" 34 | UPDATE_COMMAND "" 35 | ) 36 | 37 | if (${CMAKE_VERSION} VERSION_LESS "3.3.0" OR NOT WIN32) 38 | set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/boost_dummy.c) 39 | file(WRITE ${dummyfile} "const char *dummy = \"${dummyfile}\";") 40 | add_library(boost STATIC ${dummyfile}) 41 | else() 42 | add_library(boost INTERFACE) 43 | endif() 44 | 45 | add_dependencies(boost ${BOOST_PROJECT}) 46 | set(Boost_INCLUDE_DIR ${BOOST_INCLUDE_DIR}) 47 | -------------------------------------------------------------------------------- /deploy/iassd/cpp/cmake/external/boost.cmake: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | set(BOOST_PROJECT "extern_boost") 4 | # To release PaddlePaddle as a pip package, we have to follow the 5 | # manylinux1 standard, which features as old Linux kernels and 6 | # compilers as possible and recommends CentOS 5. Indeed, the earliest 7 | # CentOS version that works with NVIDIA CUDA is CentOS 6. And a new 8 | # version of boost, say, 1.66.0, doesn't build on CentOS 6. We 9 | # checked that the devtools package of CentOS 6 installs boost 1.41.0. 10 | # So we use 1.41.0 here. 11 | set(BOOST_VER "1.41.0") 12 | set(BOOST_TAR "boost_1_41_0" CACHE STRING "" FORCE) 13 | set(BOOST_URL "http://paddlepaddledeps.bj.bcebos.com/${BOOST_TAR}.tar.gz" CACHE STRING "" FORCE) 14 | 15 | MESSAGE(STATUS "BOOST_TAR: ${BOOST_TAR}, BOOST_URL: ${BOOST_URL}") 16 | 17 | set(BOOST_SOURCES_DIR ${THIRD_PARTY_PATH}/boost) 18 | set(BOOST_DOWNLOAD_DIR "${BOOST_SOURCES_DIR}/src/${BOOST_PROJECT}") 19 | 20 | set(BOOST_INCLUDE_DIR "${BOOST_DOWNLOAD_DIR}" CACHE PATH "boost include directory." FORCE) 21 | set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) 22 | include_directories(${BOOST_INCLUDE_DIR}) 23 | 24 | ExternalProject_Add( 25 | ${BOOST_PROJECT} 26 | ${EXTERNAL_PROJECT_LOG_ARGS} 27 | DOWNLOAD_DIR ${BOOST_DOWNLOAD_DIR} 28 | URL ${BOOST_URL} 29 | DOWNLOAD_NO_PROGRESS 1 30 | PREFIX ${BOOST_SOURCES_DIR} 31 | CONFIGURE_COMMAND "" 32 | BUILD_COMMAND "" 33 | INSTALL_COMMAND "" 34 | UPDATE_COMMAND "" 35 | ) 36 | 37 | if (${CMAKE_VERSION} VERSION_LESS "3.3.0" OR NOT WIN32) 38 | set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/boost_dummy.c) 39 | file(WRITE ${dummyfile} "const char *dummy = \"${dummyfile}\";") 40 | add_library(boost STATIC ${dummyfile}) 41 | else() 42 | add_library(boost INTERFACE) 43 | endif() 44 | 45 | add_dependencies(boost ${BOOST_PROJECT}) 46 | set(Boost_INCLUDE_DIR ${BOOST_INCLUDE_DIR}) 47 | -------------------------------------------------------------------------------- /deploy/petr/cpp/cmake/external/boost.cmake: -------------------------------------------------------------------------------- 1 | include(ExternalProject) 2 | 3 | set(BOOST_PROJECT "extern_boost") 4 | # To release PaddlePaddle as a pip package, we have to follow the 5 | # manylinux1 standard, which features as old Linux kernels and 6 | # compilers as possible and recommends CentOS 5. Indeed, the earliest 7 | # CentOS version that works with NVIDIA CUDA is CentOS 6. And a new 8 | # version of boost, say, 1.66.0, doesn't build on CentOS 6. We 9 | # checked that the devtools package of CentOS 6 installs boost 1.41.0. 10 | # So we use 1.41.0 here. 11 | set(BOOST_VER "1.41.0") 12 | set(BOOST_TAR "boost_1_41_0" CACHE STRING "" FORCE) 13 | set(BOOST_URL "http://paddlepaddledeps.bj.bcebos.com/${BOOST_TAR}.tar.gz" CACHE STRING "" FORCE) 14 | 15 | MESSAGE(STATUS "BOOST_TAR: ${BOOST_TAR}, BOOST_URL: ${BOOST_URL}") 16 | 17 | set(BOOST_SOURCES_DIR ${THIRD_PARTY_PATH}/boost) 18 | set(BOOST_DOWNLOAD_DIR "${BOOST_SOURCES_DIR}/src/${BOOST_PROJECT}") 19 | 20 | set(BOOST_INCLUDE_DIR "${BOOST_DOWNLOAD_DIR}" CACHE PATH "boost include directory." FORCE) 21 | set_directory_properties(PROPERTIES CLEAN_NO_CUSTOM 1) 22 | include_directories(${BOOST_INCLUDE_DIR}) 23 | 24 | ExternalProject_Add( 25 | ${BOOST_PROJECT} 26 | ${EXTERNAL_PROJECT_LOG_ARGS} 27 | DOWNLOAD_DIR ${BOOST_DOWNLOAD_DIR} 28 | URL ${BOOST_URL} 29 | DOWNLOAD_NO_PROGRESS 1 30 | PREFIX ${BOOST_SOURCES_DIR} 31 | CONFIGURE_COMMAND "" 32 | BUILD_COMMAND "" 33 | INSTALL_COMMAND "" 34 | UPDATE_COMMAND "" 35 | ) 36 | 37 | if (${CMAKE_VERSION} VERSION_LESS "3.3.0" OR NOT WIN32) 38 | set(dummyfile ${CMAKE_CURRENT_BINARY_DIR}/boost_dummy.c) 39 | file(WRITE ${dummyfile} "const char *dummy = \"${dummyfile}\";") 40 | add_library(boost STATIC ${dummyfile}) 41 | else() 42 | add_library(boost INTERFACE) 43 | endif() 44 | 45 | add_dependencies(boost ${BOOST_PROJECT}) 46 | set(Boost_INCLUDE_DIR ${BOOST_INCLUDE_DIR}) 47 | --------------------------------------------------------------------------------